How to Use APT Package Manager in Ubuntu
As a free and open-source Linux distribution based on Debian, Ubuntu comes with a comprehensive package management system. To install, upgrade, configure, and remove software, management tools are required to manage the packages. The Advanced Packaging Tool (APT) is one of them. In this article, you will learn How to Use APT Package Manager in Ubuntu. As a Linux/Unix administrator, you should be familiar with using package management. The practical examples of this tutorial will help you be an expert in using APT as a package manager and configure available packages of the default repository of Ubuntu.
In order to learn how to use APT in Ubuntu Package Manager, you will need to have an already running virtual private server (VPS) with the Ubuntu operating system installed.
Reasons to Use a Package Management Tool
There are several tools for interacting with Ubuntu’s package management system such as a graphical interface and command-line utilities. System administrators use Package management tools to download and install software, Keep track of updates and upgrades for all installed software, and compile software from source. Using a package management tool, also allows them to manage dependencies, maintain information about installed applications, and many other things.
The OperaVPS blog readers remember Manjaro Package Manager. Stay with us to see what the APT package manager is and how you can use it on your Ubuntu Linux.
Tutorial Use APT Package Manager in Ubuntu [With Examples]
As a powerful command-line tool, the apt command interacts with Ubuntu’s Advanced Packaging Tool (APT) to conduct tasks including installing new software packages, updating current software packages, updating the package list index, and even upgrading the complete Ubuntu system. The package management tools offer your Ubuntu computer access to a well-organized database of more than 60,000 software packages as well as the ability to resolve dependencies and search for software updates.
Previously, you have learned How to install Package on Debian. Let’s go through this guide and see how APT manager helps Ubuntu administrators to install dependencies along with the installation of considered packages automatically.
1. Update & Upgrade Ubuntu Packages Using APT Package Manager
As always, we start with updating the command. To get the latest updates and view a list of packages from the repository include on your system, use the following command which allows you to update all available repositories to new versions of packages and their dependencies.
$ sudo apt update
The output displays all the packages you can upgrade. To view the list of the packages, type:
$ sudo apt list --upgradable
Then, run the following command to install new versions of them on your Ubuntu Linux system.
$ sudo apt upgrade -y
In order to upgrade your desired package instead of upgrading all packages, use the command below:
$ sudo apt --only-upgrade [package-name]
Keep in mind to replace your considered package name with [package-name] in the above command.
2. View all Packages list Using Package Manager
On your Ubuntu system, you can list down all the available packages by running the following command:
$ sudo apt list
Again, it is possible to view only installed packages. To do this, run:
$ sudo apt list --installed
3. Search the package Using APT Package Manager
If you want to check if your considered package is available in the repository of Ubuntu to avoid reinstalling it, this part is what you need. Here, we want to install a package of nano text editor. So, firstly we run the following command to search in the repository.
$ sudo apt search nano
4. View packages details Using APT Package Manager
We can also display the details of the package including its version, dependencies, and installed size by using the APT package manager, for example, we have displayed the details of the nano text editor:
$ sudo apt show nano
5. Install packages Using APT Package Manager
Using APT Package Manager in Ubuntu allows you to install any package available in the default repository on it. For example, we use the following command to install nano package manager:
$ sudo apt install nano -y
6. Remove packages Using the APT Package Manager
To use APT Package Manager in Ubuntu, you need to learn all the commands of this article to be able to run them in related situations. Using the command below helps you to remove the installed packages from Ubuntu. For example, to remove the installed nano package, type:
$ sudo apt remove nano -y
Since running the above command will not remove the configuration files of nano, you can use the command below to remove them.
$ sudo apt purge nano -y
7. Add/Remove a Repository Using APT Package Manager
One of the things you will learn after reviewing How to Use APT Package Manager in Ubuntu is to add repositories in Ubuntu.
For example, you can add the PPA repository of your desired package by running the following command:
$ sudo add-apt-repository ppa:thomas-schiex/blender
Also, it is possible to remove the added PPA repository anytime you decide. To do this, just run:
$ sudo add-apt-repository --remove ppa:thomas-schiex/blender
8. Getting Help to Use APT on Ubuntu
To list all the options with its description, use the following command and find Help when you are using the APT package manager.
$ apt help
9. Install .Deb Package Using APT Package Manager
Use the following command to install a .deb file with the filename.
$ sudo apt deb atom-amd64.deb
10. Clean old Repository Using APT Package Manager
To remove/clean all old local repositories of the downloaded package files, run one of the following commands.
$ sudo apt autoclean
or
$ sudo apt clean
11. Remove/Delete Unused Packages Using APT Package Manager
A new package’s dependencies are installed together with it when you install it on your system, and they make use of system libraries with other packages. The dependencies of that particular package will still be present in the system after removal. So, to get rid of them, type:
$ sudo apt autoremove
12. Verify the Version of the Installed Package Using APT Package Manager
To view the installed package version, run:
$ sudo apt version chrome
13. Search for Broken Dependencies of a Package Using APT Package Manager
You might have faced the error of broken package dependencies. So, use the command below to check whether you have such an issue or not. To do this, type:
$ sudo apt check chrome
14. List all Dependencies of a Package
To check the dependencies of your considered package, use the command below and display all its information.
$ sudo apt depends chrome
15. Locate the Installed packages
Run the following command to find the location of your desired package easily. It also lists all the files that are contained in that package.
$ sudo apt content chrome
FAQ
I need a package manager to not work with the command-line. What is your suggestion?
Synaptic is a good option as a low-level GUI if you are a fairly experienced user but are not comfortable with command-line utilities.
The apt-get requires the exact package name. Which package manager to use when we do not remember the app name?
The Software Center GUI is extremely advanced and user-friendly. If you're not precisely sure what app you want, the software is thoughtfully classified to make it easy for you to find what you need.
Conclusion
In this article, you learned How to Use APT Package Manager in Ubuntu. Learning the mentioned 15 commands in this guide helps you to know how to use APT in Ubuntu and reach out to your different targets. Using APT package manager allows you to manage all the installed packages in Ubuntu and install, update, and remove them.
If you encounter any problems, please do not hesitate to contact us. Our technical support team will try their best to solve your problems.