Easy Tutorial
❮ Linux Shell Basic Operators Linux Comm Jed ❯

Linux apt Command

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

The apt command provides commands to find, install, upgrade, and remove individual, multiple, or all packages, with concise and memorable commands.

The apt command requires superuser (root) privileges to execute.

apt Syntax

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

Common apt Commands

Examples

Check for available updates:

sudo apt update

Upgrade packages:

sudo apt upgrade

Enter Y to start the upgrade during the interactive prompt.

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 remember the full package name, you can enter the first part and press Tab to list related packages.

In the example above, entering reds and pressing Tab lists four related packages.

To install a package without upgrading it if it already exists, use the --no-upgrade option:

sudo apt install <package_name> --no-upgrade

Install mplayer without upgrading if it exists:

sudo apt install mplayer --no-upgrade

To upgrade without installing, use the --only-upgrade option:

sudo apt install <package_name> --only-upgrade

Upgrade mplayer only, without installing if it doesn't exist:

sudo apt install mplayer --only-upgrade

To specify a version, use the following syntax:

sudo apt install <package_name>=<version_number>

packagename is the package name, and versionnumber is the version number.

Remove a package using the remove command:

sudo apt remove mplayer

Search for packages related to libimobile:

apt search libimobile

Show information about the pinta package:

apt show pinta

List updatable packages:

apt list --upgradeable

Clean up unused dependencies and library files:

sudo apt autoremove

Enter Y to start the cleanup during the interactive prompt.

❮ Linux Shell Basic Operators Linux Comm Jed ❯