This command combines the most frequently used commands, such as apt-get and apt-cache, and is designed to be used interactively. For this reason, when we create a script it is recommended to use apt-get (for compatibility), while when we execute a command manually it is better and more convenient to apt.
We must also bear in mind that what is known as APT repositories in Linux systems actually tells us about a collection of deb packages that can be used without any problem in many of the tools that are part of this solution. In the event that you have made the decision to use that program that we are talking about, thanks to these repositories that we are talking about, we will have the possibility of carrying out all kinds of tasks in Linux.
What we want to tell you with all this is that we will have the possibility of carrying out the facility, removing, or upgrading packages that we will use later here. In addition, we must also take into account that this is effective both when talking about individual packages and groups of them.
At the same time, it will also be interesting to know that the package management system we are talking about in these lines, APT, started today in the Debian hello project but is valid for many other Linux distributions. This means that we can benefit from all this both in the aforementioned distro and in all its derivatives, where we can include well-known systems such as Ubuntu and Linux Mint.
Main APT commands
The different tasks that APT allows us to carry out are executed through different commands and parameters that we have to execute together with it. Of course, we must take into account that most of the commands must be executed with SUDOor else they won’t work.
install – install new packages
This is undoubtedly the most basic APT command. Thanks to it we will be able to install all kinds of software on our PC from the repositories that we have added to 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 program
Also, if we indicate the path to a DEB file instead of a program name, this command will allow us to install it as well.
Reinstall – reinstall an entire package
This is another command that will be extremely useful on many occasions when we work on a day-to-day basis with Linux. To give you an idea of what we are talking about, it is responsible for allowing us to reinstall a complete software package from scratch. Today, for example, all of this will be very useful to us in the event that we encounter a problem in the operation of the hello package that we are using at that time.
sudo apt reinstall program
update – update Linux repositories
This is another of the most basic APT commands, one that we must know no matter what. With it we will be able to update the lists of software 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
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 for and download the new packages that are available to update our distro.
sudo apt upgrade
It is recommended to always use it after “apt update”. Also, if we add the name of a package after “upgrade” we can update only that package.
full-upgrade – update the system without problems
This command is, broadly speaking, an improved version of the previous one. What we achieve with it is to update the system, but 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
This command will show us all the raw data, which can make it hard to read the data. 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 package
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 for 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 it but we don’t know its name. We can launch it like this:
sudo apt search package
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 speaking, the easiest way to see the description of said package so that we know exactly what we are dealing with:
sudo apt show package
remove – remove installed packages
With this command we will be able to remove any package or program that is installed on our Linux distro. We can launch it as follows:
sudo apt remove package
This command only deletes the package, but does nothing with the configurations or other data left behind in 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 on the PC. As you can imagine, all this helps us to save disk space and will also help us to safeguard the general operation of the operating system by removing junk.
sudo apt purge package
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.
By running 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 obtained. We can add our own fonts, or delete the ones we no longer want to use. And thanks to APT, we won’t have to memorize the path where these sources are stored, but with this command we can open them directly.
sudo apt edit-sources
satisfy – satisfy dependencies
The dependencies of a particular package on the system may have been corrupted for various reasons. Thanks to APT we will be able to analyze said 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 program