Back to commands

Linux Survival Basics

Read-only

Check 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.

demo@lab:~$

$ 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

  1. apt policy nginx
  2. apt policy openssl

next steps

Related commands

Linux Survival Basics Read-only

Find Which Package Owns a File

That binary came from somewhere. dpkg can tell you where.

dpkg-query -S /usr/sbin/nginx
Linux Survival Basics Can be slow

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
Linux Survival Basics Can be slow

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.

  • lpic1:102-package-management
  • lpic1:103-gnu-unix-commands
  • lfcs:essential-commands
  • lfcs:operations-deployment
  • linuxplus:provisional
  • linuxplus:system-management
  • risk:read-only

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.