The apt-get (Advanced Package Tool) command is an advanced package manager for Linux from the Debian family, such as Debian itself, Ubuntu, Kali and Mint.
It can use local or remote files to install or update packages. This way it is possible to update the entire Debian system via ftp or http. This manager also maintains information about packages and their dependencies.
Because of its ease of operation, apt-get is the preferred To Install method for manipulating packages. This utility offers dozens of options configured in the /etc/apt/apt.conf file.
The /etc/apt/sources.list file contains the locations where apt-get will find the packages, the verified distribution (stable, testing, unstable, Woody, Sarge) and the section that will be copied (main, non-free, contrib, non-US).
Below is a simple example of the /etc/apt/sources.list file with an explanation of the sections:
deb http://www.debian.org/debian stable main contrib non-free deb http://nonus.debian.org/debian-non-US stable non-US
In the /etc/apt/apt.conf file we can specify options that will modify the behavior of the apt-get program when manipulating packages.
apt-get uses a list of packages to check whether existing packages on the system need to be updated or not. The newest list of packages is copied using the apt-get update command.
Apt-get is very useful because the administrator does not have to manually copy the package he wishes to install from the Internet, much less deal with the dependencies, as long as what he needs is in the repositories indicated on sources.list.
The most common options for this utility are:
The most common commands are:
Examples:
# apt-get install airsnort
Install the airsnort.x.y.deb package. This command accepts installing more than one package by separating names by spaces. You only need to specify the package name, without version (X), revision (Y), and suffix (.deb).
If necessary, apt-get will automatically install the dependencies necessary for the correct functioning of a package.
Apt-get is also widely used to update all system packages, with the update command to update the databases with the new packages and then the upgrade command to make the updates:
# apt-get update # apt-get upgrade
apt-get can update your entire distribution in a smart and secure way. It reads the list of packages available on the remote server, checks which are installed and their versions, and updates the old packages.
# apt-get dist-update
Since 2014, distributions based on Debian have included an improvement to apt-get, which combined and improved several tools that made up the apt-get package. This new vitamin version of apt-get became known only as apt.
Apt does everything that apt-get does. So, to install, update, and remove packages on a daily basis, it doesn’t matter if you use apt or apt-get.
To install one or more packages with apt:
# apt install package1 package2
To remove one or more packages:
# apt remove package1 package2
From time to time, one or more files that make up an installed package may be damaged or removed by accident. Thus, the easiest way to recover these files is to reinstall the affected package.
Unfortunately, the packaging system may notice that the package is already installed and will refuse to reinstall it. To circumvent the system and force a reinstallation of a package, apt’s –reinstall option should be used.
In the example the httpd package is reinstalled:
# apt --reinstall install httpd
To update the installed packages with the latest version available in the repository, use the update and then upgrade commands.
# apt update
The update downloads the updated package list.
To effectively upgrade:
# apt upgrade
The apt package manager keeps a copy of each downloaded .deb file in the /var/cache/apt/archives/ directory.
Over time, this directory can take up a lot of disk space. To clear the apt cache, use the clean command:
# apt clean
To switch from one major version of Debian or Ubuntu to the next, you need to use the apt full-upgrade command. With this instruction, apt will complete the update, removing some obsolete packages and installing new dependencies:
# apt full-upgrade
Always make a backup before updating the system using a full-upgrade. If you want to see how to update your Ubuntu, read this post.
If you use Debian or Ubuntu, it is essential to learn the apt command to manage packages on these systems.
The sudo command on Linux executes a given command as if it were another user.…
The ss command on Linux is extremely useful for investigating sockets, providing various information about…
Free Linux command shows the amount of total memory in use and available, as well…
The shell has structures for testing conditions and executing certain program sequences several times (loop),…
The /etc/fstab file stores the configuration of which devices should be mounted and what is…
The Netcat Command in Linux or nc is a utility used to do “almost anything”…
This website uses cookies.