sudo apt updateFetch the latest package lists. Do this first, or apt only knows about what was there last time.
Cheat sheet
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.
Nothing matches that. Try fewer words, or a shorter one.
sudo apt updateFetch the latest package lists. Do this first, or apt only knows about what was there last time.
sudo apt upgradeInstall every available update.
sudo apt full-upgradeInstall every update, even ones that need to add or remove other packages (new kernels often do).
sudo apt install htopInstall a package.
sudo apt install --no-install-recommends htopInstall just the package and what it strictly needs, without the "recommended" extras.
sudo apt remove htopUninstall a package but keep its config files, in case it comes back.
sudo apt purge htopUninstall a package and its config files.
sudo apt autoremoveClean out dependencies nothing needs any more.
apt search htopSearch the package names and descriptions.
apt show htopWhat a package is, its version, size and dependencies.
apt list --upgradableWhat updates are waiting.
apt policy htopWhich version is installed, which would be installed, and which repository it comes from.
dpkg -L htopEvery file an installed package put on disk.
dpkg -S /usr/bin/curlWhich installed package a file belongs to.
cat /var/run/reboot-requiredIf this file exists, an update wants a reboot.
sudo apt-mark hold htopFreeze a package at its current version, so updates leave it alone.
sudo apt-mark unhold htopLet it update again.
apt-mark showholdEverything that's being held back.
dnf check-updateWhat updates are waiting.
sudo dnf upgradeInstall every available update.
sudo dnf upgrade --securityInstall only the security fixes, on Rocky, Alma and RHEL.
sudo dnf install htopInstall a package.
sudo dnf remove htopUninstall a package.
sudo dnf autoremoveClean out dependencies nothing needs any more.
sudo dnf install epel-releaseTurn on EPEL, the big extra repository most Rocky and Alma servers end up needing.
dnf search htopSearch the package names and descriptions.
dnf info htopWhat a package is, its version and where it comes from.
dnf provides /usr/bin/curlWhich package provides a file, even one that isn't installed. Handy when a command is missing.
rpm -ql htopEvery file an installed package put on disk.
rpm -qf /usr/bin/curlWhich installed package a file belongs to.
dnf repolistWhich repositories are switched on.
sudo dnf needs-restarting -rWhether an update wants a reboot (from dnf-plugins-core).
dnf historyEvery install, update and removal, numbered.
sudo dnf history undo lastUndo the most recent one. Swap last for a number from the list to undo an older one.
sudo dnf versionlock add htopFreeze a package at its current version (needs the versionlock plugin: python3-dnf-plugin-versionlock).
sudo dnf versionlock delete htopLet it update again.