What's apt-get?
apt-get is a command line tool that forms part of the APT (Advanced Package Tool) package management system in Debian-based distributions such as Ubuntu and Linux Mint. Its main function is to interact with software repositories to search, download, install, update and remove packages automatically, solving dependencies and maintaining the system consistent.
How the package repository works
Before using apt-get, the system maintains an internal list of available packages in the repositories set up in/etc/apt/sources.listand in the files of/etc/apt/sources.list.d/. This list is updated by the implementation ofapt-get update, which download the latest information from the indicated servers.
Update the package list
The first step recommended before any installation or update is to refresh the package index:
sudo apt-get update
This command consults each repository and downloads the filesPackages.gzcontaining metadata such as versions, dependencies and descriptions. If there are changes in the servers, the local list is updated; otherwise, nothing new is downloaded.
Install a package
To install a software, the syntax is used:
sudo apt-get install name _ of the _ package
apt-get will search the package in the updated list, download the file.debcorresponding and all its units, then proceed to the configuration. For example, to install the text editorvim:
sudo apt-get install vim
During the process, a summary of the packages to be installed is shown and confirmation is requested before continuing.
Update installed packages
To apply the latest versions of all the packages already installed, it runs:
sudo apt-get upgrade
This command only updates packages without removing any or changing versions of dependencies that involve removing packages. If a more in-depth update is needed that may include unit changes, it is used:
sudo apt-get dist-upgrade
dist-upgrade intelligently handles the unit changes and can install or delete packages to complete the update.
Remove Packages
When a software is no longer necessary, it can be uninstalled in two ways:
sudo apt-get remove nombre_del_paqueteremoves the binary but leaves the configuration files in the system, allowing for quick reinstallation without losing settings.sudo apt-get purge nombre_del_paqueteremoves both the binary and the configuration files, leaving the system completely clean with respect to that package.
Search packages
If the exact name of the package is not known, apt-get offers a simple search:
apt-get search word _ key
This command runs through the list of available packages and shows those whose name or description matches the keyword. For more details about a specific package, you can use:
apt-get show name _ of _ package
which shows the version, dependencies, size and a complete description.
Clean the cache
apt-get stores the packages downloaded in/var/cache/apt/archives/. Over time, this cache can occupy a lot of disk space. To release it, the following are used:
sudo apt-get clean
that removes all .deb files stored, or:
sudo apt-get autoclean
that only erases packages that can no longer be downloaded (obsolete versions).
Tips and good practices
- Always run
apt-get updatebefore installing or updating. - Check the output of the commands for warnings on retained packages or conflicts.
- Use
apt-get -s install paquetefor a simulation showing what will be installed without actual changes. - In production systems, consider the use of
apt-get upgrade --with-new-pkgsto allow the installation of new units where necessary. - Keep a backup of the list of packages installed with
dpkg --get-selections > paquetes.txtto facilitate replication on another team.
With this knowledge, apt-get becomes a powerful and reliable tool to manage the software in any Debian-based distribution, allowing the system to be kept up to date, safe and adapted to the user's needs.


