Process Inspection with ps, top, htop
Process management is a core responsibility for anyone using Linux, especially developers and DevOps professionals. Monitoring running processes helps you diagnose performance issues, spot misbehaving applications, and ensure system health. You rely on process inspection tools to identify resource hogs, troubleshoot failures, and understand what is happening on your system at any moment. The ability to effectively inspect and monitor processes is critical for maintaining stable, responsive environments and for debugging problems rapidly.
# List all processes for the current user with custom columns
ps -u $USER -o pid,ppid,cmd,%mem,%cpu
# List all processes for the user 'www-data'
ps -u www-data -o pid,cmd
# List all processes, filter by command name 'sshd'
ps -ef | grep sshd
When you use the ps command to inspect processes, the output columns provide key information:
- PID: process ID, a unique number for each running process;
- PPID: parent process ID, showing which process started the current one;
- CMD or COMMAND: the command used to start the process;
- %CPU: the percentage of CPU the process is using;
- %MEM: the percentage of memory being used;
- USER: the owner of the process.
Common ps options include -ef, which lists every process in full-format, and -u, which filters processes by user. You can combine these with custom output columns using -o to tailor the information for your needs.
Foreground processes are those you launch directly from your terminal and interact with until they finish or are suspended. Background processes, on the other hand, run independently of your terminal session and do not block your shell. In ps, top, and htop, both types appear in the process list, but foreground processes may be associated with your current terminal (TTY), while background processes often are not.
# Start the top command for real-time process monitoring
top
# If installed, start htop for an enhanced interactive view
htop
Both top and htop provide interactive, real-time process monitoring, but they differ in usability and features. top is available on nearly all Linux systems and displays a dynamic list of processes sorted by resource usage, allowing you to kill or renice processes by entering their PID. Navigation in top is keyboard-driven, but its interface is less intuitive.
htop offers a more user-friendly, colorful interface with easier navigation using arrow keys and function keys. It supports mouse interactions, allows you to sort by any column with a single keystroke, and provides a clearer overview of CPU and memory usage. While htop must be installed separately on some systems, it is favored for its ease of use and enhanced visualization compared to top.
¡Gracias por tus comentarios!
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Genial!
Completion tasa mejorada a 8.33
Process Inspection with ps, top, htop
Desliza para mostrar el menú
Process management is a core responsibility for anyone using Linux, especially developers and DevOps professionals. Monitoring running processes helps you diagnose performance issues, spot misbehaving applications, and ensure system health. You rely on process inspection tools to identify resource hogs, troubleshoot failures, and understand what is happening on your system at any moment. The ability to effectively inspect and monitor processes is critical for maintaining stable, responsive environments and for debugging problems rapidly.
# List all processes for the current user with custom columns
ps -u $USER -o pid,ppid,cmd,%mem,%cpu
# List all processes for the user 'www-data'
ps -u www-data -o pid,cmd
# List all processes, filter by command name 'sshd'
ps -ef | grep sshd
When you use the ps command to inspect processes, the output columns provide key information:
- PID: process ID, a unique number for each running process;
- PPID: parent process ID, showing which process started the current one;
- CMD or COMMAND: the command used to start the process;
- %CPU: the percentage of CPU the process is using;
- %MEM: the percentage of memory being used;
- USER: the owner of the process.
Common ps options include -ef, which lists every process in full-format, and -u, which filters processes by user. You can combine these with custom output columns using -o to tailor the information for your needs.
Foreground processes are those you launch directly from your terminal and interact with until they finish or are suspended. Background processes, on the other hand, run independently of your terminal session and do not block your shell. In ps, top, and htop, both types appear in the process list, but foreground processes may be associated with your current terminal (TTY), while background processes often are not.
# Start the top command for real-time process monitoring
top
# If installed, start htop for an enhanced interactive view
htop
Both top and htop provide interactive, real-time process monitoring, but they differ in usability and features. top is available on nearly all Linux systems and displays a dynamic list of processes sorted by resource usage, allowing you to kill or renice processes by entering their PID. Navigation in top is keyboard-driven, but its interface is less intuitive.
htop offers a more user-friendly, colorful interface with easier navigation using arrow keys and function keys. It supports mouse interactions, allows you to sort by any column with a single keystroke, and provides a clearer overview of CPU and memory usage. While htop must be installed separately on some systems, it is favored for its ease of use and enhanced visualization compared to top.
¡Gracias por tus comentarios!