How to run an application on Linux from the terminal

Last Updated on 22. May 2022 by Victor Karp

This tutorial explains how to run an application on Linux from the terminal by typing the application name. This allows you to run AppImages, scripts or any executable file from a terminal, even though you have not installed it via any type of package manager.

The quick TL;DR (Too Long; Didn’t Read) below will most likely be enough to answer your question. The remaining article gives some more technical background infos.

The quick TL;DR answer

Copy the application itself or a link to the application to the.local/bin folder in your home directory. You can now run it by typing the exact name of the file into the terminal.

If you can’t see the .local folder in your home directory, press Ctrl + Hto show hidden files. This hotkey works in all popular file managers. If it doesn’t, look around your file manager’s menus.

If the .local or bin folder doesn’t exist, simply create it yourself. In this case, you also have to log out and back in again before the terminal recognizes applications or application links inside the bin folder.

What is $PATH?

Linux uses various other folders that it scans for applications or application links. If you type something into a terminal and Linux can find an application with that name in one of these folders, the application will run.

These folders are commonly called “$PATH” or just “PATH”. You can find out which folders are part of your $PATH by running echo $PATH in a terminal. The output will look similar to this:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

The colons are line breaks, which means that I’ve got the following folders as part of my $PATH on my machine:

  • /usr/local/sbin
  • /usr/local/bin
  • /usr/sbin
  • /usr/bin
  • /sbin
  • /bin
  • /usr/games
  • /usr/local/games
  • /snap/bin

These folders are used for different purposes. If you didn’t use the method outlined in the quick TL;DR answer, you will usually want to put your application links into /usr/local/bin (instead of /home/user/.local/bin). There is a Wikipedia page about the Filesystem Hierarchy Standard that explains what most of the folders listed above are for and what the differences are.

Contrary to the /home/user/.local/binfolder, all of the folders listed above require Root rights (sudo) to modify the files inside them. This means that you can’t simply copy your links into them without some extra steps.

How to create a link from the terminal by using “ln”

The ln terminal command allows you to create a link to a file at a location of your choice. The syntax is:

ln [parameters] [original file path] [target path and file name]

By writing sudo before it, you can create links in folders that require admin rights. Adding the -s parameter creates a soft link instead of a hard link to your file. This excellent article explains the difference between hard and soft links.

Here’s what this looks like if I want to create a link from a Krita AppImage in /home/victor/Applications to /usr/local/bin:

sudo ln -s /home/victor/Applications/krita-4.4.5-x86_64.appimage /usr/local/bin/krita

If you want to override an existing link (for example if the location of your AppImage has changed and the link is now broken), you have to add the -f parameter:

sudo ln -s -f /home/victor/Applications/krita-4.4.5-x86_64.appimage /usr/local/bin/krita

If you want to remove a file in this folder, you can use the rm command, like so:

sudo rm /usr/local/bin/name_of_your_file

Visit the Linux tutorials main page for more Linux tutorials.

Scroll to top