APT Package Management Commands
The Advanced Package Tool (APT) is a powerful command-line utility for managing software packages on Debian-based Linux distributions like Ubuntu. Mastering APT commands is crucial for any Linux user or administrator to efficiently install, update, and maintain their system's software. This guide provides a comprehensive overview of essential APT commands.
Search for Packages
To find packages that match a specific keyword or phrase, use the apt search
command.
apt search <phrase>
Show Package Information
To display detailed information about a particular package, including its description, version, and dependencies, use apt show
.
apt show <package>
Update Package Lists
Before installing or upgrading packages, it's essential to refresh your system's local package index. This command fetches the latest information about available packages from the repositories.
apt update
Upgrade Installed Packages
The apt upgrade
command downloads and installs the newest versions of all currently installed packages. It will also install new packages if they are required as dependencies for the upgrades.
apt upgrade
Perform a Full System Upgrade
For a more comprehensive upgrade that can also remove obsolete packages and install new ones to resolve dependency changes, use apt dist-upgrade
. Use this command with caution, as it can make significant changes to your system.
apt dist-upgrade
To perform a full system upgrade, it's common practice to first update the package lists and then upgrade:
apt update && apt upgrade
Install Packages
To download and install one or more packages, use the apt install
command.
apt install <package>...
Remove Packages
To uninstall packages while keeping their configuration files, use the apt remove
command.
apt remove <package>...
Remove Unused Packages
After removing packages, some dependencies might be left behind that are no longer needed by any installed software. The apt autoremove
command cleans these up automatically.
apt autoremove
List Package Dependencies
To see the dependencies required by a specific package, use the apt depends
command.
apt depends <package>...
Purge Packages
For a complete removal of a package, including its configuration files, use the apt purge
command.
apt purge <package>...
List Installed Packages
To view a list of all packages currently installed on your system, use apt list --installed
.
apt list --installed
Understanding and utilizing these APT commands will significantly enhance your ability to manage software on your Linux system, ensuring it remains up-to-date and free from unnecessary packages.