Different Linux distributions install applications in a pre-compiled package that contain binary files, configuration files and also information about the application’s dependencies.
Package management tools help System/Server Administrators in many ways such as:
- Downloading and installing software
- Compile software from source
- Keeping track of all software installed, their updates and upgrades
- Handling dependencies
- and also keeping other information about installed software and many more
In this guide, we are going to look at 15 examples of how to use the new APT (Advanced Package Tool) on your Ubuntu Linux systems.
APT is a command-line based tool that is used for dealing with packages on an Ubuntu-based Linux system. It presents a command-line interface to the package management on your system.
1. Installing a Package
You can install a package as follows by specifying a single package name or install many packages at once by listing all their names.
$ sudo apt install glances
2. Find Location of Installed Package
The following command will help you to list all the files that are contained in a package called glances (advance Linux monitoring tool).
$ sudo apt content glances
3. Check All Dependencies of a Package
This will help you to display raw information about the dependencies of a particular package that you specify.
$ sudo apt depends glances
4. Search for a Package
The search option searches for the given package name and shows all the matching packages.
$ sudo apt search apache2
5. View Information About Package
This will help you display information about package or packages, run the command below by specifying all the packages that you want to display information about.
$ sudo apt show firefox
6. Verify a Package for any Broken Dependencies
Sometimes during package installation, you may get errors concerning broken package dependencies, to check that you do not have these problems run the command below with the package name.
$ sudo apt check firefox
7. List Recommended Missing Packages of Given Package
$ sudo apt recommends apache2
8. Check Installed Package Version
The ‘version’ option will show you the installed package version.
$ sudo apt version firefox
9. Update System Packages
This will help you to download a list of packages from different repositories included on your system and updates them when there are new versions of packages and their dependencies.
$ sudo apt update
10. Upgrade System
This helps you to install new versions of all the packages on your system.
$ sudo apt upgrade
11. Remove Unused Packages
When you install a new package on your system, it’s dependencies are also installed and they use some system libraries with other packages. The after removing that particular package, it’s dependencies will remain on the system, therefore to remove them use autoremove as follows:
$ sudo apt autoremove
12. Clean Old Repository of Downloaded Packages
The option ‘clean’ or ‘autoclean’ remove all old local repository of downloaded package files.
$ sudo apt autoclean or $ sudo apt clean
13. Remove Packages with its Configuration Files
When you run apt with remove, it only removes the package files but configuration files remain on the system. Therefore to remove a package and it’s configuration files, you will have to use purge.
$ sudo apt purge glances
14. Install .Deb Package
To install a .deb file, run the command below with the filename as an argument as follows:
$ sudo apt deb atom-amd64.deb
15. Find Help While Using APT
The following command will list you all the options with its description on how to use APT on your system.
$ apt help