apt-get
Install, update, and remove software packages
TLDR
Update the list of available packages and versions (it's recommended to run this before other apt-get commands)
Install a package, or update it to the latest available version
Remove a package
Remove a package and its configuration files
Upgrade all installed packages to their newest available versions
Clean the local repository - removing package files (.deb) from interrupted downloads that can no longer be downloaded
Remove all packages that are no longer needed
Upgrade installed packages (like upgrade), but remove obsolete packages and install additional packages to meet new dependencies
SYNOPSIS
apt-get [options] command [packages...]
Example: sudo apt-get update
Example: sudo apt-get install package-name
PARAMETERS
-y, --assume-yes
Automatic yes to prompts; assumes 'yes' to all questions.
-s, --simulate, --dry-run
No actual actions will be performed; simulates operations.
-f, --fix-broken
Attempt to correct a system with broken dependencies.
-q, --quiet
Produces output suitable for logging, suppressing interactive prompts.
-V, --show-versions
Shows the version numbers of packages being installed/upgraded.
--no-install-recommends
Do not consider recommended packages as dependencies for installation.
--no-install-suggests
Do not consider suggested packages as dependencies for installation.
-u, --show-upgraded
Show a list of all packages that are going to be upgraded.
-d, --download-only
Download packages only; don't install or unpack them.
DESCRIPTION
apt-get is a powerful command-line tool that handles the installation, removal, and upgrading of software packages on Debian, Ubuntu, and other Debian-based Linux distributions. It is part of the Advanced Package Tool (APT) system. apt-get works by interacting with configured repositories (servers hosting software packages), resolving dependencies, and retrieving the necessary .deb package files. It automates the complex process of ensuring all required libraries and programs are installed when you add new software or update existing ones. While still widely used, the newer apt command is often preferred for interactive use due to its more user-friendly interface, which combines functionalities from apt-get and apt-cache. Nonetheless, apt-get remains fundamental for scripting and certain system administration tasks.
CAVEATS
Using apt-get typically requires root privileges (via `sudo`). Careless use, especially with commands like `dist-upgrade` on unstable systems or forcing installations with `--fix-broken`, can potentially destabilize your system. An active internet connection is essential for updating package lists and downloading new software. For general interactive use, the newer `apt` command is often more user-friendly.
COMMON COMMANDS
Here are the most frequently used sub-commands for apt-get:
update:
Resynchronizes the package index files from their sources. It downloads new package lists from the repositories, letting `apt-get` know about new versions of packages.
install <package>:
Installs new packages. It automatically resolves and installs any required dependencies. Multiple packages can be specified.
remove <package>:
Removes specified packages, but leaves their configuration files behind.
purge <package>:
Removes specified packages along with their configuration files.
upgrade:
Installs the newest versions of all packages currently installed on the system that are available from the sources configured in `/etc/apt/sources.list`. Existing packages are upgraded.
dist-upgrade:
Similar to `upgrade`, but also intelligently handles changing dependencies with new versions of packages; it may remove some packages or install new ones to satisfy dependencies. Often used for distribution upgrades.
autoclean:
Clears out the local repository of retrieved package files that can no longer be downloaded, and are now of no use.
autoremove:
Removes packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.
clean:
Clears out the local repository of retrieved package files. Unlike `autoclean`, it removes all .deb files regardless of whether they are still available for download.
check:
Is a diagnostic tool; it updates the package cache and checks for broken dependencies.
HISTORY
apt-get was developed as a core component of the Advanced Package Tool (APT) project by the Debian community. Its primary goal was to provide a more robust and user-friendly solution for managing software packages and their complex dependencies, improving upon the direct usage of `dpkg`. First released in 1998, it quickly became the standard for package management on Debian and its derivatives like Ubuntu. While its core functionality remains, the introduction of the simpler `apt` command in 2014 provided a consolidated interface for daily tasks, making `apt-get` more often used for scripting or specific administrative functions.