Linux Survival Basics
Read-onlyCheck the Installed and Candidate Package Version
A package has an update available, and you need to see the installed version, candidate version, and repository source.
Command
apt policy nginx
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not use it as proof the service is running; package state and service state are separate.
Expected output
Installed and candidate package versions with version table entries.
System impact
Read-only. Nothing changes. apt prints installed and candidate versions plus repository priority lines.
Recovery / rollback: no state is changed.
When to use it
Use when a package version looks wrong, a security pocket matters, or a host is pinned to an older package.
When not to use it
Do not use it as proof the service is running; package state and service state are separate.
next steps
Related commands
See Which Packages Want Updates
Before you upgrade anything, list what would move.
apt list --upgradable
Find Which Package Owns a File
That binary came from somewhere. dpkg can tell you where.
dpkg-query -S /usr/sbin/nginx
Find Running Package Manager Processes
A package lock is usually a symptom, not the first thing to delete.
ps -ef | grep -E 'apt|dpkg|dnf|yum|pacman' | grep -v grep
Check One Installed Package Cleanly
For one package, dpkg-query gives a clean status line.
dpkg-query -W -f='${Status} ${Version}\n' openssl
Find Errors Before Reading Every Log Line
The error was in the log. The problem was finding it without reading noise.
grep -iE 'error|failed|denied|timeout' /var/log/nginx/error.log | tail -40
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.