apt Command Examples in Linux

Although dpkg is the original installer for Debian-derived distributions, today .deb packages are more commonly managed using APT. APT is a front-end manager to the dpkg system, much like YUM is a front-end manager to the RPM system. Until recently, the common software management tools were implemented as a mix of the apt-get and the apt-cache commands, along with several other variations on the apt-* format. Many Debian-derived distributions now use the more streamlined package manager simply named apt.

The apt command comes with several subcommands for managing packages.

Subcommand Description
install {package name} Install the package.
remove {package name} Uninstall the package, leaving behind its configuration files.
purge {package name} Uninstall the package and remove its configuration files.
show {package name} Report information about the package.
version {package name} Display version information about the package.
update Update APT database of available packages.
upgrade [package name] Upgrade the package, or upgrade all packages if none provided (time-consuming).

Syntax

The syntax of the apt command is:

# apt [options] [subcommand] [package name]

apt Command Examples

1. Update the list of available packages and versions (it’s recommended to run this before other `apt` commands):

# apt update

2. Search for a given package:

# apt search package

3. Show information for a package:

# apt show package

4. Install a package, or update it to the latest available version:

# apt install package

5. Remove a package (using `purge` instead also removes its configuration files):

# apt remove package

6. Upgrade all installed packages to their newest available versions:

# apt upgrade

7. List all packages:

# apt list

8. List installed packages:

# apt list --installed
Related Post