apt-get(8)
apt-get is the command-line tool for managing packages in Debian-based Linux distributions.
Synopsis
apt-get [OPTION]... COMMAND [PACKAGE]...Description
apt-get is the primary package management tool for Debian, Ubuntu, and other apt-based systems. It handles downloading, installing, upgrading, and removing software packages from configured repositories.
Common commands include: update (refresh package lists), install (download and install packages), upgrade (install newer versions), remove (uninstall packages), and clean (free up disk space by removing cached packages).
Most operations require superuser privileges (use sudo). Package names are case-sensitive and typically lowercase.
Common options
| Flag | What it does |
|---|---|
update | refresh the list of available packages from repositories |
upgrade | install newer versions of packages already on the system |
install | download and install specified packages |
remove | uninstall packages but keep configuration files |
purge | uninstall packages and delete all configuration files |
autoremove | remove unused packages that are no longer needed as dependencies |
clean | remove cached package files to free disk space |
-y, --assume-yes | assume 'yes' to all prompts; useful for scripting |
-s, --simulate | show what would be done without actually making changes |
--no-upgrade | do not upgrade packages marked for upgrade |
Examples
refresh package lists from all configured repositories; run before install or upgrade operations
sudo apt-get updatedownload and install the nginx web server and its dependencies
sudo apt-get install nginxupgrade all packages to their newest available versions without removing packages
sudo apt-get upgradeinstall the build-essential package automatically confirming the prompt
sudo apt-get install -y build-essentialuninstall the apache2 package while preserving its configuration files
sudo apt-get remove apache2remove automatically installed dependency packages no longer needed by any installed package
sudo apt-get autoremovesimulate installing python3-pip to see what would happen without making actual changes
sudo apt-get install -s python3-pipremove all cached packages and only keep cache for currently installed packages to free disk space
sudo apt-get clean && sudo apt-get autoclean