APT-GET Cheatsheet
#
apt-get
is a command-line tool for handling packages on Debian-based Linux distributions. It simplifies package management tasks such as installation, removal, and updates.
Basic Commands
#
Command/Option | Example | Description |
---|
apt-get install <package> | apt-get install nginx | Install a package |
apt-get remove <package> | apt-get remove nginx | Remove a package |
apt-get purge <package> | apt-get purge nginx | Remove a package and its configuration files |
apt-get update | apt-get update | Update the list of available packages and their versions |
apt-get upgrade | apt-get upgrade | Upgrade all installed packages to the latest versions |
apt-get dist-upgrade | apt-get dist-upgrade | Upgrade all installed packages and handle dependencies intelligently |
Package Search and Info
#
Command/Option | Example | Description |
---|
apt-cache search <package> | apt-cache search nginx | Search for packages by name or description |
apt-cache show <package> | apt-cache show nginx | Display detailed information about a package |
apt-cache policy <package> | apt-cache policy nginx | Display version and repository information about a package |
Repository Management
#
Command/Option | Example | Description |
---|
add-apt-repository <repo> | add-apt-repository ppa:nginx/stable | Add a new repository |
apt-get update | apt-get update | Update package lists after adding a new repository |
apt-get remove --purge <package> | apt-get remove --purge add-apt-repository | Remove the package that was used to add a repository |
Cleaning and Caching
#
Command/Option | Example | Description |
---|
apt-get clean | apt-get clean | Remove all cached package files |
apt-get autoclean | apt-get autoclean | Remove cached package files that can no longer be downloaded |
apt-get autoremove | apt-get autoremove | Remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed |
Transaction and History
#
Command/Option | Example | Description |
---|
apt-get -f install | apt-get -f install | Fix broken dependencies |
dpkg --configure -a | dpkg --configure -a | Reconfigure unpacked packages that have not yet been configured |
Miscellaneous
#
Command/Option | Example | Description |
---|
apt-get download <package> | apt-get download nginx | Download a package file without installing it |
dpkg -L <package> | dpkg -L nginx | List all files installed by a package |
dpkg -S <file> | dpkg -S /usr/sbin/nginx | Find the package that owns a specific file |
This cheatsheet covers essential apt-get
commands and options for package management on Debian-based Linux distributions.