Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux apt Command

Linux apt Command

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

The apt command provides commands to find, install, upgrade, and remove one, a group, or even all software packages, and the commands are concise and easy to remember.

Running apt commands requires superuser (root) privileges.

apt Syntax



  apt [options] [command] [package ...]


Common apt Commands

Example

View some upgradable packages:

sudo apt update

Upgrade installed packages:

sudo apt upgrade

In the interactive prompt above, enter the letter Y to start the upgrade.

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

sudo apt update && sudo apt upgrade -y

Install the mplayer package:

sudo apt install mplayer

If you don't quite remember the full package name, you can enter just the first part and press the Tab key; related package names will be listed:

In the example above, we entered reds, then pressed the Tab key, and four related packages were output.

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

sudo apt install  --no-upgrade

Install mplayer, but do not upgrade it if it already exists:

sudo apt install mplayer --no-upgrade

If you only want to upgrade and not install, use the --only-upgrade option:

sudo apt install  --only-upgrade

Only upgrade mplayer; if it does not exist, do not install it:

sudo apt install mplayer --only-upgrade

If you need to set a specific version, the syntax is as follows:

sudo apt install =

package_name is the package name,version_number is the version number.

To remove a package, you can use the remove command:

sudo apt remove mplayer

Find packages related to the name libimobile:

apt search libimobile

View information about the pinta package:

apt show pinta

List upgradable packages:

apt list --upgradeable

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

sudo apt autoremove

In the interactive prompt above, enter the letter Y to start the cleanup.