ps — view running processes
A command that checks currently running processes. Examples include aux/-ef combinations, sorting by memory, checking processes, and execution screens.
💬 "ps command"
- Concept: Shows the list of processes currently running on the server. You need to know the PID to terminate them with
kill. - Output structure: The columns vary depending on the options. By convention,
ps auxorps -efis commonly used. - Recommended output for practical use: If you want to see only the columns you need, select and output them like
ps -eo pid,user,%mem,cmd. - PID column: This is the process number. It is the value used when running
kill. - %MEM / %CPU columns: These are memory and CPU usage. Sort in descending order with
--sort=-%mem.
3 Essential Command Combinations
ps aux— View all processes with user, CPU, and memory usageps -ef— View processes including the parent PID (PPID)ps aux | grep nginx— View only a specific process
Here are some options worth knowing as well.
--sort=-%mem— Sort by memory usage in descending order- For periodic checks,
toporhtopis convenient.
💬 "Make an example based on a situation beginners often encounter"
Scenario: The process of checking how many web server processes are running.
Step 1: Search for processes
Find processes related to nginx.
ps -ef | grep nginx
Step 2: Count the processes
Count the number of workers.
ps -ef | grep nginx | grep -v grep | wc -l
Step 3: Check the parent process
Check the master process PID.
ps -eo pid,ppid,cmd | grep nginx
Actual Output
This is an example screenshot of viewing processes with ps aux.
!ps command execution result: PID, user, CPU and memory usage, command
Actual production server
Source (HTML): https://games.aidebatehub.com/programs/linux/services/ps.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments