Description and usage
apt
provides a high-level commandline interface for the package management system. It is intended as an end user interface and enables some options better suited for interactive usage by default compared to more specialized APT tools like apt-get
and apt-cache
.
It 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. The basic command syntax is:
$ apt [options] command [packages]
|
Some commands require root-level privileges, in this case, prepend sudo
to the command.
options
--assume-no |
Assumes the answer "no" to all prompts. |
-b, --compile, --build |
Compile source packages after downloading them. |
-c, --config-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. |
-d, --download-only |
For any operation that would download packages, download them, but do nothing else. |
-f, --fix-broken |
When used with install or remove, this option attempts to fix any broken dependencies. |
--force-yes |
Force yes. This is a dangerous option that will cause apt to continue without prompting if it is doing something potentially harmful. It should not be used except in very special situations. Using --force-yes can potentially destroy your system! |
--ignore-hold |
Ignore package Holds. This causes apt-get to ignore a hold placed on a package. This may be useful in conjunction with dist-upgrade to override a large number of undesired holds. |
-h, --help |
Show a short usage summary. |
-m, --ignore-missing, --fix-missing |
Ignores missing packages. If packages cannot be retrieved or fail the integrity check after retrieval (corrupted package files), hold back those packages and handle the result. Use of this option together with -f may produce an error in some situations. If a package is selected for installation (particularly if it is mentioned on the command-line) and it could not be downloaded then it will be silently held back. |
--no-download |
Do not download any packages. This forces apt to use only packages it has already downloaded. |
--no-list-cleanup |
Forbids apt to automatically manage the contents of /var/lib/apt/lists to erase obsolete files. The only reason to use this option is if you frequently change your source list. |
--no-remove |
If any packages are to be removed apt immediately aborts without prompting. |
--no-upgrade |
Do not upgrade packages. When used in conjunction with install, no-upgrade will prevent packages listed from being upgraded if they are already installed. |
-o, --option |
Sets an arbitrary configuration option. The syntax is -o Foo::Bar=bar
. -o and --option can be used multiple times to set different options. |
--only-source |
Only has meaning for the source command. Indicates that the given source names are not to be mapped through the binary table. This means that if this option is specified, the source command will only accept source package names as arguments, rather than accepting binary package names and looking up the corresponding source package. |
--print-uris |
Instead of fetching the files to install, their URIs are printed. Each URI will have the path, the destination file name, the size and the expected md5 hash. Note that the file name to write to will not always match the file name on the remote site! This also works with the source and update commands. When used with the update command, the MD5 and size are not included, and it is up to the user to decompress any compressed files. |
-q, --quiet |
Quiet. Produces output suitable for logging, omitting progress indicators. More q's will produce more quiet up to a maximum of two. You can also use -q=# to set the quiet level, overriding the configuration file. Note that quiet level 2 implies -y, you should never use -qq without a no-action modifier such as -d, --print-uris or -s as APT may decided to do something you did not expect. |
--reinstall |
Re-Install packages that are already installed and at the newest version. |
-s, --simulate, --just-print, --dry-run, --recon, --no-act |
Simulates operations, reporting what they would do, but make no changes to the system. |
-t, --target-release, --default-release |
This option controls the default input to the policy engine. It creates a default pin at priority 990 using the specified release string. The preferences file may further override this setting. In short, this option lets you have simple control over which distribution packages will be retrieved from. Some common examples might be -t '2.1*' or -t unstable. |
--trivial-only |
Only perform operations that are "trivial". Logically this can be considered related to --assume-yes. Where --assume-yes will answer yes to any prompt, --trivial-only will answer no. |
-u, --show-upgraded |
Show upgraded packages. Print out a list of all packages that are to be upgraded. |
-v, --version |
Show the program version. |
-V, --verbose-versions |
Show full versions for upgraded and installed packages. |
-y |
Assumes the answer "yes" to any prompts, proceeding with all operations if they are possible. |
Examples
Updates the list of available packages.
|
Downloads and installs the latest packages.
|
|
|
command list
update |
download package information from all configured sources. Note: Other commands operate on this data, therefore, it is advisable to run this command first. |
upgrade |
install available upgrades of all packages currently installed on the system from the configured sorces. New packages will be installed if required to satisfy dependencies, but existing packages will never be removed. |
full-upgrade |
performs the function of upgrade but will remove currently installed packages if this is needed to upgrade the system as a whole. |
list |
displays a list of packages satisfying certain criteria. It supports glob patterns for matching package names as well as options to list installed ( --installed
), upgradeable ( --upgradeable
) or all available versions ( --all-versions
). |
search |
search for the given regex term(s) in the list of available packages and display matches. If you are looking for a package including a specific file try apt- file
. |
satisfy |
satisfies dependency strings, as used in Build-Depends. It also handles conflicts, by prefixing an argument with "Conflicts: ". |
autoremove |
remove packages that are now no longer needed because dependencies changed or the package(s) needing them were removed in the meantime. Packages marked by the user (installed using apt-mark
) or installed explicitly via install
are never proposed for automatic removal. |
install / reinstall |
installs/reinstalls one or more packages specified via regex, glob or exact match. A specific version of a package can be selected for installation by following the package name with an equals ( =<version>
). Alternatively the version from a specific release can be selected by following the package name with a forward slash and codename ( /<codename>
) , such as bullseye, bookworm, sid ..., or suite name ( /<suit>
), for example, stable, testing, unstable. This will also select versions from this release for dependencies of this package if needed to satisfy the request. See note (**). |
remove |
removes one or more packages specified via regex, glob or exact match. All package data will be removed, leaving (modified) user configuration files behind, in case the remove was an accident. Just issuing an installation request for the accidentally removed package will restore its function as before in that case. See note (**). |
purge |
removes one or more packages specified via regex, glob or exact match. All data (including user configuration files) of an installed (or already removed) packages. This does not affect any data or configuration stored in your home directory. See note (**). |
(*) This is a short list of the most commonly used commands. View documentation for a complete list.
(**) The requested action can be overridden for specific packages by appending a plus (+) to the package name to install this package or a minus (-) to remove it.
|