Difference between revisions of "Apt command"

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to navigation Jump to search
Line 30: Line 30:
<pre>sudo -- sh -c "apt update && apt upgrade"</pre>
<pre>sudo -- sh -c "apt update && apt upgrade"</pre>
===  Install the nginx software package ===
===  Install the nginx software package ===

Revision as of 08:15, 16 November 2017

The apt is a command used on Debian, Ubuntu and other Linux distribution. It 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 command and apt-cache command.

apt command Syntax

The syntax is

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

apt Commands

All apt command must run by the root user either using the sudo command or su command.

  • list - list packages based on package names
  • search - search in package descriptions
  • show - show package details
  • install - install packages
  • remove - remove packages
  • autoremove - Remove automatically all unused packages
  • update - update list of available packages
  • upgrade - upgrade the system by installing/upgrading packages
  • full-upgrade - upgrade the system by removing/installing/upgrading packages
  • edit-sources - edit the source information file


Let us see some example:

Upgrade all installed packages on your system

sudo apt update 
sudo apt upgrade


sudo -- sh -c "apt update && apt upgrade"


Install the nginx software package

See also