432

How can I make an application automatically start when I have logged in?

0

15 Answers 15

529

20.04 and later

  1. If not yet done by default install gnome-startup-applications

  2. Search and open "Startup Applications"

    screenshot

  3. click add to enter the command including options of your application as you would run it from terminal (you may have to give in the full path if it runs from a non-standard location)

    screenshot

  • This will add a .desktop file in your ~/.config/autostart

    screenshot

14.04 and later

  1. Open the Dash and search for "Startup Applications"

    screenshot

  2. Now click on Add and give in the command to run the application. This can be found in Main Menu if installed (see below)


Using Main Menu (alacarte) to find the terminal command to run a given program:

  1. Firstly open the program 'Main Menu' (type Menu in the Dash)

    screenshot

  2. Now select the program which you want to add to startup and click on properties .

    screenshot

  3. Now note the command for that program .

    screenshot


Non GUI approach

Advanced users may want to manually put a .desktop file in ~/.config/autostart to run applications after a user login. This may have following content:

[Desktop Entry]
Type=Application
Name=<Name of application as displayed>
Exec=<command to execute>
Icon=<full path to icon>
Comment=<optinal comments>
X-GNOME-Autostart-enabled=true

You may have to give this file execute permission.

10
  • 37
    useful the "Non GUI approach" part, I was searching that folder!
    – Stefano
    Jan 7, 2013 at 17:50
  • 11
    The Start-up Applications Preferences dialogue can be brought up from ALT+F2 gnome-session-properties if you can't find it in menus (e.g. in Gnome Shell)
    – Marcus
    Jan 28, 2013 at 22:59
  • 2
    gnome-session-properties command was all that I was looking for. Kind of shows how pointless UIs can be (i.e. the time it takes to illustrate everything with screenshots compared to a simple command) Dec 25, 2013 at 18:54
  • Without dash with the traditional menu: System -> Preferences -> Personal -> Startup Applications. Mar 4, 2016 at 9:53
  • 1
    I'm on the latest Ubuntu (groovy) and Startup Applications wasn't there. Turns out I first had to sudo apt install gnome-startup-applications, and then it worked beautifully.
    – kvz
    Dec 19, 2020 at 19:22
29

For 11.04 and newer see here: How do I start applications automatically on login?

For older versions: If the program you wish to run on startup is in the Applications menu, you can drag-and-drop it into the Startup Applications window to add it to the list.

enter image description here

0
27
  1. Launch Startup applications from Dash

    screenshot

  2. Click on Startup Applications

    screenshot

  3. And then click on add

    screenshot

  4. Type the name of the program, browse to the command, and then click add.

Addition: Here is a sample that I use to autostart Guake (the Gnome version of Yakuake):

Put this in the 'command' box.

sh -c "sleep 120s; guake"

This starts guake automatically, but waits 2 mins before doing so. You can change the 120 to whatever you wish.

For 14.04 and 16.04

Type Startup in Dash, and run Startup Application form there

screenshot

And then just follow the rest of the steps.

Please note that, if you are using Ubuntu in another language, "startup" might not find the correct program. Try another search that is in your language.

2
  • In Ubuntu 14.04, I don't see those options in the system menu in the upper right.
    – user29020
    Sep 25, 2014 at 7:39
  • 2
    In 14.04 type Startup in dash, and you can run it from there. Look at the addition in the answer. Thanks
    – Mitch
    Sep 25, 2014 at 13:02
21

Both Unity and Xfce4 have GUI programs that allow you to control startup applications.

For Unity:

enter image description here

enter image description here

For Xfce4 Startup tool is available in Settings > Session and Startup

enter image description here Image courtesy of Xubuntu Geek xubuntugeek

If the GUI is not what you want, and you want is more advance control, then you can put .desktop files in the ~/.config/autostart/ directory for Xfce4, and a .desktop file in ~/.config/autostart for Unity to run applications after a user login.

Check this question to get more help on creating .desktop files:

Also note if you want a startup application to start only in XFCE, but not in Unity, you have to put the line OnlyShowIn=XFCE in the .desktop file. It is OnlyShowIn=Unity for a Unity only application.

2
  • From your answer what I get is that for both you put .desktop file in ~/.config/autostart/ Aug 30, 2012 at 7:37
  • Please if you know by heart what would be that GUI program, for Unity it is Startup Applications(easy to search), for xfce ? Aug 30, 2012 at 7:38
12

You might want to start it from a CLI via:

$ gnome-session-properties

