aptget command in Linux (original) (raw)

apt-get command in Linux

Last Updated : 19 May, 2026

The apt-get command is a command-line package management tool used in Debian-based Linux distributions such as Ubuntu and Debian. It allows users to install, update, upgrade and remove software packages easily by fetching them from configured repositories.

Most Commonly Used apt-get Commands

1. Update Package Index

This command updates the local package list from the configured repositories. It does not install or upgrade any software but ensures the system has the latest package information.

**Command:

sudo apt-get update

**Output:

file

Output

2. Upgrade Installed Packages

This command upgrades all installed packages to their latest available versions. An update should be performed before running this command.

**Command:

sudo apt-get upgrade

**Output:

file

Output

3. Dselect Upgrade

This command upgrades the system based on selections made using the dselect tool. It installs and removes packages according to those selections.

**Command:

sudo apt-get dselect-upgrade

**Output:

file

Output

**NOTE : dselect-upgrade is Rarely used in practice; mainly for legacy dselect tool

4. Distribution Upgrade

This command performs an advanced upgrade. It handles changing dependencies and may install or remove packages to complete the upgrade.

**Command:

sudo apt-get dist-upgrade

**Output:

file

Output

5. Install Packages

This command installs one or more packages and automatically installs their dependencies.

**Command:

sudo apt-get install vim

**Note: You can also specify package versions or target distributions, but this should be done carefully as it may downgrade packages.

6. Reinstall Packages

This command reinstalls a package that is already installed, restoring it to its default state.

**Command:

sudo apt-get install --reinstall firefox

7. Remove Packages

This command removes a package but keeps its configuration files.

sudo apt-get remove vim

8. Purge Packages

This command removes a package along with its configuration files.

**Command:

sudo apt-get purge vim

9. Check for Broken Dependencies

This command checks the system for broken dependencies and looks for inconsistencies in the package system.

**Command:

sudo apt-get check

**Output:

file

10. Download Packages

This command downloads a package without installing it.

**Command:

sudo apt-get download firefox

11. Clean Package Cache

This command removes all downloaded package files stored in the local cache.

**Command:

sudo apt-get clean

12. Remove Unused Dependencies

This command removes packages that were installed automatically as dependencies and are no longer needed.

**Command:

sudo apt-get autoremove

**Output:

file

13. Download Source Code

This command downloads the source code of a package in tarball format.

**Command:

sudo apt-get source firefox

14. Show Package Information

This command displays detailed information about a package, including version, dependencies, and description.

**Command:

sudo apt-get show firefox

Syntax

sudo apt-get [options] [command] [package(s)]

Options Available in apt-get

The apt-get command supports several options to control its behavior:

  1. **--no-install-recommends: Prevents installation of recommended packages that are not strictly required.
  2. **--install-suggests: Installs suggested packages along with the requested package.
  3. **-d or --download-only: Downloads packages without installing them.
  4. **-f or --fix-broken: Attempts to fix broken dependencies.
  5. **-m or --ignore-missing: Ignores missing or unavailable packages.
  6. **--no-download: Uses only cached packages and avoids downloading new ones.
  7. **-q or --quiet: Suppresses output messages, useful in scripts.
  8. **-s or --simulate: Simulates the command without making changes.
  9. **-y or --assume-yes: Automatically answers “yes” to prompts.
  10. **--assume-no: Automatically answers “no” to prompts.
  11. **--no-show-upgraded: Suppresses the list of upgraded packages during an upgrade.
  12. **-V or --verbose-versions: Displays detailed version information.
  13. **-b or --build: Builds a package from source.
  14. **--no-upgrade: Installs a package without upgrading existing ones.
  15. **--only-upgrade: Upgrades a package without installing new ones.
  16. **--reinstall: Reinstalls an installed package.
  17. **-h or --help: Displays the help manual.

Difference Between apt and apt-get

Feature apt apt-get
**Purpose High-level tool designed for interactive use Low-level tool mainly used for scripts and automation
**User Experience Cleaner output with progress bars and colored text Detailed but less user-friendly output
**Command Simplicity Combines common operations (e.g., update + upgrade) Requires separate commands for each task
**Stability for Scripts Not recommended for scripts (output may change) Stable interface, safe for scripting
**Features Combines functionalities of apt-get, apt-cache, and apt-config Focused mainly on installation and removal
**Availability Introduced later for better usability Available since early Debian versions