Linux Survival Basics
Read-only, can be slowFind Running Package Manager Processes
A package command reports a lock and you need to see whether apt, dpkg, dnf, yum, or pacman is still running.
Command
ps -ef | grep -E 'apt|dpkg|dnf|yum|pacman' | grep -v grep
Before you run this
System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.
When not to use it: Do not kill package processes from this list without checking what they are doing.
Expected output
Matching package-manager processes, or no output when none are obvious.
System impact
Read-only, can be slow. Nothing changes. The command reads current state and prints diagnostic evidence.
Scope this to the smallest useful path or service on busy systems.
Recovery / rollback: no state is changed.
When to use it
Use when a package operation says a lock is held.
When not to use it
Do not kill package processes from this list without checking what they are doing.
Example run
Commands shown
These are the commands shown for inspection. Treat them as an example, not proof that your system will behave identically.
ps -efps -ef | grep -E 'apt|dpkg|dnf|yum|pacman' | grep -v grep
next steps
Related commands
Find the dpkg Lock Owner
Find the process holding the dpkg lock before touching lock files.
sudo lsof /var/lib/dpkg/lock-frontend /var/lib/dpkg/lock 2>/dev/null
Find CRLF Lines in a Script
Find exactly which lines still contain carriage returns.
grep -n $'\r' script.sh | head
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 OOM Killer Lines in the Kernel Journal
Before restarting a service, prove whether the kernel killed it.
journalctl -k --since '24 hours ago' --no-pager | grep -iE 'out of memory|oom-killer|killed process'
Find the Processes Using Memory
The server felt slow. Memory pressure was the first thing to rule out.
ps -eo pid,comm,%mem,%cpu --sort=-%mem | head
next diagnostic step
Where to go from this command
- Package lock held hub Use this as the first package-lock check.
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.