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.

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

  • LPIC-1 style command-line practice
  • LFCS style performance-task practice
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.