Auto Start a Desktop Application on the Rapberry PI

In the article on ten things to do after after buying a Raspberry PI, item number 9 shows how to automatically start an application at boot time when booting to the command prompt. This blog article will now show how to auto start an application when booting into the desktop of the Raspbian operating system running on the PI. It also shows how to auto run a command line application or shell script in a terminal window on the desktop.

NOTE: This is one way to auto start applications, but not the only way. There are other methods to do the same thing.

Auto Starting a Raspberry PI Desktop Application

The Setup

Some folders (directories) and a file need to be created as described here. How to do this is explained below the description.

  1. First create a folder called lxsession in the hidden folder called .config in the home directory.
  2. Now create a folder called LXDE-pi (name the folder LXDE in older Raspbian versions) in the lxsession folder.
  3. Finally create a text file called autostart in the lxsession folder.

You should end up with:


Or on older Raspbian versions:


Starting the Application Automatically

To start the application automatically, edit the autostart text file that you created above and add the application name that you want to start preceded by the @ symbol. For example, to auto start the calculator application (called galculator) the contents of your autostart file would look like this:


The next time that you start the desktop, the calculator application will automatically start.

If you write your own application that does not appear in the Linux PATH, then you will need to specify the path to the application, e.g. for an application in the home directory:




How to Do the Setup from the Desktop

To do the above steps on the desktop, start the file manager and then press Ctrl + H to show the hidden files and folders. Double-click the .config folder to open it. Right-click in the folder and use the pop-up menu to create the lxsession folder. Open the lxsession folder, right-click again and create the LXDE-pi folder. Open the LXDE-pi folder, right-click again and create the autostart text file. Double-clicking the autostart file will open it in the text editor. Add your application name to the file and save — don’t forget the preceding @ symbol as described above. Press Ctrl + H again any time that you want to hide the hidden files and folders in the file manager (Hidden files and folders have a period or dot (.) in front of their names in Linux. Ctrl + H toggles between hiding and showing these files in the file manager).

How to Do the Setup from the Command Line

On the command line in the pi home directory, enter:

mkdir -p .config/lxsession/LXDE-pi
nano .config/lxsession/LXDE-pi/autostart

Now enter the application that you want to automatically start, then save the file and exit (don’t forget the preceding @ symbol), e.g.:


Save the file in nano:

Ctrl + o

Exit nano:

Ctrl + x

Auto Starting a Raspberry PI Command Line Application on the Desktop

To start a command line application in a terminal window on the desktop, you will need to do the above steps to auto start the terminal window called lxterminal. In the auto start file, add the following line:


To run a command line application in the terminal, it is necessary to use the same method that was used in the article ten things to do after after buying a Raspberry PI, item number 9. And that is…

Open the hidden file .bashrc found in the home directory and add the name of the application or script that you want to run. For example, to run the top command line application, the end of your .bashrc file will look like this:

# existing text in .bashrc file ...
    . /etc/bash_completion

This will run top in a terminal window the next time that you start the desktop.

To run a custom script in the terminal window on the desktop, insert the path to the script and the script name. E.g. for a script called found in the home directory:

# existing text in .bashrc file ...
    . /etc/bash_completion


13 thoughts on “Auto Start a Desktop Application on the Rapberry PI

  1. hi and thanks that was nice and easy to follow.

    my question , is it possible to start the browser in full screen and to a specific website?

    thanks for your reply


    • Yes you can do that,
      Running Chrome at start-up (without anything else running):
      Edit the autostart file: sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
      # Auto run the browser
      @xset s off
      @xset -dpms
      @xset s noblank
      @chromium-browser –kiosk

      Note: Comment out everything else (don’t delete it as you might need it later)

  2. I need help. I have configured my RPi to boot to the Dektop GUI, and I want to autostart Iceweasel. I tried this way first, typing:

    sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

    in the terminal and then adding


    to the list of apps. But nothing happened at startup. I also tried typing this into the terminal:

    sudo nano /etc/xdg/lxsession/LXDE/autostart

    (without -pi), but nothing happened at startup. Then I found this webpage. I followed the instructions, and it worked. Iceweasel opened automatically at startup. But there is a problem.

    When I minimize Iceweasel, my Taskbar with the Menu” start button (also called the panel?) has disappeared. Is this normal. It doesn’t reappear if I put my mouse pointer at the top of the screen where the panel was.

    Thanks in advance for any help you can give. PS. I am an extreme noob to RPi and Linux. Trying to learn, though.

  3. Thank you so much, your command line method worked for me after wasting countless hours on stupid raspberry forums.

    Such a simple thing should be in the docs.

  4. Hi,
    I start my browser in kiosk-mode as described and it works great. Thanks for your tutorial. Now I want to start another application on my second workspace. Is ther a chance to specify this also in autostart or is there another way to do it. Thanks in advance…. Jo

    • Hi Jo
      I haven’t tried to automatically open a second application on another desktop before. Maybe someone else can answer that question.

    • Hi Paul
      It should work with a Python script. Just make sure the script is marked as executable or call python and pass the script to it.

  5. I want to run python script using picamera and its output as display of video for robotic application. I am running as You mentioned but its not running.
    I make the python script executable by
    chmod +x
    and then add line to auto start


  6. Thank You!
    You Saved Me!
    But let’s consider this: newbies like me will always be newbies.
    What do I mean by that: learning linux internals takes time. A newbie does not have time and just wants to dive into coding and “do cool stuff”. Being aware it is possible does not mean easy. Then we bang our head against the wall and, after the wall fell down, we find some blogger like you to help us. Thank you for your work. For your passion.

Leave a Reply

Your email address will not be published. Required fields are marked *