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.
To find packages that match a specific keyword or phrase, use the apt search command.
apt search <phrase>
To display detailed information about a particular package, including its description, version, and dependencies, use apt show.
apt show <package>
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
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
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
To download and install one or more packages, use the apt install command.
apt install <package>...
To uninstall packages while keeping their configuration files, use the apt remove command.
apt remove <package>...
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
To see the dependencies required by a specific package, use the apt depends command.
apt depends <package>...
For a complete removal of a package, including its configuration files, use the apt purge command.
apt purge <package>...
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.