The apt-get command is a powerful package management tool used in Debian-based Linux distributions, such as Debian, Ubuntu, and their derivatives. It allows users to install, update, upgrade, and remove software packages from the system's repositories.
Before installing or upgrading packages, you should update the package list to ensure you have the latest information about available packages:
sudo apt-get updateTo upgrade all installed packages to their latest versions, use:
sudo apt-get upgradeTo perform a more comprehensive upgrade that may install or remove packages to satisfy dependencies, use:
sudo apt-get dist-upgradeTo install a specific package, use:
sudo apt-get install package_nameFor example, to install the curl package:
sudo apt-get install curlTo remove a specific package, use:
sudo apt-get remove package_nameTo remove a package along with its configuration files, use:
sudo apt-get purge package_nameTo remove packages that were automatically installed to satisfy dependencies for other packages and are no longer needed:
sudo apt-get autoremoveTo clean the local repository of retrieved package files:
sudo apt-get cleanTo remove all packages that have been downloaded but are no longer installed:
sudo apt-get autocleanTo search for a package by name or description:
apt-cache search keywordTo display detailed information about a package:
apt-cache show package_nameTo check for broken dependencies and attempt to fix them:
sudo apt-get checkTo download a package without installing it:
sudo apt-get download package_nameTo perform a distribution upgrade, which includes upgrading to a new release of the operating system:
sudo apt-get dist-upgradeTo update the package list and upgrade all installed packages:
sudo apt-get update
sudo apt-get upgradeTo install multiple packages at once, list them separated by spaces:
sudo apt-get install package1 package2 package3To remove multiple packages at once:
sudo apt-get remove package1 package2 package3-y: Assume "yes" to all prompts and run non-interactively.-f: Attempt to correct a system with broken dependencies.--purge: Remove configuration files when removing packages.-d: Download only; do not install or unpack archives.--no-install-recommends: Do not consider recommended packages as a dependency for installing.
For example, to install a package without recommended packages:
sudo apt-get install --no-install-recommends package_nameThe apt-get command is a versatile and essential tool for managing software packages on Debian-based systems. By understanding its basic and advanced commands, you can effectively install, update, upgrade, and remove packages, ensuring your system stays up-to-date and free of unnecessary software.
Usage: apt-get [options] command
apt-get [options] install|remove pkg1 [pkg2 ...]
apt-get [options] source pkg1 [pkg2 ...]
apt-get is a command line interface for retrieval of packages
and information about them from authenticated sources and
for installation, upgrade and removal of packages together
with their dependencies.
Most used commands:
update - Retrieve new lists of packages
upgrade - Perform an upgrade
install - Install new packages (pkg is libc6 not libc6.deb)
reinstall - Reinstall packages (pkg is libc6 not libc6.deb)
remove - Remove packages
purge - Remove packages and config files
autoremove - Remove automatically all unused packages
dist-upgrade - Distribution upgrade, see apt-get(8)
dselect-upgrade - Follow dselect selections
build-dep - Configure build-dependencies for source packages
satisfy - Satisfy dependency strings
clean - Erase downloaded archive files
autoclean - Erase old downloaded archive files
check - Verify that there are no broken dependencies
source - Download source archives
download - Download the binary package into the current directory
changelog - Download and display the changelog for the given package