1. Introduction

When users log into a Linux system, they may trigger various programs that are configured to launch automatically. When applications are added or removed as startup programs, they can impact the system’s overall performance and speed.

In this tutorial, we’ll discuss several approaches to managing startup applications for optimizing system efficiency and performance.

2. Manage Startup Applications

We’re covering instructions for the GNOME desktop environment in this example, but other desktop environments will ordinarily have a similar utility in which startup applications can be managed.

Let’s begin with opening the Startup Application utility by searching for it in the Activities menu:

Lanching Startup Applications in Linux

The Startup Application utility’s launch window displays the programs already set as startup applications, such as Slack and SSH Key Agent, in our case. Alongside the program list, a list of buttons allows users to add, remove, or edit the startup programs:

Programs currently set as startup applications
Let’s look at how the Startup Application utility manages startup programs.

2.1. Adding Startup Applications

To add a startup application, we’ll use the Add button on the right side of the pane. Let’s add the Sound Switcher Indicator program to the list of startup applications.

First, click on the Add button and provide a name for the program, e.g., Sound Switcher Indicator. Next, we must add the name of an executable file or provide the path to it either by entering it manually or by using the Browse button.

The Comment field can be used to provide the startup program description. After filling all the necessary fields, we click the Add button:

Adding new startup application

As the output screen shows, the Sound Switcher Indicator application has now been added to the list of startup applications:
New startup applications added
Once done, we can click the Close button to exit the window.

2.2. Disable or Remove Startup Applications

The Startup application utility can provide an option to either remove a program altogether or disable it temporarily.

To disable a specific program from the list, we simply select the program and uncheck the checkbox next to it.

Additionally, to remove any other startup application from the list, we select the specific application and hit the Remove button from the right pane of the management utility:

Selecting specific startup applications to remove it

For example, we don’t need the Sound Switcher Indicator as a startup application. Therefore, we’re removing it from the list of applications to prevent it from launching at the system start.

Here, we select the application Sound Switcher Indicator from the list and tap the Remove button on the right:

Sound Switcher Indicator startup applications is removed here
In the above window, the Sound Switcher Indicator application is now successfully removed from the list and will no longer open at system startup.

2.3. Delay Startup Applications

To maximize system performance, we can minimize the use of system resources by adding delays for startup applications. This way, our startup applications won’t attempt to start simultaneously, resulting in better system performance.

Suppose we want to delay the startup launch of SSH Key Agent for three minutes. So, we select SSH Key Agent from the list and click on the Edit button from the right pane. The window to edit the startup SSH Key Agent program has all the necessary auto-filled fields.

Here, only the Command field needs to be updated:

Delaying the startup launch of SSH Key Agent application
Hence, we’re adding sleep 180 before the instruction in the Command field. Click on the Save button to save the changes. A delay of precisely three minutes will occur before the execution of the actual instruction:Adding sleep 180 for the delay of startup application
After three minutes, the command will be executed, and the SSH Key Agent program will be launched as a startup application.

3. Manage Startup Applications Using systemd

systemd is the Linux-based service manager that manages all the automatic startup services. Linux systems provide several commands to use systemd.

Thus, let’s look at a few options for using systemd commands.

3.1. Listing All Services

The systemctl command lists all the startup applications on the shell. This command takes the list-unit-files flag and—type as an argument.

Here, we assign service as a parameter value to the option type:

$ systemctl list-unit-files --type=service
UNIT FILE                                  STATE           VENDOR PRESET
accounts-daemon.service                    enabled         enabled      
acpid.service                              disabled        enabled      
alsa-restore.service                       static          -            
alsa-state.service                         static          -            
alsa-utils.service                         masked          enabled      
anacron.service                            enabled         enabled      
apparmor.service                           enabled         enabled      
....

Here, the output displays all the currently available startup applications.

3.2. Checking Service Status

The systemctl command for systemd is used to find the current status of any startup application.

For instance, we’re using the status parameter followed by the name of a service, snapd:

$ systemctl status snapd
● snapd.service - Snap Daemon
     Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2024-07-30 23:21:16 PKT; 7h ago
TriggeredBy: ● snapd.socket
   Main PID: 464 (snapd)
      Tasks: 8 (limit: 9433)
     Memory: 63.6M
        CPU: 5.364s
     CGroup: /system.slice/snapd.service
             └─464 /usr/lib/snapd/snapd

Here, the output shows that snapd is currently active and running.

3.3. Disabling a Service

Now, we’re disabling the service using the systemctl command to prevent it from automatically starting at system boot.

Here, we’re using the systemctl command, followed by the is-enabled option, and the name of a service, snapd, to check whether it is enabled or not:

$ systemctl is-enabled snapd
enabled

In our case, it’s enabled.

Now, we’re using the systemctl command with the disable option to disable the snapd service:

$ sudo systemctl disable snapd
Removed /etc/systemd/system/multi-user.target.wants/snapd.service.

$ systemctl is-enabled snapd
disabled

The snapd service is successfully disabled as per the output above.

3.4. Stopping a Service

Just like we’ve disabled a particular service, we can also stop it to halt its activities.

For instance, the systemctl command, along with the stop option, helps to stop the snapd service’s activities:

$ sudo systemctl stop snapd
Warning: Stopping snapd.service, but it can still be activated by:
  snapd.socket

Then, let’s check the status of the snapd service:

$ systemctl status snapd
○ snapd.service - Snap Daemon
     Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Wed 2024-07-31 06:46:28 PKT; 50s ago
TriggeredBy: ● snapd.socket
    Process: 464 ExecStart=/usr/lib/snapd/snapd (code=exited, status=0/SUCCESS)
   Main PID: 464 (code=exited, status=0/SUCCESS)
        CPU: 5.388s

Thus, we can see from the output above that the snapd service is currently inactive.

3.5. Enabling and Restarting a Service

In case a particular service is disabled, we can try to enable it using the enable option within the systemctl command.

Following that, the is-enabled option can be used in the systemctl command to verify the service enabled:

$ sudo systemctl enable snapd
$ sudo systemctl is-enabled snapd
enabled 

The systemctl command uses the start option to start a currently inactive service, such as snapd.

Along with that, we’re using the systemctl status command to verify that the service is successfully activated:

$ sudo systemctl start snapd
$ systemctl status snapd
● snapd.service - Snap Daemon
     Loaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2024-07-31 06:49:23 PKT; 6s ago
TriggeredBy: ● snapd.socket
   Main PID: 10197 (snapd)
      Tasks: 7 (limit: 9433)
     Memory: 11.8M
        CPU: 279ms
     CGroup: /system.slice/snapd.service
             └─10197 /usr/lib/snapd/snapd

Finally, the command provides statistics for the snapd service.

4. Conclusion

In this article, we’ve discussed the process of managing startup applications.

First, we’ve used GNOME’s Startup Application tool to administer the startup applications. Afterward, three approaches were considered for handling startup applications: adding, removing, and delaying. After that, we used the systemctl command for systemd to list all services, check their status, disable, and stop a service.

Finally, we’ve demonstrated a way to enable and restart the disabled service.