Using APT-GET And APT On Debian/Ubuntu/Linux Mint

Today I will be showing you how to manage your systems packages on Debian based systems including Ubuntu and Linux Mint using the apt/apt-get package manager.

Some of the great features that come with the package manager are automatically install software through the command line, automatically install dependencies required by the software, automatically update all of your systems packages, etc.

Updating Available Software/Package Information

While the following command looks like it may update your packages or software, it actually updates the list of available packages as-well as what the latest versions are. This is something that you should always run before actually updating packages as new packages or dependencies could be available.

Below is an example of how you can update your packages, either one will work.

sudo apt-get update
sudo apt update

Updating Software/Packages

With apt as-well as apt-get you can update either all of your packages at the same time or just a specific package. Here are a few examples of updating packages, be sure to update your available packages list prior to doing any of these.

Updating All Software/Packages

You can update all of your software or packages using either apt-get or just apt.

sudo apt-get upgrade
sudo apt upgrade

Updating Specific Software/Package

Unlike when updating all of your software or packages at the same time, you can only update a specific package using apt-get. This will also update any dependencies, however anything that the package you are updating doesn’t rely on will not be updated.

sudo apt-get upgrade packagename

Installing Software/Packages

Installing software is pretty simple using the apt and apt-get utilities. Sometimes software will not be available in the default repositories, for example notepadqq. In that case you may be required to add a repository. To install a package with its dependencies, simply run one of the following commands.

sudo apt-get install packagename
sudo apt install packagename

Removing Software/Packages

Removing software is just as easy as installing them. When removing packages you have some options though that you should consider depending on what you are removing. For example if you are having trouble with a service after changing the default configuration files you may want to purge the packages (remove the packages and configuration files), if you don’t purge the packages then the configuration files will remain on your system. Here are a couple of quick examples below.

sudo apt-get purge apache2
sudo apt-get remove expect
sudo apt remove expect

If you would like to automatically remove any unused packages from your system (for example an older kernel that you no longer require), you can do so with autoremove. Here are the commands below.

sudo apt-get autoremove
sudo apt autoremove

Searching Available Packages

If you need to find a package you are searching for you can do this as-well, for example if you are used to Red Hat and want to install Apache (httpd is the package name in RHEL), then you can run the following with the word “apache” to find the correct package name.

sudo apt search packagename

Upgrading Distribution To Next Release

Upgrading releases can be important especially when it’s an LTS release that is no longer supported, an example would be upgrading Ubuntu Server 16 to Ubuntu Server 17. You can upgrade your entire system to the latest release with a single command. Note: THIS IS IRREVERSIBLE. So before upgrading, make sure that your requirements are still available in the latest release. Here is the upgrade command.

sudo apt-get dist-upgrade

Removing Cached Package Files

Whenever you install or update a package the files are downloaded and cached, you can remove these to free up some disk space if you like. This means that if you re-install them though, you will have to re-download the packages.

sudo apt-get clean # Erase downloaded archive files
sudo apt-get autoclean # Erase old downloaded archive files

I hope you liked this guide on using apt and apt-get. Please don’t forget to like/comment/share, especially if I missed something important! Thanks!

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *