apt-get is a package management command-line tool used in Debian and Ubuntu-based systems to handle software packages. This cheat sheet covers essential apt-get commands for installing, updating, and managing packages.
Introduction:
apt-get simplifies the process of installing, updating, and managing software packages on Debian and Ubuntu-based systems. It is a front-end to the Advanced Package Tool (APT).
Basic Commands:
Command
Description
sudo apt-get update
Update the package lists for available packages.
sudo apt-get upgrade
Upgrade all installed packages to the latest versions.
sudo apt-get dist-upgrade
Upgrade the distribution, including installing or removing packages if necessary.
sudo apt-get install [package]
Install a specific package.
sudo apt-get remove [package]
Remove a specific package.
sudo apt-get purge [package]
Remove a package along with its configuration files.
sudo apt-get autoremove
Remove packages that were automatically installed and are no longer needed.
sudo apt-get clean
Remove downloaded package files from the local cache.
sudo apt-get autoclean
Remove old downloaded package files from the local cache.
Search and Information:
Command
Description
apt-get search [keyword]
Search for packages containing the specified keyword.
apt-get show [package]
Display detailed information about a package.
apt-get list
List all available packages.
Repository Management:
Command
Description
sudo apt-get add-apt-repository [repository]
Add a new repository to the system.
sudo apt-get remove-apt-repository [repository]
Remove an existing repository from the system.
sudo apt-get update
Update the package lists after adding or removing repositories.
Dependency Resolution:
Command
Description
sudo apt-get -f install
Fix broken dependencies.
sudo apt-get build-dep [package]
Install the build dependencies for a source package.
Miscellaneous:
Command
Description
sudo apt-get check
Check for broken dependencies.
sudo apt-get changelog [package]
Display the changelog for a package.
sudo apt-get download [package]
Download the .deb file for a package without installing it.
sudo apt-get --purge autoremove
Remove all packages that were automatically installed and are no longer needed.
sudo apt-get dist-upgrade
Perform a full system upgrade, including resolving dependencies.
Conclusion
apt-get is a powerful package management tool for Debian and Ubuntu-based systems. This cheat sheet covers essential commands for updating, upgrading, installing, and managing packages, as well as searching for information and managing repositories. Whether you are a system administrator or an Ubuntu user, mastering these commands will help you efficiently manage software on your system.