APT Linux Command

What is Linux apt Command?



The apt command is used to work with the software packages in Linux. This command is used to install or remove or upgrade the software packages in a host. The "apt" is the abbreviation for Advanced Package Tool. It is a command-line tool for handling packages. It provides a commandline interface for managing the packages of the system. This command is used to search for particular apt software package in the cache, and to search for available packages that are ready for installation on Linux machines. A software package can be installed by using the command

apt-get install Package Name

The APT (the Advanced Packaging Tool) is an evolution of the Debian .deb software packaging system. Using this tool it is very quick and easy way to install packages on your system. Dependencies are managed automatically, configuration files are maintained, and upgrades and downgrades are handled carefully to ensure system stability.


apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [-a=architecture] {list | search | show | update | install pkg [{=pkg_version_number | /target_release}]... | remove pkg... | upgrade | full-upgrade | edit-sources | {-v | --version} | {-h | --help}}


There are four main operations that APT can perform:
Tag Description
list list is used to display a list of packages. It supports shell pattern for matching package names and the following options: --installed, --upgradable, --all-versions are supported.
search search searches for the given term(s) and display matching packages.
show show shows the package information for the given package(s).
install install is followed by one or more package names desired for installation or upgrading.
A specific version of a package can be selected for installation by following the package name with an equals and the version of the package to select. This will cause that version to be located and selected for install. Alternatively a specific distribution can be selected by following the package name with a slash and the version of the distribution or the Archive name (stable, testing, unstable).
remove remove is identical to install except that packages are removed instead of installed. Note that removing a package leaves its configuration files on the system. If a plus sign is appended to the package name (with no intervening space), the identified package will be installed instead of removed.
edit-resources edit-sources lets you edit your sources.list file and provides basic sanity checks.
update update is used to resynchronize the package index files from their sources.
upgrade upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list. New package will be installed, but existing package will never removed.
full-upgrade full-upgrade performs the function of upgrade but may also remove installed packages if that is required in order to resolve a package conflict.


All command line options may be set using the configuration file, the descriptions indicate the configuration option to set. For boolean options you can override the config file by using something like -f-,--no-f, -f=no or several other variations.
Option Description
-h, --help Show a short usage summary.
-v, --version Show the program version.
-c, --config-file Configuration File; Specify a configuration file to use. The program will read the default configuration file and then this configuration file. If configuration settings need to be set before the default configuration files are parsed specify a file with the APT_CONFIG environment variable. See apt.conf(5) for syntax information.
-o, --option Set a Configuration Option; This will set an arbitrary configuration option. The syntax is -o Foo::Bar=bar. -o and --option can be used multiple times to set different options.


The apt-get command is a powerful command-line tool, which works with Ubuntu's Advanced Packaging Tool (APT) performing such functions as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.
  1. For example, to install the GD graphics library, type the following:
    apt-get install php5-gd

  2. To remove the package installed in the previous example, type the following:
    apt-get remove php5-gd

Ask Questions

Ask Question