Linux Cheatsheet
Package Managers
Use this Linux reference while you build software engineering projects, review code for technical interview prep, or polish examples for a software engineer resume.
apt — Debian / Ubuntu
apt update # refresh package index apt upgrade # upgrade all installed packages apt full-upgrade # upgrade + handle dependency changes apt install nginx # install package apt install nginx=1.24.* # install specific version apt remove nginx # remove (keep config) apt purge nginx # remove + delete config files apt autoremove # remove unused dependencies apt search "web server" # search available packages apt show nginx # show package details apt list --installed # list installed packages apt list --upgradable # list upgradable packages apt-cache policy nginx # show installed vs available versions dpkg -l nginx # check if installed dpkg -L nginx # list files installed by package dpkg -S /usr/bin/nginx # which package owns a file dpkg -i package.deb # install local .deb file
apt Sources
/etc/apt/sources.list # main sources list /etc/apt/sources.list.d/ # additional .list files add-apt-repository ppa:user/repo # add PPA (Ubuntu)
dnf — Fedora / RHEL 8+ / AlmaLinux
dnf update # update all dnf install nginx # install dnf remove nginx # remove dnf autoremove # remove unused dependencies dnf search nginx # search dnf info nginx # show package details dnf list installed # list installed dnf list available "http*" # search available dnf provides /usr/bin/nginx # which package owns file dnf history # transaction history dnf history undo 5 # undo transaction 5 dnf repolist # show enabled repos dnf config-manager --add-repo URL # add repo rpm -qa # list all installed RPMs rpm -ql nginx # list files in package rpm -qf /usr/bin/nginx # which RPM owns file rpm -ivh package.rpm # install local RPM
yum — RHEL 7 / CentOS 7
yum update yum install nginx yum remove nginx yum search nginx yum provides /usr/sbin/nginx yum info nginx yum repolist
dnf is a drop-in replacement for yum on modern systems.
zypper — openSUSE / SUSE
zypper refresh # update repo metadata zypper update # update all zypper install nginx # install zypper remove nginx # remove zypper search nginx # search zypper info nginx # show details zypper lr # list repos
pacman — Arch Linux / Manjaro
pacman -Syu # sync + upgrade all pacman -S nginx # install pacman -R nginx # remove pacman -Rs nginx # remove + orphaned deps pacman -Ss "web server" # search repos pacman -Si nginx # show package info pacman -Q # list installed pacman -Ql nginx # list files in package pacman -Qo /usr/bin/nginx # which package owns file pacman -Sc # clear package cache
AUR helpers (Arch only):
yay -S package # install from AUR paru -S package # alternative AUR helper
snap
snap install code --classic # install snap package snap remove code # remove snap list # list installed snaps snap find "text editor" # search snap info code # show details snap refresh # update all snaps snap refresh code # update specific snap
flatpak
flatpak install flathub org.gimp.GIMP flatpak uninstall org.gimp.GIMP flatpak list # list installed flatpak search gimp # search flatpak update # update all flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Cross-Distro Quick Reference
| Task | apt | dnf | pacman |
|---|---|---|---|
| Refresh index | apt update | dnf check-update | pacman -Sy |
| Install | apt install pkg | dnf install pkg | pacman -S pkg |
| Remove | apt remove pkg | dnf remove pkg | pacman -R pkg |
| Search | apt search term | dnf search term | pacman -Ss term |
| Who owns file | dpkg -S /path | dnf provides /path | pacman -Qo /path |
| Upgrade all | apt upgrade | dnf upgrade | pacman -Syu |
| List installed | dpkg -l | rpm -qa | pacman -Q |