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 [package ...]
PARAMETERS
-h, --help
Show summary of options.
-v, --version
Show version information.
-q, --quiet
Produce less output; repeat for more quiet.
-y, --assume-yes, --assume-y
Assume 'yes' to all prompts.
-d, --download-only
Download packages but do not install.
-s, --simulate, --dry-run, --recon, --just-print
Simulate actions without changes.
-u, --upgrade
Show upgraded packages (with install/upgrade).
-b, --build
Build source packages only.
-V, --verbose-versions
Explain versions during install.
--allow-downgrades
Allow downgrading packages.
--allow-remove-essential
Allow removing essential packages.
--allow-change-held-packages
Allow changes to held packages.
--no-install-recommends
Do not install recommended packages.
--install-recommends
Install recommended packages too.
--only-source
Get source packages only.
--only-deb
Get deb packages only.
--no-upgrade
Do not upgrade packages.
--no-remove
Do not remove packages.
--ignore-missing
Ignore missing packages.
-t, --target-release, -T
Target release version.
-o, --option
Set custom configuration option.
-c, --config-file
Use alternative config file.
-a, --architectures
Process architectures.
DESCRIPTION
apt-get is a powerful command-line tool for managing packages on Debian-based systems like Ubuntu. Part of the APT (Advanced Package Tool) suite, it handles installing, updating, upgrading, removing, and querying software packages from remote repositories defined in /etc/apt/sources.list and /etc/apt/sources.list.d/.
It fetches package lists with update, installs or upgrades with install or upgrade, and cleans up with clean or autoremove. Designed for scripts and advanced users, it requires superuser privileges (use sudo). Unlike graphical tools, it provides precise control over dependencies, versions, and simulations.
Key strengths include handling complex dependency resolution, source code compilation via source, and holding packages. It's script-friendly with options like --assume-yes for automation. While apt offers a user-friendly wrapper, apt-get remains essential for servers and precise operations, supporting both binary (.deb) and source packages.
CAVEATS
Requires root privileges (sudo); can break system if misused (e.g., removing essentials); repositories must be updated first; prefer apt for interactive use as apt-get is script-oriented.
COMMON SUBCOMMANDS
update: Refresh package lists.
upgrade: Upgrade installed packages.
dist-upgrade: Upgrade with package additions/removals.
install: Install packages.
remove: Remove packages (keep config).
purge: Remove packages and config.
autoremove: Remove unused deps.
clean: Clear downloaded .deb files.
CONFIG FILES
Main: /etc/apt/sources.list
Extras: /etc/apt/sources.list.d/*.list
Use apt-get update after editing.
HISTORY
Developed as part of APT by Debian's Jason Gunthorpe and Fabrice Bellet; first released in 1998 with APT 0.1.9 for better dependency handling over dpkg. Evolved through decades, key in Ubuntu since 2004; largely stable, with apt (2014) as modern frontend.


