apt

Search for and install software packages (Debian/Ubuntu). See also apt-get(8) and apt-cache(8) for more low-level command options. (Debian/Ubuntu).

Syntax
      apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [ -a=architecture]
         list pkg {=pkg_version_number | / target_release}]... 

      apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [ -a=architecture]
         search pkg {=pkg_version_number | / target_release}]... 

      apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [ -a=architecture]
         show pkg {=pkg_version_number | / target_release}]... 

      apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [ -a=architecture]
         update pkg {=pkg_version_number | / target_release}]... 

      apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [ -a=architecture]
         install pkg {=pkg_version_number | / target_release}]... 

      apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [ -a=architecture]
         remove pkg...

      apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [ -a=architecture]
         upgrade

      apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [ -a=architecture]
         full-upgrade

      apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [ -a=architecture]
         edit-sources

      apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [ -a=architecture]
         {-v | --version}

      apt [-h] [-o=config_string] [-c=config_file] [-t=target_release] [ -a=architecture]
         {-h | --help}

Options

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.

   -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.

   -h, --help
          Show a short usage summary.

   -v, --version
          Show the program version.

apt/apt-get and aptitude now share the same list of installed packages and so can be used interchangeably.

apt option Description Apt-Get Equivalent
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. apt‑cache search
show show shows the package information for the given package(s). apt-cache show
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).

apt-get install
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. apt-get remove
edit‑sources 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. apt-get update
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 packages will be installed, but existing packages will never be removed. apt-get upgrade
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. apt‑get dist‑upgrade

FILES

/etc/apt/sources.list
Locations to fetch packages from. It takes the following format:
deb [web address] [distribution name][maincontribnon-free]
For example, in Ubuntu, it could be something like:
deb http://in.archive.ubuntu.com/ubuntu lucid main restrcted
or for debian
deb http://ftp.de.debian.org/debian lenny main
Configuration Item:
Dir::Etc::SourceList.

/etc/apt/sources.list.d/
File fragments for locations to fetch packages from. Configuration
Item: Dir::Etc::SourceParts.

/etc/apt/apt.conf
APT configuration file. Configuration Item: Dir::Etc::Main.

/etc/apt/apt.conf.d/
APT configuration file fragments. Configuration Item:
Dir::Etc::Parts.

/etc/apt/preferences
Version preferences file. This is where you would specify
"pinning", i.e. a preference to get certain packages from a
separate source or from a different version of a distribution.
Configuration Item: Dir::Etc::Preferences.

/etc/apt/preferences.d/
File fragments for the version preferences. Configuration Item:
Dir::Etc::PreferencesParts.

/var/cache/apt/archives/
Storage area for retrieved package files. Configuration Item:
Dir::Cache::Archives.

/var/cache/apt/archives/partial/
Storage area for package files in transit. Configuration Item:
Dir::Cache::Archives (implicit partial).

/var/lib/apt/lists/
Storage area for state information for each package resource
specified in sources.list(5) Configuration Item: Dir::State::Lists.

/var/lib/apt/lists/partial/
Storage area for state information in transit. Configuration Item:
Dir::State::Lists (implicit partial).

Examples

These examples assume that /etc/apt/sources.list already includes the web address of at least one software repository.

Sync the local software database with the repository database (build cache):
$ sudo apt-get update

Search for a particular program (search the cache) in this case the 'gimp' program:
$ apt-cache search gimp

If the above succeeds then the software is available and can be installed:
$ sudo apt-get install gimp

To remove the software if you no longer need it:
$ sudo apt-get remove gimp

Upgrade all the software on your system to the latest versions:
$ sudo apt-get upgrade

Upgrading the whole linux distribution to a new version:
$ sudo apt-get dist-upgrade

“There's nothing wrong with having a collection, but it becomes a problem when it overwhelms your space. When you're not displaying it properly, you're not enjoying it and it turns into clutter” ~ Niecy Nash

Related linux commands:

apt-cache(8), apt-cdrom(8), dselect(1), sources.list(5), apt.conf(5), apt-config(8), apt-secure(8), apt_preferences(5)
dpkg - Low level Package management.
The APT User's guide in /usr/share/doc/apt-doc/
wiki.debian.org/Apt - APT Wiki (Debian).
Ubuntu Software Center - GUI for APT
Synaptic Package Manager - GUI for APT (In Ubuntu this is under System | Administration).
Tasksel - Debian/Ubuntu tool to install multiple related packages, typically on servers.
aptitude - Package manager.
dpkg - Package manager (Debian/Ubuntu).
Equivalent Windows command: Package managers


 
Copyright © 1999-2021 SS64.com
Some rights reserved