apt is a command-line utility for installing, updating and removing packages on Debian, and related Linux distributions. It performs a similar function to apt-get, but with some additional functions, conveniences, and features. Most of the apt commands must be run as a user with sudo privileges.


Below is the syntax of apt command

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}}
  • list : 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 : It searches for the given term(s) and display matching packages.
  • show : It shows the package information for the given package(s).
  • install : It 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. 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 : It is identical to install except that packages are removed instead of installed. Note that removing a package leaves its configuration files on the system.
  • update : It is used to resynchronize the package index files from their sources.
  • upgrade : It 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 : It performs the function of upgrade but may also remove installed packages if that is required in order to resolve a package conflict.

Conmanly used options are

  • -v : Display information about what version of apt you are using.
  • -h : Display a brief listing of available commands and options.
  • -y : Assume the answer “yes” to any prompts, proceeding with all operations if they are possible.
  • –assume-no : Assume the answer “no” to all prompts.
  • -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.
  • –no-download : Do not download any packages. This forces apt to use only packages it has already downloaded.
  • -s,–simulate : Simulate operations, reporting what they would do, but make no changes to the system.

Update Package

Update information about available packages, and then upgrade all installed packages on your system.

sudo apt update && sudo apt upgrade

# Same as above, but automatically answer yes to the prompt.
sudo apt update && sudo apt -y upgrade 

Search Package

apt search searches for the given term(s) and display matching packages. It will look for any packages related to your search query, not just packages that contain the specific phrase in their name. If you get a lot of results, you could always use grep to narrow the search further, or pipe to less or more so your terminal doesn’t get flooded with output.

# Search for package name 
$ apt search package-name

# Search for package and grep for specific term in the result
$ apt search package-name | grep specific-name

# Show result on the visible area of terminal 
$ apt search package-name | less

Package Details

The information about the package dependencies, installation size, the package source, and so on might be useful before removing or installing a new package. apt show retrieve information about a given package. Below command shows the information about package package_name.

sudo apt show package_name