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
- Use `ps aux` for a comprehensive list:
- Open a terminal (Ctrl+Alt+T on most Linux desktops).
- Type:
ps aux - Press Enter. This shows ALL running processes with details like user, CPU/memory usage, and PID (Process ID).
- Filter by name: Use grep for specific apps (e.g., grep "nginx" to find Nginx servers). Example:
ps aux | grep chromeshows Chrome processes.
- Use `top` or `htop` for real-time monitoring:
- Install `htop` if missing (most Linux systems include it; otherwise, run
sudo apt install htopon Debian/Ubuntu). - Run:
top - Observe the live table—CPU, memory, and process details sort dynamically. Press
Shift+Gto focus on the process with the highest CPU usage. - Exit with
Ctrl+Corq.
- Install `htop` if missing (most Linux systems include it; otherwise, run
- Find processes by user:
- Use:
ps aux | grep -E "username"(replace "username" with the actual name). - Or for system-wide users:
ps aux | awk '$1 ~ /^[a-zA-Z]+$/'
- Use:
- Search for a specific process type:
- Example: Find all SSH sessions:
ps aux | grep sshd - Or find processes using a port (e.g., port 80 for web servers):
ss -tulnp | grep ':80'
- Example: Find all SSH sessions:
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 PIDis 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) orAlt+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:
- Terminal issues: If `ps` or `top` hangs, try restarting the terminal (Ctrl+D). If the problem persists, check for terminal corruption with:
resetor rebooting. - Permission denied: Run commands as root (temporarily) with:
sudo ps aux. For persistent access, grant permissions via:chmod +x /path/to/script(if applicable). - No output from commands:
- Check if the service is actually running:
systemctl status service_name - Verify the command exists:
which ps
- Check if the service is actually running:
- Stuck processes:
- Use `fuser` to identify locked files:
fuser -v /path/to/file - For stubborn processes, try:
sudo lsof | grep PIDto see associated files.
- Use `fuser` to identify locked files:
- 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`.