Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Process Inspection with ps, top, htop | Monitoring and Diagnostics
Linux Terminal Tools

bookProcess 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.

Note
Definition

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.

question mark

Which statement best describes the main differences between ps, top, and htop as discussed above?

Select the correct answer

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 1

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

bookProcess 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.

Note
Definition

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.

question mark

Which statement best describes the main differences between ps, top, and htop as discussed above?

Select the correct answer

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 1
some-alt