Computer

APT: the basic command you must know to use Linux

What is APT

APT, Advanced Packaging Tool, is a program created by the Debian project to allow users to manage your Linux distribution packages. This program is usually included by default in most distributions (such as Ubuntu, Mint or any other derivative of Debian) and it helps us to install, update or delete any program or package from the system. This program was originally designed to work with DEB packages, although today it can also be used to work with other packages, such as RPM.

This command combines the most frequently used commands, such as apt-get and apt-cache, and is designed to be used interactively. Therefore, when we create a script it is recommended to use apt-get (for compatibility), while when we execute a command manually, apt is better and more comfortable.

Main APT Commands

The different tasks that APT allows us to perform are executed through different commands and parameters that we have to execute together with it. Of course, we must bear in mind that most of the commands must be executed with Sudo, or else they won’t work.

install – install new packages

This is undoubtedly the most basic APT command. Thanks to him we will be able to install all kinds of software on our PC from the repositories that we have added in the distribution. To run it, all we have to do is run the following command, followed by the name of the package or program (as it appears in the repository) that we want to install:

sudo apt install programa

Command APT Linux - 2

Furthermore, if we indicate the path to a DEB file instead of a program name, this command will also allow us to install it.

update – update Linux repositories

This is another of the most basic APT commands, one that we must know yes or yes. With it we will be able to update the software lists and repositories. When we run it, the distribution connects to the servers, downloads the software lists, and updates its database with it.

sudo apt update

Command APT Linux - 3

It is recommended to use this command before installing programs or updating the system.

upgrade – upgrade packages and programs

Keeping Linux up to date is very important, as it is the best way to avoid all kinds of problems. Thanks to this command we will be able to use APT to update the distribution. With this command we can search and download the new packages that are available to update our distro.

sudo apt upgrade

Command APT Linux - 4

It is recommended to always use it after “apt update”. Also, if we add the name of a package after “upgrade” we will be able to update only that package.

full-upgrade – upgrade the system without problems

This command is, roughly, an improved version of the previous one. What we achieve with it is to update the system, but by installing, removing or updating all the packages that are necessary for the update to be successful.

sudo apt full-upgrade

We must be careful with this command, not use it lightly.

list -view a list of packages to install or update

With list we will be able to see a list of all the available packages that we have in APT.

sudo apt list

Command APT Linux - 5

This command will show us all the raw information, which can make it difficult to read the information. For this reason, it is recommended to use the “grep” parameter to filter by the specific package that we want to find.

sudo apt list | grep paquete

We can even use it to see only the packages we have installed with:

sudo apt list --installed

And even the ones that are available to update with:

sudo apt list --upgradeable

search – search packages

This command allows us to search for packages in the repositories. It is very useful if, for example, we are looking for a specific program to install but we do not know its name. We can launch it like this:

sudo apt search paquete

Command APT Linux - 6

As we can see, the command will show us the name of the package that matches the description, and from there we can use “apt install” to install it.

show – view the details of a package

The “show” command will allow us to see the details of a specific package. It is, roughly, the easiest way to see the description of said package:

sudo apt show paquete

Command APT Linux - 7

reinstall – reinstall a package

It allows us to reinstall a complete package from scratch, perfect when the package is not working or is giving problems.

sudo apt reinstall paquete

remove – remove installed packages

With this command we will be able to eliminate any package or program that is installed in our Linux distro. We can launch it in the following way:

sudo apt remove paquete

This command only deletes the package, but does not do anything with the settings or the rest of the data that have been left over from the package. To do this, then we must use purge.

purge – remove packages and clean traces

Purge is the advanced version of remove. In addition to removing a package or a program that we have installed on our Linux distro, with it we will be able to automatically remove all traces and all residual elements that remain from the PC.

sudo apt purge paquete

autoremove – remove unused dependencies

When we install a program, it can install dependencies (other packages) necessary to function. However, by removing them, we are leaving these dependencies in the system, packages that take up space and are not needed at all.

Executing the following command we make sure that these dependencies disappear from the PC.

sudo apt autoremove

edit-sources – view and edit the list of software sources

Surely more than once we have heard of Linux repositories. These are, broadly speaking, the sources from which the software that we install on the PC is extracted. We can add our own fonts, or delete the ones we no longer want to use. And thanks to APT, we will not have to memorize the path where these sources are saved, but with this command we will be able to open them directly.

sudo apt edit-sources

Command APT Linux - 8

satisfy – satisfy dependencies

Dependencies for a particular package on your system may have been corrupted for various reasons. Thanks to APT we will be able to analyze this program, review its dependencies and make sure that they are all correct. And if not, repair them so that the program can work again.

sudo apt satisfy programa

Related Articles