Automatically Launch Applications at Startup on Linux Using Desktop Entries

2025-09-28
3 min read

Introduction

Manually opening the same set of essential applications—such as a web browser, code editor, and terminal—every time you log into your computer can be a repetitive and time-consuming task. Fortunately, most Linux desktop environments provide a simple and standardized way to automate this process, saving you time and streamlining your workflow.

This guide will walk you through the process of automatically launching your favorite applications at startup by creating .desktop files in the autostart directory.

The Solution: The Autostart Directory

The Freedesktop standard, which is followed by most popular desktop environments like GNOME, KDE, and XFCE, specifies a special directory where users can place application launchers that should be run automatically upon login. This directory is located at ~/.config/autostart/.

By creating simple text files with a .desktop extension and placing them in this folder, you can command the system to launch any application or script you need.

Step 1: Ensure the Autostart Directory Exists

First, you need to make sure the autostart directory exists in your home configuration folder. If it doesn’t, you can create it with a single command. Open your terminal and run the following:

mkdir -p ~/.config/autostart

How It Works

  • mkdir: The standard command to “make a directory”.
  • -p (or --parents): A useful option that tells mkdir to create any necessary parent directories. In this case, if ~/.config doesn’t exist, it will be created first, followed by the autostart directory inside it.

Step 2: Create .desktop Files for Each Application

Next, we will create a separate .desktop file for each application you want to launch at startup. These files follow a simple INI file format.

You can create these files using any text editor, such as gedit, nano, or vim. For example, to create the file for Firefox, you could run gedit ~/.config/autostart/firefox.desktop and paste the content below.

Core .desktop File Structure

A minimal .desktop file for autostart purposes includes the following key-value pairs:

  • [Desktop Entry]: The required header for the file.
  • Type=Application: Specifies that this file is an application launcher.
  • Name=AppName: A human-readable name for the application.
  • Exec=command: The exact command used to launch the application from the terminal. This is the most critical line.
  • Terminal=false: Instructs the system not to open a terminal window to run the command.

Example Configurations

Here are the specific .desktop file contents for the applications you want to launch automatically.

Firefox

Create a file named firefox.desktop:

[Desktop Entry]
Type=Application
Name=Firefox
Exec=firefox
Terminal=false

Sublime Text

Create a file named sublime-text.desktop:

[Desktop Entry]
Type=Application
Name=Sublime Text
Exec=subl
Terminal=false

GNOME Terminal

Create a file named terminal.desktop. The executable for the terminal can vary; gnome-terminal is the default on GNOME-based systems like RHEL, Fedora, and Ubuntu.

[Desktop Entry]
Type=Application
Name=Terminal
Exec=gnome-terminal
Terminal=false

Visual Studio Code

Create a file named vscode.desktop:

[Desktop Entry]
Type=Application
Name=Visual Studio Code
Exec=code
Terminal=false

Conclusion

Once you have created and saved these files in the ~/.config/autostart/ directory, the changes will take effect on your next login. When you log out and log back in, Firefox, Sublime Text, your terminal, and Visual Studio Code will all launch automatically.

This method provides a powerful yet simple way to customize your desktop environment and create a more productive workspace tailored to your needs.