LinuxCommandLibrary

apt

Manage software packages (install, update, remove)

TLDR

Update the list of available packages and versions (recommended before running other apt commands)

$ sudo apt update
copy

Search packages by name or description
$ apt search [package]
copy

Search packages by name only (supports wildcards like *)
$ apt list [package]
copy

Show detailed information about a package
$ apt show [package]
copy

Install a package, or update it to the latest version
$ sudo apt install [package]
copy

Remove a package (use purge instead to also remove configuration files)
$ sudo apt remove [package]
copy

Upgrade all installed packages to their latest versions
$ sudo apt upgrade
copy

List all installed packages
$ apt list [[-i|--installed]]
copy

SYNOPSIS

apt [options] command [arguments]

PARAMETERS

-h, --help
    Display help for apt or specific command.

-v, --version
    Print version information.

--assume-yes, -y
    Automatically answer 'yes' to prompts; non-interactive mode.

--assume-no
    Automatically answer 'no' to prompts.

--dry-run, -s, --simulate
    Simulate operations without making changes.

-q, --quiet
    Produce less output (repeat for more quiet).

-qq
    Very quiet output.

--no-install-recommends
    Skip installing recommended packages.

--no-install-suggests
    Skip installing suggested packages.

-f, --fix-broken
    Fix broken dependencies before proceeding.

-m, --ignore-missing
    Ignore missing packages.

--allow-downgrades
    Allow downgrading packages.

--allow-remove-essential
    Allow removing essential packages (dangerous).

--print-uris
    Print URIs to download instead of downloading.

--target-release, -t
    Target release version for packages.

DESCRIPTION

apt is a command-line interface for the Advanced Package Tool (APT), the package management system used in Debian and Ubuntu-based Linux distributions. It simplifies software installation, updates, removal, and queries by providing an intuitive, interactive experience with features like progress bars, colorized output, and concise messaging.

Unlike the lower-level apt-get, apt is optimized for end-users, automatically handling dependencies, repositories, and security updates. Common tasks include refreshing package databases with update, applying upgrades via upgrade, installing software with install, or searching with search. It supports multiple packages, versions, and pinning for precise control.

apt ensures system integrity by resolving conflicts and verifying sources, making it essential for maintaining stable, up-to-date systems. It's non-interactive by default but offers simulation modes for testing.

CAVEATS

apt is for interactive use; use apt-get for scripts.
Most commands require root privileges (sudo).
Not all apt-get options are supported.
Progress bars may not work in pipes or non-terminals.

COMMON SUBCOMMANDS

update: Refresh package lists.
upgrade: Upgrade all packages.
install pkg [=ver]: Install package.
remove pkg: Remove package (keep config).
purge pkg: Remove package and config.
search pattern: Search packages.
list [--installed]: List packages.

CONFIGURATION

Settings in /etc/apt/apt.conf and /etc/apt/apt.conf.d/*.conf.
Sources in /etc/apt/sources.list and /etc/apt/sources.list.d/.

HISTORY

APT originated in Debian in 1998 by Jason Gunthorpe. The apt frontend debuted in Ubuntu 16.04 LTS (2016) as a user-friendly wrapper over apt-get and apt-cache, prioritizing simplicity and visuals while maintaining compatibility.

SEE ALSO

apt-get(8), apt-cache(8), dpkg(1), aptitude(8), synaptic(8)

Copied to clipboard