How to start a program automatically in Linux desktop

Sometimes you may want to launch a program automatically when you log in to your Linux desktop. Such start-up programs can conduct system-wide configuration (e.g., auto proxy) or user-specific desktop customization (e.g., Conky), at the time you log in to your desktop.

Most Linux desktop environments have their own GUIs that allow users to configure user-specific auto-start programs or services.

In this tutorial, I will describe how to start a program automatically in various Linux desktop environments.

GNOME Desktop Environment

Run this command in a terminal to launch "Startup Applications Preferences" GUI.

$ gnome-session-properties

Click on "Add" button to configure a new startup application. Type in the name of the app, and the CLI command for the app, in "Name" and "Command" fields respectively. Type in optional description in "Comment" field.

Unity Desktop Environment

Type "startup" in Unity Dash. Once "Startup Applications" icon appears, click on it.

Once "Startup Applications Preferences" window opens up, enter "Name", "Command" and "Comment" to configure a program to auto-start.

KDE Desktop Environment

First, open up "System Settings" window. You will find "Startup and Shutdown" icon under System Administration. Click on the icon.

You will be asked to choose an application to auto-start among a list of known applications. If your program is not listed, enter the name of the program in the top blank. If the program (e.g., CLI command) shall be run in a terminal, turn on the checkbox for "Run in terminal". Click on "OK" button.

Next, you will be asked to enter the detail of the app, including name, command, and description.

After this, you will see that the program is configured to run on start-up. To configure additional start-up programs/scripts, you can click on "Add Program" or "Add Script" buttons in the right sidebar.

MATE Desktop Environment

On MATE desktop, go to "Applications" -> "Preferences" -> "Startup Applications"

You will see "Startup Applications Preferences" window. Click on "Add" button.

Enter the detail of a startup program: "Name", "Command" and "Comment".

Xfce Desktop Environment

Choose "Settings Manager" from Xfce desktop menus. In "Settings" window, click on "Session and Startup" icon.

Under "Application Autostart" tab, click on "Add" button at the bottom.

Enter the detail of a program to auto-start: "Name", "Command" and "Description".

LXDE Desktop Environment

To configure a start-up program on LXDE desktop environment, run the following commands in a terminal.

$ mkdir -p ~/.config/lxsession/Lubuntu/
$ touch ~/.config/lxsession/Lubuntu/autostart
$ leafpad autostart

Then add the following entry to the created autostart file:


Here, "conky" is the name of the CLI command that I want to auto-run upon log in.

Save and close.

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

16 thoughts on “How to start a program automatically in Linux desktop

  1. Omg just add it to autostart list, all distros I've seen had a simple GUI tool for it. Do we need a tutorial on how to click mouse?

    • Many people do find these kinds of tutorials very helpful. Don't begrudge them that .. more documentation is never bad.

    • Most desktop environments no longer look at .xinitrc (since that's supposed to be capable of jump-starting your entire X session).

      • Your DE doesn't have to look at X Window's init file, X Window will. Try it and see what happens. echo "xterm &" > ~/.xinitrc Then start an X session and see if you don't have an xterminal when you begin. Well, make sure you're not blowing away a ~/.xinitrc before you do that. cat ~/.xinitrc and make sure you get the No such file or directory message first.

        • I've seen a number of systems where the base X stuff won't look at .xinitrc when starting up a system-default window manager, because .xinitrc has traditionally been for launching an entire session. Which of course results in hilarity if Gnome starts up and your .xinitrc starts doing conflicting calls to xrdb and xmodmap and so on.

          There's also been more than a few systems that were horribly, horribly confoozled about the difference between .xinitrc and .xsession

          • My global xinitrc actually calls Xsession so I guess you've just seen a lot of broken systems. Because X Window really should be able to handle xinit and Xsession too. Mine does.

    • You can, but the desktop autostart mechanisms allow for more automated control. If you're a xinitrc kind o' guy then it hardly matters, probably :)

  2. I hate bash as a programming language with passion, but bash is a goddamn lingua franca. How do I change nameserver? echo 'nameserver' > /etc/resolv.conf and such.

    The last tech related thing with such amount of screenshots I've read was a book on Zabbix, and it was a terrible experience.

  3. Under Linux Mint-15, using the Cinnamon desktop environment, one can use the desktop menus,
    | select MintMenu --> Preferences --> StartupApplications
    At this point the existing instructions about use of the ADD button and filling the resulting form apply.

    My approach will tend to use a script and wrap the command that actually starts a program. That overhead is more than paid for by the uniformity of the application launch and error detection and notification.
    ~~~ 0;-Dan

  4. Hi, in Lubuntu 14.04 LTS, I have to go in the Lxde Menu> preference > default application for LxSession
    Choose the tab "autosart" and clic on the "+" button on the top to add a "Manual autostarted application" and type "AppName"

Leave a comment

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