Back to commands

Linux Survival Basics

Read-only, can be slow

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

  1. ps -ef
  2. ps -ef | grep -E 'apt|dpkg|dnf|yum|pacman' | grep -v grep

next steps

Related commands

Linux Survival Basics Sensitive output

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

Find CRLF Lines in a Script

Find exactly which lines still contain carriage returns.

grep -n $'\r' script.sh | head
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 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'
Linux Survival Basics Can be slow

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

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.