Show Menu
Cheatography

my cheat sheet Cheat Sheet (DRAFT) by

my first test cheat sheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Command guide: apt

Descri­ption and usage

apt
provides a high-level comman­dline interface for the package management system. It is intended as an end user interface and enables some options better suited for intera­ctive usage by default compared to more specia­lized APT tools like
apt-get
and
apt-cache
.
It works with Ubuntu’s Advanced Packaging Tool (APT) performing such functions as instal­lation 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 privil­eges, in this case, prepend
sudo
to the command.

options

--assu­me-no
Assumes the answer "­no" to all prompts.
-b, --compile, --build
Compile source packages after downlo­ading them.
-c, --conf­ig-file
Specify a config­uration file to use. The program will read the default config­uration file and then this config­uration file. If config­uration settings need to be set before the default config­uration files are parsed specify a file with the APT_CONFIG enviro­nment variable.
-d, --down­loa­d-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 depend­encies.
--forc­e-yes
Force yes. This is a dangerous option that will cause apt to continue without prompting if it is doing something potent­ially harmful. It should not be used except in very special situat­ions. Using --forc­e-yes can potent­ially destroy your system!
--igno­re-hold
Ignore package Holds. This causes apt-get to ignore a hold placed on a package. This may be useful in conjun­ction with dist-u­pgrade to override a large number of undesired holds.
-h, --help
Show a short usage summary.
-m, --igno­re-­mis­sing, --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 situat­ions. If a package is selected for instal­lation (parti­cularly if it is mentioned on the comman­d-line) and it could not be downloaded then it will be silently held back.
--no-d­ownload
Do not download any packages. This forces apt to use only packages it has already downlo­aded.
--no-l­ist­-cl­eanup
Forbids apt to automa­tically manage the contents of /var/l­ib/­apt­/lists to erase obsolete files. The only reason to use this option is if you frequently change your source list.
--no-r­emove
If any packages are to be removed apt immedi­ately aborts without prompting.
--no-u­pgrade
Do not upgrade packages. When used in conjun­ction with install, no-upgrade will prevent packages listed from being upgraded if they are already installed.
-o, --option
Sets an arbitrary config­uration option. The syntax is
-o Foo::B­ar=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 corres­ponding source package.
--prin­t-uris
Instead of fetching the files to install, their URIs are printed. Each URI will have the path, the destin­ation 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 indica­tors. 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 config­uration file. Note that quiet level 2 implies -y, you should never use -qq without a no-action modifier such as -d, --prin­t-uris or -s as APT may decided to do something you did not expect.
--rein­stall
Re-Install packages that are already installed and at the newest version.
-s, --simu­late, --just­-print, --dry-run, --recon, --no-act
Simulates operat­ions, reporting what they would do, but make no changes to the system.
-t, --targ­et-­rel­ease, --defa­ult­-re­lease
This option controls the default input to the policy engine. It creates a default pin at priority 990 using the specified release string. The prefer­ences file may further override this setting. In short, this option lets you have simple control over which distri­bution packages will be retrieved from. Some common examples might be -t '2.1*' or -t unstable.
--triv­ial­-only
Only perform operations that are "­tri­via­l". Logically this can be considered related to --assu­me-yes. Where --assu­me-yes will answer yes to any prompt, --triv­ial­-only will answer no.
-u, --show­-up­graded
Show upgraded packages. Print out a list of all packages that are to be upgraded.
-v, --version
Show the program version.
-V, --verb­ose­-ve­rsions
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

apt update
Updates the list of available packages.
apt upgrade
Downloads and installs the latest packages.
 

command list

update
download package inform­ation 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 depend­encies, but existing packages will never be removed.
full-u­pgrade
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 (
--inst­alled
), upgrad­eable (
--upgr­adeable
) or all available versions (
--all-­ver­sions
).
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-­Dep­ends. It also handles conflicts, by prefixing an argument with "
Conflicts: 
"
.
autoremove
remove packages that are now no longer needed because depend­encies 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
instal­ls/­rei­nstalls one or more packages specified via regex, glob or exact match. A specific version of a package can be selected for instal­lation by following the package name with an equals (
=<v­ers­ion>
). Altern­atively the version from a specific release can be selected by following the package name with a forward slash and codename (
/<c­ode­nam­e>
) , such as bullseye, bookworm, sid ..., or suite name (
/<s­uit>
), for example, stable, testing, unstable. This will also select versions from this release for depend­encies 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 config­uration files behind, in case the remove was an accident. Just issuing an instal­lation request for the accide­ntally 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 config­uration files) of an installed (or already removed) packages. This does not affect any data or config­uration stored in your home directory. See note (**).
(*) This is a short list of the most commonly used commands. View docume­ntation 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.

sd