The simplest way to find running processes in Linux is with the `ps` or `top` commands—no extra tools or permissions needed. These commands show every active process, letting you identify stuck apps, resource hogs, or even malicious activity. For quick checks, `ps aux` is the fastest; for live performance monitoring, `top` or `htop` provide real-time insights. Always back up your system before force-closing critical processes, and ensure you have the right permissions if modifying them.

What You'll Need

  • A Linux command-line terminal (most distributions include it by default)
  • Basic familiarity with keyboard shortcuts (e.g., arrow keys, Ctrl+C to interrupt)
  • Optional: A text editor or clipboard tool to save process details (for later review)

Step-by-Step

  1. Use `ps aux` for a comprehensive list:
    1. Open a terminal (Ctrl+Alt+T on most Linux desktops).
    2. Type: ps aux
    3. Press Enter. This shows ALL running processes with details like user, CPU/memory usage, and PID (Process ID).
    4. Filter by name: Use grep for specific apps (e.g., grep "nginx" to find Nginx servers). Example: ps aux | grep chrome shows Chrome processes.
  2. Use `top` or `htop` for real-time monitoring:
    1. Install `htop` if missing (most Linux systems include it; otherwise, run sudo apt install htop on Debian/Ubuntu).
    2. Run: top
    3. Observe the live table—CPU, memory, and process details sort dynamically. Press Shift+G to focus on the process with the highest CPU usage.
    4. Exit with Ctrl+C or q.
  3. Find processes by user:
    1. Use: ps aux | grep -E "username" (replace "username" with the actual name).
    2. Or for system-wide users: ps aux | awk '$1 ~ /^[a-zA-Z]+$/'
  4. Search for a specific process type:
    1. Example: Find all SSH sessions: ps aux | grep sshd
    2. Or find processes using a port (e.g., port 80 for web servers): ss -tulnp | grep ':80'

Common Mistakes

  • Misinterpreting PID (Process ID): The PID in `ps aux` is critical for killing processes. If you use the wrong PID, you may crash other apps or services. Double-check with `pgrep`: pgrep -fl "process_name" to confirm the exact PID.
  • Running as root without cause: Killing critical system processes (e.g., `systemd`) can destabilize your system. Always confirm permissions before force-quitting. sudo kill -9 PID is last resort.
  • Overlooking user privileges: Some processes (like `systemd`) require root access. Use `sudo ps aux` only if necessary.
  • Ignoring resource leaks: A single long-running process (e.g., a buggy app) can drain all CPU/memory. Monitor with `top` or `htop` for signs of degradation.

Tips

  • Shortcut for quick checks: Press Ctrl+Shift+P (GNOME) or Alt+F2 + type "top" to launch instantly.
  • Save process lists: Redirect output to a file for later review: ps aux > running_processes.txt
  • Use `pstree` for hierarchy: Visualize process relationships: pstree -p
  • Check startup services: For services like Apache or MySQL, use: systemctl list-units --type=service
  • Avoid `killall` unless necessary: It forces close ALL instances of a process. Prefer killing by PID to prevent side effects: kill -9 PID

Troubleshooting

If processes refuse to show or behave unexpectedly:

  1. Terminal issues: If `ps` or `top` hangs, try restarting the terminal (Ctrl+D). If the problem persists, check for terminal corruption with: reset or rebooting.
  2. Permission denied: Run commands as root (temporarily) with: sudo ps aux. For persistent access, grant permissions via: chmod +x /path/to/script (if applicable).
  3. No output from commands:
    1. Check if the service is actually running: systemctl status service_name
    2. Verify the command exists: which ps
  4. Stuck processes:
    1. Use `fuser` to identify locked files: fuser -v /path/to/file
    2. For stubborn processes, try: sudo lsof | grep PID to see associated files.
  5. System freezes: If the system locks up, force-reboot instead of killing systemd processes. Use a physical button or: sudo systemctl isolate multi-user.target (last resort).

Frequently Asked Questions

How do I kill a process if `ps` shows only PID?

Run: sudo kill -9 PID (Replace PID with the exact number from `ps aux` or `pgrep`.) Use `-9` only if the process won’t respond to `kill 15` (SIGTERM).

Why can’t I find my Chrome process in `ps aux`?

Chrome may run as a service or in the background. Use: ps aux | grep chrome or check: systemctl status chromium if installed as a service.

How do I see memory usage by process?

Use `ps aux` and note the third column (RAM usage, in KB). For precise numbers, pipe to `awk`: ps aux | awk '{print $3 + $4}' | sort -nr (Columns 3–4 = CPU + memory usage.)

What’s the difference between `ps` and `top`?

ps aux provides a static snapshot. top (or htop) shows real-time updates, sorting processes by CPU/memory.

How do I find processes using a specific port?

Use: ss -tulnp | grep ':PORT_NUMBER' (Replace PORT_NUMBER with the port number, e.g., 22 for SSH.)

Can I list processes without root?

Yes! Use: ps aux or: top for most user-level tasks. System-level processes (e.g., `nginx`) require root for `kill`.