What Is the APT Package Manager: Why and How To Use It

What Is the APT Package Manager: Why and How To Use It


Do you want to stay up-to-date with the latest software, but an old package manager and its complex maintenance are not letting you do so? Well, it happens to most of us. Just having packages installed and leaving them alone are not enough to maintain those packages. You should get a command-line tool and all software listed in one place, which will allow you to simplify the process of managing software on the system. In Linux, since application software comes in packages, to manage those packages, package managers are used. The default package management system is the APT (Advanced Packaging Tool) package manager.


What is the APT package manager? 

The APT package manager is an advanced package management tool. Using its core libraries, it facilitates the process of installation and uninstallation of Linux software packages. It is also used to maintain and upgrade installed packages. The APT package manager depends on repositories. To make the APT package manager work without a hitch, the core libraries are essential. All the data should be kept under one roof to have easy accessibility.


Talking about listing the software all in one place, you need a package repository that hosts all popular packages including Java, APT, YUM, Python, RubyGem, Node, and more. You need a package repository service like packagecloud that can help you manage all of the packages in your systems. Packagecloud works seamlessly to manage your artifacts in the system. So, having it and getting it embedded in the system makes the work of software management easier.


Now, let’s imagine that you have all the package artifacts in your repositories. With a strong command-line tool, you can manage all of those software packages in real-time and keep them updated. To enable this, you need to use the APT package manager tool.


In this post, we’ll show you why you should use the APT package manager and share guides on how to use it. In addition, the article will show you several popular APT utilities, which will help you to understand how to use the APT package manager.


Why use the APT package manager?

The APT package manager is free software that has handy features for Linux users, which supervises all the maintenance and grunt work. From installation and uninstallation to upgrading or removing the software on Ubuntu, Debian, and similar Linux distributions, it can help you do it all. Making the most use of the software at your disposal, you can use it in the terminal connection (SSH) to make sure the data transferred between the host and the client is encrypted. You can use cron scheduling in the system administration scripts to notify administrators about the pending updates.


In addition to these advantages, there are many more benefits you get from the APT package manager. For instance, there are advanced installation functions and automotive configurations. With these, you can set up sources and apply them to other features and make the operations easier. Not only does the APT package manager solve the issues of installation and removal of the software, but it also keeps your repositories clean and presentable. All the packages and software data will be stratified.


Once the APT package manager is used, upgrading your packages will become seamless. Every time there are installations, removals, or needed upgrades, the administrator will be informed. Obsolete files will be removed automatically, and other subsequent operations will be executed sequentially.


How to use the APT package manager

Since all the application software comes in packages and the packages need to be externally stored in a repository, the repo has to have the qualities to be a good host to all the essential packages. Thus, you need to make sure the packages are handled optimally by a unified and developer-friendly interface. This is true for packagecloud, which offers these functions and more services as well.


Let’s learn how to use the basic features of the APT package manager and a few other options to simplify the process.


NOTE: To install and manage packages, previously you had to use the apt-get command, while the apt-cache command had to be used for exploring packages on Ubuntu and Debian. However, the apt command has since been introduced to consolidate both apt-get and apt-cache commands to make use of the above user-friendly and uncomplicated.


Now, Debian and Ubuntu suggest you use the apt command where possible. Thus, consecutively in this guide, we will make use of the apt command where possible.


Install, Uninstall, Reinstall, and Autoremove 

Single package installation


Try the following command to install a package:

$ sudo apt install <Package_Name>


Multiple packages installation 

To install multiple packages, specify the following command:

$ sudo apt install <1st Package> <2nd Package>


To install the package with APT, you do not have to write down a complete name. You can just add a phrase or a portion of the file name. For instance, if you want to install Nmap, you can write Nmap for the package name without the package version number.


It is unlikely that you will experience any failures during install due to missing dependencies. This is also a strength of APT.


Uninstalling Packages 

To uninstall a package, frame the code:

$ sudo apt remove <Package_Name>


NOTE: The remove commands swipe out the package binaries but keep the data files and package configurations.


Uninstall with purge 

When you want to uninstall a package with its configuration and data files, try:

$ sudo apt purge <Package_Name>


Reinstalling packages 

To reinstall a package, you can run:

$ sudo apt reinstall <Package_Name>

Auto-remove a package 

The dependencies of the packages that are removed stay in the system. You remove the unused packages by:

$ sudo apt autoremove


Furthermore, if you want to remove a specific package, add the name of the package after autoremove.

$ sudo apt autoremove <Package_Name>


Update, Upgrade, and Dist-upgrade 

Update package index 

The update command is to update the indices of packages. It re-synchronizes all files from the package index files. The repos of available packages are located in the /etc/apt/sources.list.d directory or the /etc/apt/sources.list file. To update the repository and the local package index, execute:

$ sudo apt update


Upgrade installed packages 

To update the existing packages to the latest versions, try:

$ sudo apt upgrade


Specific package upgrade 

To upgrade any specific package, execute:

$ sudo apt upgrade <Package_Name>


Dist-upgrade for full dependency upgrade 

The full-upgrade, or dist-upgrade, will perform extra functions to the upgrade. Along with upgrading the packages, it will also upgrade the dependencies. This full-upgrade is a smart option for conflict resolution. However, be cautious since it can remove a few dependency packages. You must review the prompts it shows before upgrading the entire system.

$ sudo apt full-upgrade


Sources set-up 

APT depends on the repositories to find and manage dependencies. Although the default locations are in the local drive, you can specify different locations, for example, CD-ROM or other network location.


In /etc/apt/sources.list, you can define a list of repositories you want to use. To modify source.list, a graphical user interface can help you edit it easily with apt-setup.


To add more to the repositories, you can opt to add storage media such as CD, USB, hard disks, etc. using the apt-cdrom command or by adding file:/ URL to the file source list.


Other useful features 

There are more useful tasks you can perform using these APT features.


APT pinning

By using the APT pinning feature, you ask APT to choose a particular version that’s from a different repository. The administrator can prevent a package from upgrading to the version that might conflict with others or that applies unwanted changes. This is done by changing the pins in APT’s preference file, /etc/apt/preferences.


Use the package’s specific version 

A specific version of a package can be used if you add the package’s version. The command syntax looks like:

$ sudo apt install <Package_Name> = <Package_Number>


-y/--yes flag


You can use the -y or --yes flag to say yes to all prompts and not to give confirmation to every step during an installation process.


Say yes to all steps with the code:

$ sudo apt install -y <Package_Name>


-s/--simulate flag


If you want to simulate what a particular command can change in your system without actually making those changes, try the following code. In this example, see how APT simulates upgrading the Yarn package:

$ sudo apt upgrade -s yarn



To search for a particular package in APT’s repository, try:

$ sudo apt search <Searching-Term>



List the installed, available, or upgraded packages by:

$ sudo apt list


Retrieve Specific Package Information 

To retrieve complete information on a specific package, run:

$ sudo apt show <Package_Name>


Retrieve Package Version Repository Information 

To check the version of a package and the repository to which it belongs, you can try:

$ sudo apt policy <Package_Name>



We have learned the basics of APT and various powerful features of the package management tool. The article also shares the strengths of APT and the benefits of packagecloud.


If your Linux infrastructure is growing, you will need help from an efficient and more powerful tool. Check out our free trial today for more information.

You might also like other posts...