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.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ apt policy nginx
nginx:
Installed: 1.24.0-2ubuntu7.3
Candidate: 1.24.0-2ubuntu7.4
Version table:
1.24.0-2ubuntu7.4 500
500 http://example.com/ubuntu noble-updates/main amd64 Packages
*** 1.24.0-2ubuntu7.3 100
100 /var/lib/dpkg/status
$ apt policy openssl
openssl:
Installed: 3.0.13-0ubuntu3.5
Candidate: 3.0.13-0ubuntu3.6
Version table:
3.0.13-0ubuntu3.6 500
500 http://example.com/ubuntu noble-security/main amd64 Packages
*** 3.0.13-0ubuntu3.5 100
100 /var/lib/dpkg/status
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
apt policy nginxapt policy openssl
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
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
Find the Exact Log Line Before You Scroll
The error was there. The useful part was knowing exactly where it was.
grep -inE 'error|failed|denied|timeout' /var/log/nginx/error.log
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.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.