I’ve updated the Terms and Conditions for using this website. Take a look!

How to Install Programs on Linux from the Shell

In this tutorial, we will go over using Aptitude (apt for short) to install a program in your Linux system programmatically (in other words, within a shell or terminal).

How to Install a Program in the Linux Command-Line

Find the Package Name of the Program You Want to Install

Linux bundles programs in what are called Linux packages. So in order to install a program in Linux, you need to know the exact package name of that program. There are two ways to do this.

1. In a terminal (called the Command Prompt in Windows), type the following command. (Note, | is the pipe key, which is most likely found on the same key as the \ key on your keyboard. On some keyboards the pipe key may look like two vertical bars, one over the other, instead of one long vertical bar.)

sudo apt search PackageName | less

PackageName should be part of the name of the program. For example, if I were looking to install the Nginx server, I might type nginx in place of the above PackageName placeholder. Note that using a one-word search is best, because apt isn’t as smart as Google, and you may miss a package that exists just because you typed one letter that doesn’t exist in the package name you are looking for. (For example, because the Nginx package name is just nginx, if I typed nginx-server or nginx program, I wouldn’t find the Nginx server package I was looking for, even though it does exist.)

(When you are done using less to peruse the available Linux packages, type the Q key on your keyboard.)

2. If you have access to a web browser, you can also find Linux package names by doing a search on your favorite search engine, like below:

linux apt install Program

Where Program is the program you are looking for.

Update Your List of Known Packages in Apt

Next, update your computers list of known packages and package versions. This is an important step, as it will ensure you install the latest version of the program you want to use.

sudo apt update

Note: If you get a notification that says something like “E: Could not open lock file /var/lib/apt/lists/lock – open (13: Permission denied)”, this means you need administrator privileges to run apt and you don’t have it.

Install the Program Using Apt

Installing the program is easy once you know what the package is called.

sudo apt install PackageName

The Aptitude program will figure out if any other packages are needed by the package you want to install, and then ask you if you want to install these too. Just type Y for yes or N for no, and then hit the Enter key.

Once Aptitude finishes processing, you will see the usual terminal prompt, and you are good to start using your new program.

Comments on "How to Install Programs on Linux from the Shell"

Leave the first comment


X

Be in the Know

Subscribe to be in the know about new articles and giveaways, like free Bricks Builder templates. The most I will email you is once every two weeks.