# man > apt-get(8)

---
type: CommandReference
command: apt-get
mode: man
section: 8
source: man-pages
---

## Quick Reference

- `sudo apt-get update` — Update list of available packages and versions
- `sudo apt-get install <package>` — Install or update a package
- `sudo apt-get remove <package>` — Remove a package (keep config files)
- `sudo apt-get purge <package>` — Remove package and its configuration files
- `sudo apt-get upgrade` — Upgrade all installed packages
- `sudo apt-get autoclean` — Remove obsolete package files from cache
- `sudo apt-get autoremove` — Remove packages that are no longer needed
- `sudo apt-get dist-upgrade` — Upgrade with smart dependency handling (may remove packages)

## Name

**apt-get** — APT package handling utility -- command-line interface

## Synopsis

`apt-get [options] {update | upgrade | dselect-upgrade | dist-upgrade | install <pkg>... | remove <pkg>... | purge <pkg>... | source <pkg>... | build-dep <pkg>... | download <pkg>... | check | clean | autoclean | autoremove | changelog | indextargets | {-v | --version} | {-h | --help}} [options]`

## Options

### General Options

- `-d, --download-only` — Download only; do not unpack or install
- `-f, --fix-broken` — Fix broken dependencies
- `-m, --ignore-missing, --fix-missing` — Ignore missing or corrupted packages
- `-q, --quiet` — Quiet output; `-qq` implies `-y`
- `-s, --simulate, --dry-run, --no-act` — Perform a simulation without changes
- `-y, --yes, --assume-yes` — Assume yes to all prompts
- `--assume-no` — Assume no to all prompts
- `-v, --version` — Show program version
- `-h, --help` — Show usage summary
- `-c, --config-file <file>` — Use specified configuration file
- `-o, --option <option>` — Set a configuration option

### Install/Upgrade Options

- `--no-install-recommends` — Do not install recommended packages
- `--install-suggests` — Install suggested packages
- `--reinstall` — Reinstall already installed packages
- `--no-upgrade` — Do not upgrade packages on command line
- `--only-upgrade` — Only upgrade already installed packages; do not install new ones
- `--with-new-pkgs` — Allow installing new packages during upgrade
- `--allow-downgrades` — Allow downgrading packages (dangerous)
- `--allow-remove-essential` — Allow removal of essential packages (dangerous)
- `--allow-change-held-packages` — Allow changing held packages (dangerous)
- `--force-yes` — Force yes (deprecated; use fine-grained options)
- `--ignore-hold` — Ignore package holds
- `--purge` — Use purge instead of remove for all removals
- `--autoremove, --auto-remove` — Remove unused dependencies after install/remove
- `--mark-auto` — Mark all freshly installed packages as automatically installed
- `--no-remove` — Abort if any packages are to be removed

### Source/Build Options

- `-b, --compile, --build` — Compile source packages after download
- `-a, --host-architecture <arch>` — Set host architecture for cross-compilation
- `-P, --build-profiles <profiles>` — Activate build profiles (comma-separated)
- `--only-source` — Treat arguments as source package names only
- `--diff-only, --dsc-only, --tar-only` — Download only the specified file type
- `--arch-only` — Process only architecture-dependent build-dependencies
- `--indep-only` — Process only architecture-independent build-dependencies

### Other Options

- `-t, --target-release, --default-release <release>` — Target a specific release (e.g., `stable`, `testing`)
- `-V, --verbose-versions` — Show full versions for upgraded/installed packages
- `--print-uris` — Print URIs of files instead of downloading
- `--list-cleanup` — Enable automatic cleanup of `/var/lib/apt/lists` (default on)
- `--no-list-cleanup` — Disable list cleanup
- `--allow-unauthenticated` — Allow unauthenticated packages (security risk)
- `--no-allow-insecure-repositories` — Forbid update from unsigned repositories
- `--allow-releaseinfo-change` — Allow repository release info changes (e.g., new release)
- `--show-progress` — Show user-friendly progress during package operations
- `--with-source <file>` — Add a file as a source for metadata
- `-e, --error-on=` — Fail update on any error
- `-S, --snapshot <timestamp>` — Select a snapshot for Snapshot-enabled archives

## Examples

shell
# Update package list
sudo apt-get update

# Install a package
sudo apt-get install nginx

# Remove a package (keep config)
sudo apt-get remove nginx

# Purge a package (remove config)
sudo apt-get purge nginx

# Upgrade all packages
sudo apt-get upgrade

# Perform a dist-upgrade
sudo apt-get dist-upgrade

# Autoremove unused dependencies
sudo apt-get autoremove

# Clean obsolete package files
sudo apt-get autoclean

# Simulate an install
apt-get -s install vim
## See Also

- [apt-cache(8)](https://www.chedong.com/phpMan.php/man/apt-cache/8/markdown)
- [apt-cdrom(8)](https://www.chedong.com/phpMan.php/man/apt-cdrom/8/markdown)
- [dpkg(1)](https://www.chedong.com/phpMan.php/man/dpkg/1/markdown)
- [sources.list(5)](https://www.chedong.com/phpMan.php/man/sources.list/5/markdown)
- [apt.conf(5)](https://www.chedong.com/phpMan.php/man/apt.conf/5/markdown)
- [apt-secure(8)](https://www.chedong.com/phpMan.php/man/apt-secure/8/markdown)
- [apt_preferences(5)](https://www.chedong.com/phpMan.php/man/preferences/5/markdown)
- [aptitude(8)](https://www.chedong.com/phpMan.php/man/aptitude/8/markdown)
- [synaptic(8)](https://www.chedong.com/phpMan.php/man/synaptic/8/markdown)
- [wajig(1)](https://www.chedong.com/phpMan.php/man/wajig/1/markdown)

## Exit Codes

- `0` — Normal operation
- `100` — Error occurred