All cheat sheets

Cheat sheet

Packages with apt and dnf

Installing, updating and removing software on Debian and Ubuntu (apt) and on Fedora, Rocky and RHEL (dnf, the new yum).

Nothing you type here is sent. Nothing is saved, unless you switch on Remember. Privacy policy

On RHEL, Rocky and Alma 8 and later, yum is just another name for dnf, so every dnf command below also works with yum. On older CentOS 7 boxes, use yum.

Debian and Ubuntu: everyday

sudo apt update

Fetch the latest package lists. Do this first, or apt only knows about what was there last time.

sudo apt upgrade

Install every available update.

sudo apt full-upgrade

Install every update, even ones that need to add or remove other packages (new kernels often do).

sudo apt install htop

Install a package.

sudo apt install --no-install-recommends htop

Install just the package and what it strictly needs, without the "recommended" extras.

sudo apt remove htop

Uninstall a package but keep its config files, in case it comes back.

sudo apt purge htop

Uninstall a package and its config files.

sudo apt autoremove

Clean out dependencies nothing needs any more.

Debian and Ubuntu: finding out

apt search htop

Search the package names and descriptions.

apt show htop

What a package is, its version, size and dependencies.

apt list --upgradable

What updates are waiting.

apt policy htop

Which version is installed, which would be installed, and which repository it comes from.

dpkg -L htop

Every file an installed package put on disk.

dpkg -S /usr/bin/curl

Which installed package a file belongs to.

cat /var/run/reboot-required

If this file exists, an update wants a reboot.

Debian and Ubuntu: holding back

sudo apt-mark hold htop

Freeze a package at its current version, so updates leave it alone.

sudo apt-mark unhold htop

Let it update again.

apt-mark showhold

Everything that's being held back.

Fedora, Rocky and RHEL: everyday

dnf check-update

What updates are waiting.

sudo dnf upgrade

Install every available update.

sudo dnf upgrade --security

Install only the security fixes, on Rocky, Alma and RHEL.

sudo dnf install htop

Install a package.

sudo dnf remove htop

Uninstall a package.

sudo dnf autoremove

Clean out dependencies nothing needs any more.

sudo dnf install epel-release

Turn on EPEL, the big extra repository most Rocky and Alma servers end up needing.

Fedora, Rocky and RHEL: finding out

dnf search htop

Search the package names and descriptions.

dnf info htop

What a package is, its version and where it comes from.

dnf provides /usr/bin/curl

Which package provides a file, even one that isn't installed. Handy when a command is missing.

rpm -ql htop

Every file an installed package put on disk.

rpm -qf /usr/bin/curl

Which installed package a file belongs to.

dnf repolist

Which repositories are switched on.

sudo dnf needs-restarting -r

Whether an update wants a reboot (from dnf-plugins-core).

Fedora, Rocky and RHEL: undo and hold

dnf history

Every install, update and removal, numbered.

sudo dnf history undo last

Undo the most recent one. Swap last for a number from the list to undo an older one.

sudo dnf versionlock add htop

Freeze a package at its current version (needs the versionlock plugin: python3-dnf-plugin-versionlock).

sudo dnf versionlock delete htop

Let it update again.

Remember your blanks on this device?

Everywhere else on this site, what you type is forgotten the moment you leave the page. If you switch this on: