Sobes.tech
Junior

How do you find a running process?

sobes.tech AI

Answer from AI

# Find a process by name (e.g., nginx)
ps aux | grep <process_name>

# Find a process by PID
ps aux | grep <PID>

# Find a process run by a specific user
ps -u <username>

# Display the full list of processes in a tree with subprocesses
pstree -ap

# A more convenient interactive process viewer
# Install htop if it is not installed
htop

# Filter processes in htop by name or PID
# (search function is often available after startup)

You can find a running process in several ways, depending on what is known about it (name, PID, user) and your preferred interaction method (command line or interactive monitor).

Main command-line tools:

  • ps: Utility for viewing the list of running processes. Different options (aux, ef) provide various information.
  • grep: Used to filter the output of ps based on a pattern (process name, PID, user).
  • pgrep: A utility specifically designed to find the PID of a process by its name or other criteria. More convenient than ps | grep.
  • pstree: Displays processes in a tree structure, showing parent and child processes.
  • htop: An interactive process monitor that provides a more visual overview of CPU load, memory, running processes, their PIDs, and launch commands. Often more user-friendly for analysis and search than command-line utilities.

Usage examples:

# Find the PID of a process named "nginx"
pgrep nginx

# Find processes containing "docker" in their name and display full information
ps aux | grep docker

# Find all processes of the user "www-data"
ps -u www-data