Linux & shell: Package & software versions (any distro)
29 Linux & shell commands: Package & software versions (any distro). Click a command to see what each part does.
- Whole sheet251
- Navigate & list13
- Create, copy, move, delete13
- View & compare files9
- Permissions & ownership31
- Help & shell basics11
- Users & groups6
- Install packages7
- Package & software versions29
- System info9
- Network basics & SSH10
- Zip & compress4
- Shell operators6
- Processes6
- Files & search8
- Text processing pipelines4
- Disk3
- Network5
- Services & logs6
- Archives & copying4
- Firewall7
- Scheduling: cron & systemd timers6
- Storage, mounts & LVM10
- Kernel, hardware & limits8
- Performance & tracing10
- TLS & certificates8
- Packet capture & network debugging10
- Terminal tools8
Package & software versions (any distro)29
hostnamectlOS, version and kernel in one viewWhat each part does
hostnamectlhostname, operating system and version, kernel, architecture, virtualization (systemd systems)
<program> --versionVersion of any programWhat each part does
<program> --versionmost tools print their version; some use -v or -V (nginx -v, java -version, python3 -V)
dpkg -S "$(command -v <program>)"Where is a command, and which package installed it? (Debian / Ubuntu)What each part does
command -v <program>full path of the program the shell would rundpkg -S <path>the package that owns that file
rpm -qf "$(command -v <program>)"Which package installed a command? (RHEL / Fedora / Amazon Linux)What each part does
command -v <program>full path of the programrpm -qf <path>package (name-version-release) that owns that file
dpkg-query -W -f='${Package} ${Version} ${Status}\n' <package>Installed version of one package (Debian / Ubuntu)What each part does
dpkg-query -Wshow installed package info-f='${Package} ${Version} ${Status}\n'output format: name, version, install status<package>package name; wildcards work, e.g. 'openssl*'
apt-cache policy <package>Installed vs available version (Debian / Ubuntu)What each part does
apt-cache policyInstalled: version now, Candidate: what apt install/upgrade would get, plus the version table per repo<package>package name
apt list -a <package>All versions the repos offer (Debian / Ubuntu)What each part does
apt list -aevery available version, marked [installed] / [upgradable]
sudo apt update && apt list --upgradablePackages with updates available (Debian / Ubuntu)What each part does
apt updaterefresh package lists first, or the answer is staleapt list --upgradableinstalled packages with a newer version: name, new version, [upgradable from: old]
dpkg-query -W -f='${Package}\t${Version}\n' | sortEvery installed package with its version (Debian / Ubuntu)What each part does
dpkg-query -W -f='...'name TAB version for every installed package| sortalphabetical; redirect to a file to diff two servers
rpm -q <package>Installed version of one package (RHEL / Fedora / Amazon Linux / SUSE)What each part does
rpm -q <package>name-version-release.arch, or 'package ... is not installed'
rpm -qi <package>Details of an installed package (RHEL family)What each part does
rpm -qiversion, release, install date, vendor, build date, summary
dnf list --showduplicates <package>Installed and available versions (RHEL / Fedora)What each part does
dnf listInstalled Packages section and Available Packages section--showduplicatesevery available version, not just the newest (to pick one to install or downgrade)
dnf check-updatePackages with updates available (RHEL / Fedora)What each part does
dnf check-updatelist pending updates; exit code 100 means updates exist, 0 means none (yum check-update on older systems)
dnf updateinfo list --securityPending security updates only (RHEL / Fedora)What each part does
dnf updateinfo listadvisories for available updates--securityonly security fixes, with severity and advisory ID
rpm -qa --last | head -30Every installed package, newest installs first (RHEL family)What each part does
rpm -qaall installed packages--lastsorted by install/update time, newest first, with the date| head -30the 30 most recent
dnf history; dnf history info <id>What changed recently? (RHEL / Fedora)What each part does
dnf historyevery install/upgrade/remove transaction with date and userdnf history info <id>exact packages and versions in that transaction; dnf history undo <id> reverts it
grep -E ' (install|upgrade) ' /var/log/dpkg.logWhat was installed or upgraded recently? (Debian / Ubuntu)What each part does
grep -E ' (install|upgrade) 'only install and upgrade lines (date, package, old and new version)/var/log/dpkg.logdpkg's log; older months are in dpkg.log.1 and .gz files (zgrep)
apk info -v <package>; apk policy <package>Installed version of one package (Alpine)What each part does
apk info -v <package>installed name-versionapk policy <package>installed and available versions per repository
apk update && apk version -l '<'Packages with updates available (Alpine)What each part does
apk updaterefresh the indexapk version -l '<'only packages whose installed version is older than the repo's
zypper info <package>Installed version of one package (SUSE)What each part does
zypper infoversion, repository, installed status of a package
snap list; flatpak list --columns=application,versionSnap and Flatpak packages with versionsWhat each part does
snap listsnaps: name, version, revision, channelflatpak list --columns=...flatpak apps and their versions
python3 -m pip list; python3 -m pip show <package>Python packages and versionsWhat each part does
python3 -m pip listevery package in this Python environment with its version (add --outdated for updates)pip show <package>version, location and dependencies of one package
node --version; npm ls -g --depth=0Global Node.js packages and versionsWhat each part does
node --versionNode.js versionnpm ls -g --depth=0globally installed npm packages, top level only
ldd --version | head -1; openssl version -a | head -2Core library versions (glibc, OpenSSL)What each part does
ldd --versionthe C library (glibc) version; matters for binary compatibility and CVEsopenssl version -aOpenSSL version and build date
sudo apt install <package>=<version>Install a specific version (Debian / Ubuntu)CautionWhat each part does
<package>=<version>exact version from apt list -a; add --allow-downgrades to go back
sudo dnf install <package>-<version>Install a specific version (RHEL / Fedora)CautionWhat each part does
<package>-<version>exact version from dnf list --showduplicates; dnf downgrade to go back
sudo apt-mark hold <package>; sudo dnf versionlock add <package>Stop a package from being upgradedWhat each part does
apt-mark holdDebian / Ubuntu: keep the current version (apt-mark unhold to release)dnf versionlock addRHEL / Fedora: same idea (needs the versionlock plugin)
dnf provides '*/<file>'; apt-file search <file>Which package provides a file you don't have?What each part does
dnf provides '*/<file>'RHEL family: packages containing that fileapt-file search <file>Debian / Ubuntu (install apt-file and run apt-file update first)
ansible all -i <inventory> -m shell -a "rpm -q <package> 2>/dev/null || dpkg-query -W <package>"Check a package version across many serversWhat each part does
ansible all -i <inventory>every host in the inventory-m shell -a "..."run the command on each onerpm -q <package> || dpkg-query -W <package>works on both RHEL- and Debian-family hosts
Tip Without Ansible: for h in <host1> <host2>; do echo "$h: $(ssh $h 'rpm -q <package> 2>/dev/null || dpkg-query -W <package>')"; done
Nothing matches.
My DevOps Playbook by Angelo John Calleja