How can I make an application automatically start when I have logged in?
20.04 and later
- If not yet done by default install
- Search and open "Startup Applications"
- 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)
- This will add a
.desktopfile in your ~/.config/autostart
14.04 and later
- Open the Dash and search for "Startup Applications"
- 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:
- Firstly open the program 'Main Menu' (type
Menuin the Dash)
- Now select the program which you want to add to startup and click on properties .
- Now note the command for that program .
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.
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.
Launch Startup applications from Dash
Click on Startup Applications
And then click on add
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
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)
Both Unity and Xfce4 have GUI programs that allow you to control startup applications.
For Xfce4 Startup tool is available in Settings > Session and Startup
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
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.
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;
For Ubuntu 12.04,
Launch Startup Application from the top right menu
Without clicking on Add, open Dash and type the application you want running at startup e.g. Skype
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:
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.
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
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
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.
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.
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.)