Linux and Shell Programming

0 of 30 lessons complete (0%)

Module 5 Processes

Process Management Tools

TOP and HTOP Commands

top Command:

  • The top command provides a dynamic view of system processes, continuously updating in real-time.
top
  • It displays a list of active processes with details like PID, CPU usage, memory usage, etc.

htop Command:

  • htop is an enhanced alternative to top with a more user-friendly interface.
htop
  • It provides a visually appealing display of processes and their resource utilization.

Process Management Utilities

kill Command:

  • The kill command is used to send signals to processes.
# Terminate a process by PID 
kill <PID> 
# Send SIGTERM (termination) signal to a process 
kill -15 <PID> 
# Send SIGKILL (forceful termination) signal to a process 
kill -9 <PID>

killall Command:

  • The killall command sends a signal to all processes with a specific name.
killall <process-name>

pstree Command

  • The pstree command displays the processes in a tree format, showing their hierarchical relationship.
pstree
  • This command provides a visual representation of the parent-child relationships among processes.

pgrep and pkill Commands

pgrep Command:

  • The pgrep command allows you to search for processes by their name.
pgrep <process-name>
  • It returns the PID(s) of processes that match the specified name.

pkill Command:

  • The pkill command is used to send signals to processes based on their name.
pkill <process-name>
  • This command sends a signal to all processes whose names match the specified pattern.

Nice and Renice Commands

nice Command:

  • The nice command is used to launch a process with a specified priority (niceness).
nice -n <priority> <command>

renice Command:

  • The renice command is used to change the priority of an existing process.
renice <priority> -p <PID>

These tools and commands provide powerful capabilities for managing processes in a Unix environment. They allow users to monitor, terminate, and adjust process priorities as needed.