ubuntu startup applications

Ubuntu ships with the gnome-startup-applications applet which lets you easily manage startup applications via the GUI. If you’re on Ubuntu server or a similar installation with no GUI, you can do the same by creating a .desktop file in the terminal. Systemctl is also useful when you want to configure programs that are managed through systemd (e.g., NGINX).

Startup Applications Preferences

Search and open Startup Applications Preferences from the Activities overview. Alternatively, you can also press Alt + F2 and enter the gnome-session-properties command there.

This applet is very easy to understand and use. The Add button lets you specify the command to run at login.

For instance, to run Discord at login, you’d enter the path of the binary (e.g., /snap/bin/discord) in the command section. This creates a .desktop file in the ~/.config/autostart/ directory.

If you’re trying to add a program installed using apt, you’ll want to check the /usr/bin/ directory instead (e.g., /usr/bin/google-chrome). You can find the full path for commands using the which tool.

which firefox

You can also configure a delayed launch for certain apps by prefixing the command with sleep#;, where # is the time in seconds. 

The Name and Comment fields are optional. You can stop an app from launching at startup by unchecking it, or you can remove the entry entirely with the Remove button.

Create a .desktop File

The Startup Preferences applet is just a GUI front for easily creating .desktop config files. So if you want, you can also do the same thing manually from the terminal. For instance, let’s create one for the Discord app.

sudo nano ~/.config/autostart/discord.desktop

Use the following config:

[Desktop Entry]
Type=Application
Exec=/snap/bin/discord
X-GNOME-Autostart-enabled=true
Hidden=false
NoDisplay=false
Name=Discord
Comment=<description>
Icon=<iconpath>

Save the config and exit the editor (Ctrl + O and Ctrl + X). Then, make this file executable like so

chmod +x ~/.config/autostart/discord.desktop

You can create .desktop files to configure other startup applications in the same manner. You only need to adjust the Exec path. And you actually only need the first 3 lines, the rest are optional.

Finally, you can change X-GNOME-Autostart-enabled to false, or delete the file entirely to stop the app from launching at boot.

Enable Services with Systemctl

If you’re trying to configure a systemd service to launch at boot, you can use the enable command. First, you may want to list the service units with

systemctl list-units --type=service

Let’s say you want to configure your Apache server to launch at startup. All you need to do is enable it using the service name. This’ll create a symbolic link between the systemd autostart directory and the specified service unit file. 

sudo systemctl enable apache2

You can stop the service from automatically starting with the disable command.

sudo systemctl disable apache2
Anup Thapa

Senior Writer

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. His goal is to effectively communicate technical concepts in a simplified form understandable by new Linux users. To this end, he mainly writes beginner-friendly tutorials and troubleshooting guides. Outside of work, he enjoys reading up on a range of topics, traveling, working out, and MOBAs.