Process management in Linux involves monitoring and controlling the execution of processes on a system. Here’s a deeper dive into key concepts and commands:
ps (Process Status):
Purpose: Displays information about active processes.
Common Options:
-e or -A: Show all processes.-f: Full format listing, including command line arguments.aux: Combined options for detailed output.Examples:
ps -e # List all processes
ps -ef # Full format listing
ps aux # Detailed process information
top:
Navigation: Use arrow keys to scroll, q to quit.
top # Open the top command interface
htop:
top with a user-friendly interface.Installation: May need to be installed via package manager (e.g., sudo apt install htop).
htop # Open the htop command interface
kill:
SIGTERM (15): Graceful termination (default).SIGKILL (9): Forceful termination (non-catchable).kill PID # Send default SIGTERM to process with PID
kill -9 PID # Forceful termination using SIGKILL
kill 1234 # Terminate process with PID 1234
pkill:
pkill [options] name
-f: Match against the full command line.pkill firefox # Terminate all processes with the name 'firefox'
nice and renice:
nice: Starts a new process with a specified priority.
nice -n priority command
nice -n 10 myscript.sh # Start 'myscript.sh' with priority 10
renice: Changes the priority of an existing process.
renice -n priority -p PID
renice -n 5 -p 1234 # Change the priority of process with PID 1234 to 5
ps or top commands.Parent Process ID (PPID): Identifier of the parent process that spawned a process.
R (Running): Process is currently executing.S (Sleeping): Process is waiting for an event.Z (Zombie): Process has finished execution but still has an entry in the process table.T (Stopped): Process has been stopped (e.g., by a signal).Understanding these tools and concepts allows you to effectively monitor, manage, and control processes on a Linux system, ensuring optimal performance and resource utilization.
Go back to topics page [[Linux Basics]].