Table of Contents
Certainly! Managing processes in Linux involves using various commands such as ps, kill, and nice. Here’s a guide on how to use them:
1. ps – Process Status
The ps command is used to display information about currently running processes.
- List all processes:
ps aux - List processes for a specific user:
ps -u username - Show detailed process information:
ps -ef
2. kill – Terminate Processes
The kill command is used to terminate or send signals to processes.
- Terminate a process by PID (Process ID):
kill PID - Send a specific signal to a process:
kill -SIGNAL PIDCommon signals:
SIGTERM(15): Terminate (default signal)SIGKILL(9): Force termination
- Kill all processes owned by a user:
pkill -u username
3. nice – Set Process Priority
The nice command is used to launch a process with a specified priority.
- Launch a process with a specific niceness level:
nice -n priority_level commandNiceness levels range from -20 (highest priority) to 19 (lowest priority). The default is 0.
Examples:
- List all processes and their details:
ps aux - Terminate a process with PID 1234:
kill 1234 - Launch a process with increased priority:
nice -n -10 command
Remember to exercise caution when terminating processes, especially with SIGKILL, as it forcefully terminates a process and may lead to data corruption. Use SIGTERM whenever possible for a graceful termination. Adjusting process niceness can help manage system resource allocation.