433

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

Lincity
  • 25,371

15 Answers15

530

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.

Pablo Bianchi
  • 15,657
Takkat
  • 142,284
  • 37
    useful the "Non GUI approach" part, I was searching that folder! – Stefano Jan 07 '13 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 '13 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) – Ev Dolzhenko Dec 25 '13 at 18:54
  • Without dash with the traditional menu: System -> Preferences -> Personal -> Startup Applications. – Martin Thoma Mar 04 '16 at 09:53
  • @SuB, to run applications before login: https://help.ubuntu.com/community/UbuntuBootupHowto#Installing_custom_init-scripts – danilo Feb 16 '20 at 15:29
  • @JohnSmith: thank you. Added some fresh shots for 20.04. Make shure you give in the correct command (including full path if needed). – Takkat May 26 '20 at 19:49
  • 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 '20 at 19:22
  • In Ubuntu 20 startup applications is installed by default. I tried it the ~/.config/autostart way but it didn't work. Startup Applications did. – jcollum Aug 28 '21 at 02:36
  • I prefer the "Non GUI approach" too. Raphael commented that the reader might also find /etc/xdg/autostart worth checking out for system-wide autostart, or to find out what happens in the default installation if you're running i3 or something similar. The file you add to the autostart dir (note by leo-the-manic) must end with .desktop or it will be ignored. To give this file execute permission, you can enter chmod +x myapp.desktop. I wanted to add this to the answer, but it was rejected. – Cadoiz Feb 15 '23 at 08:31
  • I don't know why Espanso seems to die whenever my computer sleeps. I've been manually restarting it after logging int. I'm going to try running espanso restart here. – Ryan Mar 05 '24 at 20:41
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

Isaiah
  • 59,344
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.

Pablo Bianchi
  • 15,657
Mitch
  • 107,631
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.

Mitch
  • 107,631
12

You might want to start it from a CLI via:

$ gnome-session-properties

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

Wernight
  • 1,383
  • 10
  • 10
  • 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 '17 at 03: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;
Zanna
  • 70,465
Philippe Gachoud
  • 5,900
  • 3
  • 43
  • 50
  • $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 '19 at 23:40
  • And user specific autostart files should be placed under $XDG_CONFIG_HOME/autostart defaulting to $HOME/.config/autostart – jarno Aug 18 '19 at 23:53
  • This Solved my problem, thank you! – singrium Jul 03 '20 at 09: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

amh
  • 997
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.

Zanna
  • 70,465
gone
  • 369
  • 2
  • 12
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

hg8
  • 13,462
Malay Desai
  • 151
  • 1
  • 2
  • 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 04 '16 at 08: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.

Zanna
  • 70,465
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

Zanna
  • 70,465
  • 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 08 '11 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. – Geppettvs D'Constanzo May 09 '11 at 20:50
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.

appas
  • 185
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.

wjandrea
  • 14,236
  • 4
  • 48
  • 98
Raja G
  • 102,391
  • 106
  • 255
  • 328
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.)

Evgeni Sergeev
  • 115
  • 1
  • 2
  • 8
0

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

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

Lucio
  • 18,843
Volomike
  • 2,283
  • 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? –  Feb 24 '11 at 04:43
  • @Bob, which application do you want to run on start up? – Oxwivi Feb 24 '11 at 05:35
  • Doesn't work in Ubuntu Studio 18.04 – R B Jul 17 '20 at 17:34