(just in case you're not running GNOME ;))

1
  • 1
    I had no other way of finding the $#@! window. None of the menu items above exist on my machine, but this command brought it right up.
    – Reb.Cabin
    Jan 30, 2017 at 3:28
10

Take a look at $XDG_CONFIG_DIRS/autostart directory:

$ echo $XDG_CONFIG_DIRS/autostart
/etc/xdg/xdg-kde-plasma:/usr/share/upstart/xdg:/etc/xdg/autostart

which says there are 3 directories in this example. I wanted to prune the nautilus entry

sudo rm /etc/xdg/autostart/nautilus-autostart.desktop

otherwise if you can add it, create a Desktop entry file: sudo touch /etc/xdg/autostart/my-shell-autostart.desktop add these contents:

[Desktop Entry]
Name=foo
Terminal=false
Exec=/path/shell.sh
Type=Application
Icon=/path/icon.png
Categories=Utility;
3
  • $XDG_CONFIG_DIRS/autostart adds "autostart" to the last one of the colon separated directories. There may be autostart directory under the other directories separated by colon, as well. Actually the directories are preference-ordered. Besides, if $XDG_CONFIG_DIRS is empty or not set, the configuration file base directory is /etc/xdg. See reference
    – jarno
    Aug 18, 2019 at 23:40
  • And user specific autostart files should be placed under $XDG_CONFIG_HOME/autostart defaulting to $HOME/.config/autostart
    – jarno
    Aug 18, 2019 at 23:53
  • This Solved my problem, thank you!
    – singrium
    Jul 3, 2020 at 9:21
6

You can use GNOME Startup Application. enter image description here

Click the Add button and then add the full command to open the application you want. If you don't know the path of the command you can do

which name_of_commmand

6

Ubuntu 13.10 with UNITY Instructions

To do this with a command that requires sudo is a bit tricky.

In my case, I wanted to disable the PSMOUSE driver using the command sudo rmmod psmouse to prevent a mouse click problem that randomly manifests itself. See Dealing with Mouse and Touchpad Freezes in Linux for more info on this problem. I got tired of entering it on every boot.

On my install, the ~/.config folder did not have an autostart sub-folder, so I created one. This enabled my Startup Applications Preferences settings to be saved.

In order to toggle visibility of hidden startup applications, you can use the following commands.

To show them :

sudo sed -i 's/NoDisplay=true/NoDisplay=false/g' /etc/xdg/autostart/*.desktop

To hide them :

sudo sed -i 's/NoDisplay=false/NoDisplay=true/g' /etc/xdg/autostart/*.desktop

Configure your command as per above posts in the Startup Applications Perferences window.

Name:    Fix Mouse
Command: sudo rmmod psmouse
Comment: Fix Mouse

Then you have to edit the /etc/sudoers file using sudo visudo. Add a line that contains the following info:

username ALL=(ALL) NOPASSWD: /sbin/rmmod

You must enter this line below the line which starts with %admin. I added my line to the end of the file. It is IMPORTANT to use sudo visudo to edit this file as making a mistake will prevent you from being able to do any sudo commands at all. If that happens, boot in recovery mode and undo your edits, then try using sudo visudo.

Note:
Initially I tried using a bash script to run my the command indirectly, but this didn't work. I had to put sudo rmmod psmouse directly in the Edit Startup Program window.

5

For Ubuntu 12.04,

  1. Launch Startup Application from the top right menu

    enter image description here

  2. Without clicking on Add, open Dash and type the application you want running at startup e.g. Skype

    enter image description here

  3. Drag the application to the Startup application window. If Dash windows is too big that you can't drag your app outside, use the restore window button (shown in the previous image) at the top left corner. Final list looks like this:

    http://imgur.com/G60wbOJ

1
  • Well Step 1 doesn't work for Ubuntu 16.10. But the possibility of drag and drop the app into the autostart window works and is great.
    – eDeviser
    Nov 4, 2016 at 8:17
4

Also to put a BATCH FILE into start up applications to run after user login.... type at the command line in start up applications in the field Command:

gnome-terminal  -e  "/batch-path/batch-name.sh" 
  • gnome-terminal: open the terminal after user login with current user privileges
  • -e: set the terminal to execute the batch file
  • /batch-path/batch-name.sh: is the batch full path and full name

Remember than the file batch permissions to set the flag Allow executing file as a program to ON.

2

For a simple, portable way to do this, you can use Cron. Run crontab -e to edit your user's crontab; add @reboot command to run command on each boot.

2

You can use the feature to Remember Currently Running Applications in the System/Preferences/Startup Applications preferences window. Which (when enabled) will "remember" all the programs that you are using and will re-open them after a reboot or when starting the system for the first time in a day.

This is great when you don't have enough time to make notes of what were you doing the last time and you wish an application to open if it was running the last time.

If you wish to remove an application from this feature simply close it and go to this function and press the "Remember Currently Running Application" in order to refresh the list of the programs that will be opened the next time.

enter image description here

2
  • The only thing I do not like about this one is that your/my wireless is slower to come up than my browser is in loading when it was active. Every tab needs to be reloaded after wireless picks up.
    – Rinzwind
    May 8, 2011 at 17:17
  • Good point. That's why I don't save that preference with the browser open :) Docky is owning the control for my browser with an icon on it. But yours is a good point! Thank you. May 9, 2011 at 20:50
1

Type "startup applications" in your Unity Dash and it will list you that application which you can click to open. After opening it, you can add your application there.

0

Alt+F2, then gnome-help ghelp:user-guide?gosstartsession-2.

Click Run, wait a sec, and then follow the directions.

3
  • cool I know the part to add but not the commands... so do I google them? or should I hit alt+f2 then put the name of the program... if it finds it, I'll say run in terminal... to display the command?
    – user11383
    Feb 24, 2011 at 4:43
  • @Bob, which application do you want to run on start up?
    – Oxwivi
    Feb 24, 2011 at 5:35
  • Doesn't work in Ubuntu Studio 18.04
    – R B
    Jul 17, 2020 at 17:34
0

Here's a pitfall with "Startup Applications". I needed to run the following on startup, to activate custom key remapping that I had defined:

xkbcomp -I$HOME/.xkb ~/.xkb/keymap/mykbd $DISPLAY

I put it into "Startup Applications", as in other answers above, and it didn't work.

SOLUTION: putting it in the following way into "Startup Applications" works:

bash -c "xkbcomp -I$HOME/.xkb ~/.xkb/keymap/mykbd $DISPLAY"

(I don't know why. I worked it out by trial-and-error.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .