Apt (Advanced Packaging Tool) is a Shell front-end package manager in Debian and Ubuntu.

Apt command provides the command to find, install, upgrade, delete a certain, a group or even all software packages, and the command is concise and easy to remember.

Apt command execution requires super administrator privileges (root).

Apt grammar

 apt [options] [command] [package ...]
Copy the code
  • ** Options: ** Optional options include -h (help), -y (select all “yes” when prompted during installation), -q (do not display the installation process), and so on.
  • **command: ** The operation to be performed.
  • Package: indicates the name of the installation package.

Apt common commands

  • Sudo apt update lists all software that can be updated

  • Sudo apt Upgrade

    List updatable packages and version information: apt List –upgradeable

    Run the sudo apt full-upgrade command to upgrade software packages

  • Sudo apt install <package_name>

    Sudo apt install <package_1> <package_2> <package_3>

  • Sudo apt update <package_name>

  • Sudo apt show <package_name>

  • Sudo apt remove <package_name>

  • Clean up dependencies and library files that are no longer used: sudo apt autoremove

  • Sudo apt purge <package_name>

  • Sudo apt search

  • List all installed packages: apt List –installed

  • List the versions of all installed packages: apt list –all-versions

The instance

Check out some updatable packages:

sudo apt update
Copy the code

Upgrade installation package:

sudo apt upgrade
Copy the code

Enter the letter Y interactively above to begin the upgrade.

You can combine the following two commands for one-click upgrade:

sudo apt update && sudo apt upgrade -y
Copy the code

Install mPlayer package:

sudo apt install mplayer
Copy the code

If you don’t remember the full package name, you can just type the first half of the package name and then press Tab to list the relevant package name:

In the example above we typed reds and then hit Tab to output four related packages.

If we want to install a package, but do not upgrade it if the package already exists, use the — no-upgrade option:

sudo apt install <package_name>  --no-upgrade
Copy the code

Install mPlayer if it exists do not upgrade:

sudo apt install mplayer --no-upgrade
Copy the code

If you only want to upgrade and do not install, you can use the –only-upgrade parameter:

sudo apt install <package_name>  --only-upgrade
Copy the code

Only upgrade mPlayer, don’t install it if it doesn’t exist:

sudo apt install mplayer --only-upgrade
Copy the code

To set the specified version, the syntax is as follows:

sudo apt install <package_name>=<version_number>
Copy the code

Package_name indicates the package name, and version_number indicates the version number.

To remove packages, use the remove command:

sudo apt remove mplayer
Copy the code

Find the related package named LibiMobile:

apt search libimobile
Copy the code

To view information about pinta packages:

apt show pinta
Copy the code

Lists updatable packages:

apt list --upgradeable
Copy the code

Clean up dependencies and library files that are no longer used:

sudo apt autoremove
Copy the code

To begin the cleanup, type the letter Y interactively above.