How to Run a Program at Startup Using Ubuntu

Ubuntu Startup Applications
Run Applications At Startup Using Ubuntu.

Juergen Haas 

In this guide you will be shown how to launch applications when Ubuntu starts. You will be pleased to know that you do not need the terminal at all to be able to do this, as there is a fairly straight forward graphical tool to help you.

Startup Application Preferences

The tool used to get applications to start when Ubuntu loads is called Startup Application Preferences. Press the super key (Windows key) on the keyboard to bring up the Ubuntu Dash and search for "Startup." It is likely that two options will be available; one will be for the Startup Disk Creator and the other is Startup Applications.

Click on the Startup Applications icon. A screen will appear like the one in the image above.

There will already be some items listed as startup applications, and it is recommended that you not alter these.

The interface is fairly straight forward. There are just three options: Add, Remove, and Edit.

Adding Programs as Startup Applications

To add a program at startup click the Add button. A new window will appear with three fields:

  • Name
  • Command
  • Comment

Enter the name of something that you will recognize in the Name field. For instance, if you want Rhythmbox to run at startup, type "Rhythmbox" or "Audio Player."

In the Comment field, provide a good description of what is to be loaded. This can help explain the purpose of the application and why it is running at start up.

The Command field is the most involved part of this process. This is the actual command you want to execute, and it can be a program name or the name of the script. For example, to get Rhythmbox to run at startup all you have to do is type "Rhythmbox".

If you don't know the correct name of the program you want to run, or you don't know the path for it, click the Browse button and navigate to it on your system.

When you have entered all the details, click OK. The application will be added to the startup list.

Finding Commands for Applications

Adding Rhythmbox as an application at startup is quite easy because it is the same as the name of the program. However, if you want something like Chrome to run at startup then entering "Chrome" as the command will not work. 

The Browse button isn't particularly very useful on its own because, unless you know where a program is installed, it can be hard to find.

As a quick tip most applications are installed in one of the following locations:

  • /usr/bin
  • /usr/sbin
  • /usr/local/bin
  • /usr/local/sbin

If you know the name of the program you wish to run, you can open a command prompt by pressing CTRL+ALT+T and entering the following command:

which google-chrome

This will return the path to the application. For example, the above command will return the following:

/usr/bin/google-chrome

It may not be immediately obvious to everyone that to run Chrome you have to use google-chrome. An easier way to find out how a command is run is to physically open the application by selecting it from the Dash. Simply press the super key and search for the application you wish to load at startup and click the icon for that application.

Now open a terminal window and type the following:

top -c

A list of the running applications will be displayed. You should recognize the application you are running. The best thing about doing it this way is that it provides a list of switches that you might wish to include as well.

Copy the path from the command and paste it into the Command field on the Startup Applications screen.

Writing Scripts to Run Commands

In some cases, it isn't a good idea to execute the command at startup but to run a script which will execute the command. A good example of this is the conky application which displays system information on your screen. In this case, you won't want Conky to launch until the display has fully loaded. A sleep command can prevent Conky starting too soon.

Editing Commands

If you need to tweak a command because it doesn't run properly, on the Startup Applications Preferences screen click on the Edit button.

The screen that appears is the same as the one for the Add New Startup Application screen. The name, command, and comment fields will already be populated. 

Amend the details as required and then click OK.

Preventing Applications From Running at Startup

To remove an application that is set to run at startup, select the line within the Startup Application Preferences screen and click the Remove button. As mentioned, it is not a good idea to remove the default items that were not added by you.