APT

Advanced Package Tool

apt

apt-get

apt install package

apt remove package

apt purge package

apt update

apt upgrade

apt autoremove

apt full-upgrade

apt-get install package

apt-get remove package

apt-get purge package

apt-get update

apt-get upgrade

apt-get autoremove

apt-get dist-upgrade

Install

Remove

Purge

Refreshes repository index

Upgrades all upgradable packages

Removes unwanted packages

Upgrades with auto dependencies

apt update

The first column in the output shows: Hit, Ign, or GetHit means there is no change.Ign means the package is ignored. Get means there is a new version and the package information will be updated.

upgrade vs full-upgrade

full-upgrade will remove installed packages if necessary, upgrade will not.

remove vs purge

remove removes the binaries of a package but leaves residue configuration files.purge removes everything related to a package including the configuration files.

apt-cache

apt search file

apt show

apt list

apt list --installed

apt edit-sources

apt-cache search file

apt-cache show




Search for package that provides file

Shows package details

Lists packages with installed status

Lists installed packages

Edits sources list

Examples

To check if a package is installed...

apt list --installed | grep packageName

add-apt-repository

Manages Personal Package Archives (PPA)

add-apt-repository ppa:user/ppa-name

add-apt-repository -r ppa:user/ppa-name

Repositories are added into /etc/apt/sources.list or /etc/apt/sources.list.d

Add repository

Remove repository

The add-apt-repository command is provided by the software-properties-common package.
sudo apt install software-properties-common

Examples

sudo add-apt-repository ppa:appimagelauncher-team/stable

apt.systemd.daily

You may try to install a package and get an error similar to this...

E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?

In the output of ps -ef you see...

root      3610     1  0 09:41 ?        00:00:00 /bin/sh /usr/lib/apt/apt.systemd.daily installroot      3614  3610  0 09:41 ?        00:00:00 /bin/sh /usr/lib/apt/apt.systemd.daily lock_is_held install

This means you need to wait until the scheduled daily apt download activities are finished before you can install extra packages. You can get more information with...

journalctl -u apt-daily.service

Also try this...

systemd-analyze blame

systemd-analyze time

If you get ...

Bootup is not yet finished. Please try again later.

... then it may be worth rebooting again. i.e. something in the boot process may have failed. If it fails again on reboot then further investigation is warranted.

Bibliography