APT stands for Advanced Packaging Tool, a well-known package manager used by such important and popular distributions as Debian and Ubuntu. Its main function is to manage, thanks to some implementations of libraries built in C++, to handle everything related to the packages inside a GNU/LINUX system. Its main use is to Install and Uninstall these packages. It is a “program” that is mostly used from the terminal, but there are front-ends like Synaptic allowing for ease of use as if it were a much easier tool to use. It was created by the Debian project, so the first implementations were made to handle only.DEB packages but was later ported to handle.RPM packages as well.
It is a “program” that is mostly used from the terminal, but there are front-ends like Synaptic allowing for ease of use as if it were a much easier tool to use. It was created by the Debian project, so the first implementations were made to handle only.DEB packages but was later ported to handle.RPM packages as well.
What is a GNU/LINUX package?
The Debian package system carries a large amount of information associated with each package for ensure that it integrates neatly and easily into the system. The most salient feature is the system of dependencies. The dependency system allows individual programs to make use of shared elements such as function libraries (libraries). APT attempts to resolve dependency issues by providing a set of automated algorithms to help you select the packages to install
A software package is a compressed file and with an established structure that allows to be treated by software management tools to perform operations such as install, compile, delete, purge system configuration files, update. Some packages may work on different distributions if you share a common package, libraries, and similar dependencies.
In other words, a package can contain either a program, libraries or simply instructions to the operating system, all compressed into a single file.
Using APT on Ubuntu 18.04
As mentioned, APT manages packages, mainly.DEB, packages that can do very delicate things, so all commands associated with APT must be made with super user privileges.
0.- Basic use of the command
A great way to learn how to use a command is to show your help from the terminal:
In it we can see a list of most used options as well as a detailed description of the command itself.
Another option is to use man. Man allows us to show a guide in the terminal to use command.
1.- Refreshing package repositories
Packages are stored in a common source called repositories. These repositories are the source of where our operating system packages are going to be installed. Then we must get the updated package list in order to have the package available for installation.
sudo apt update
2.-Upgrading installed packages
When the repository cache is updated, we can see if we have packages to update. As we have said, these packages can be whole programs or libraries.
sudo apt upgrade
3.- Installing a package
We got to the good stuff, installing a package is simple but we need to know its exact name.
sudo apt install package_name
Also in a single instruction we can install several packages.
sudo apt install package1_name package2_name
As an example, I will proceed to install a chess game called Chessx.
sudo apt install chessx
4.-Uninstalling a package
Once you have installed a package, you have the option to uninstall it:
sudo apt remove package_name
In this case, i will remove the chessx package:
sudo apt remove chessx
Additionally we can uninstall several packages in a single instruction:
sudo apt remove package1_name package2_name . . . . .
5.- Remove unnecessary packages
There is also an APT option that allows us to remove all those unnecessary packages that we have in the system. These are usually dependencies that are no longer required.
sudo apt autoremove
6.- Search for a package
Thanks to APT we can search for a specific package within the repositories. Or packages that contain in their description the word we are looking for.
sudo apt search package_name
In my case
sudo apt search netbeans
We’ll get the list of packages related to Netbeans
7.-Getting information about a specific package:
Another great utility of APT is to display information from a package:
sudo apt show package_name
sudo apt show netbeans
8.-Knowing the dependencies of a package
To know the dependencies of a specific package, we can do it with the following command:
sudo apt depends package_name
In this case:
sudo apt depends netbeans
9.- Download the source files of a package
Also APT offers us the possibility to download the source files of a package.
sudo apt source package_name
sudo apt source nano
10.- Clean the downloaded and installed packages:
Over time we download and install many packages, but once installed we can remove the downloaded files and save disk space.
sudo apt clean
11.- List the contents of a package:
With the following instruction we can list the contents of a package.
sudo apt list package_name
In this case:
sudo apt list geany
12.- Show installed packages
Many times it is useful to know the installed packages, for that we write
sudo apt-cache pkgnames
and many more!!
We can conclude that, APT is a veteran among package managers and its use by the terminal is quite simple. However, we can count on graphic tools to manage packages being Synaptic the most popular and lightest.
Using the terminal may be difficult at first, but after a while you may find that it is an efficient and practical tool. And the best way to take advantage of APT’s flexibility is by using the terminal.
Please share this article through social networks and spread the word.