When I first started on my Linux journey, the prospect of having to use the command line preoccupied me somewhat. Because my first Linux distribution was Debian (yeah, I know), I ended up delving headfirst into command-line procedures. I learned to rely on the Terminal before even thinking of using GUI software. Of all the commands one can learn, I consider the APT commands part of the Linux command-line fundamentals and a great place to start. 

Nowadays, and especially with user-friendly distributions such as Ubuntu, Linux Mint or Elementary OS, it is easy to execute core commands such as updating your software, installing applications and removing packages through the Software Manager and Software Updater/Update Manager.

However, it is a Linux best practice to know how to execute these basics commands from the Terminal. The APT package manager, being the standard manager included in the vast majority of Linux distributions, is easy to learn and execute and makes using these commands a breeze.

Why you should use APT or the Software Manager

Whether you end up using a Software Manager or APT commands executed through the Terminal, the result is the same. In all cases, always use one of these two options to install or remove packages. By using a package manager such as APT or a software manager, you make sure that:

  • You are installing applications compatible with your current operating system and its desktop environment.
  • The package manager will install your application alongside all its required dependencies (if needed).
  • Your applications are automatically updated whenever you update your OS.
  • All the dependencies installed alongside an app that is no longer existent can be automatically removed.
  • You will not lose your installed packages when upgrading your operating system.

Sometimes, fetching a package from the Terminal or Software Manager isn’t possible. It can be the case when the application isn’t present within the package manager repositories. In that case, follow the application’s installation instructions to add the package repository to your Linux distribution. By doing so, you avoid having to compile .tar (or tar.gz, .tar.xz, .tar.bz2) files manually and get all the advantages that installing from APT or the Software Manager provides. Even though much better than merely manually compiling packages, it is still advisable to use this method with parsimony. If you find yourself continually adding specific repositories, consider finding app alternatives in your Software Manager. Taking a look at the Snap Store can be of tremendous help when looking for applications that are readily available on your Linux distribution.

What about .deb files?

You can still install applications that aren’t found on your OS Software Manager or installed by adding a specific repository. It is the case with .deb files, which are usually files used by applications that aren’t open-source. Those using Debian-based distributions, such as Debian, Ubuntu, Linux Mint or Linux Lite, can use APT commands to install apps from files that use this extension.

NOTE FOR DEBIAN USERS: Some applications are only available on specific Debian releases, such as Debian Unstable (aka Debian Bullseye as of October 2019). To fetch packages meant for the unstable version on a machine running the stable Debian 10 distribution, you will have to add repositories to your primary sources.list. You can find instructions to do so HERE. If you are using Debian Buster and find yourself regularly adding packages from the unstable or testing repo, take a look at the different releases Debian offers. You might want to switch to a version that better suits your needs.

As a final note, it is always a good idea to execute the “apt update” command whenever you are done installing or removing an application.

The Command-Line Basics

Note that for each command, the use of “$” indicates a command that can be executed from any user, whereas “#” requires admin (root) privileges. To run a command as root, enter “su” then press Enter. Type your password, then press Enter again. You will now execute all your following commands from root. Alternatively, you can run single commands with admin privilege by adding “sudo” before typing the command as usual.

Updating your operating system

Regularly updating your operating system is extremely important. By executing this APT command, all the packages (eg, applications and their dependencies) found within your distribution will be verified and updated as needed.

# apt update

Screenshot of the APT command used to Update a Linux distribution

Using APT commands to Instal an application

If there is a single Terminal command you want to remember, it is how to install an application using the APT package manager.

# apt install [NameOfThePackage]


# apt install digikam

Screenshot of the APT command used to install a package

However, be sure to double-check whether your application’s package name is the same as the one used for the app itself. Often, the package associated with an application will use a different name. Amongst the many APT commands available, there is one that allows you to search for all possible packages related to any given keyword.

Ex: I want to install KDE Partition Manager.

$ apt search kde partition manager

Screenshot of the APT command used to search for packages

As you can see, more than one result appears (and it isn’t rare to find a dozen different results or more). You will also notice that even though the application is named KDE Partition Manager, its main installation package is called “partitionmanager.” It is thus using this name that I will install the app by typing “sudo apt install partitionmanager.”

Removing an application

To remove an application – as well as all its dependencies -, enter the following:

# apt remove [NameOfThePackage]

Screenshot of the APT command used to remove a package
Screenshot of the APT command used to remove a package

And do not forget to update your system after, for good measure.

Upgrading your operating system

Whenever you wish to install a major component on your distribution, it is advisable to check whether your OS kernel and core files are up-to-date. Upgrading your OS is also part of routine maintenance and something you should do regularly.

# apt upgrade

Screenshot of the APT command used to Upgrade a Linux distribution

Doing a clean-up of your system (removing unused packages)

Sometimes when updating or upgrading your distribution, you will see a message within the Terminal indicating that you can remove some packages. Usually, executing the auto-remove command is safe and is considered the most natural way of removing unneeded packages. However, there are instances where using auto-remove might “break” some of your applications. This is the case when specific dependencies have been manually added to make the app compatible with your system. It is also the reason why it is not recommended to add applications or dependencies manually. To do a package clean-up of your OS, execute the following APT command.

# apt autoremove

Screenshot of the APT command used to autoremove all unnecessary packages

Installing an application downloaded as a .deb file

Here we will use the Google Chrome .deb file as an example (which you can find by clicking here). Once you have downloaded the .deb file, take note of its location (usually the Downloads folder). If your .deb file has a complicated name, it might be worth copying or modifying it beforehand to make sure that you find no typo when executing the command.

# dpkg -i [PathToYourDebFile+NameOfYourDebFile]


Screenshot of the location of a .deb file

I first have to find the location of my Google Chrome .deb file. Knowing that it is in my Downloads folder, I can now install it.

# dpkg -i /home/lari/Downloads/google-chrome-stable_current_amd64.deb

Screenshot of the dpkg command used to install a .deb file
Screenshot of the dpkg command used to install a .deb file

Followed by:

# apt install -f

Screenshot of the command used to install a .deb file

Voilà! You’re all set to continue on your Linux journey.

Owner and content creator behind ITgirl.tech. Geeky girl and blogger based in Montreal, Canada. Chocolate and nature lover (in that order). View all posts by Larryssa →

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.