Every time a program or command is run, a process is created for it. These processes are all unique and identified by the process identification (PID) that becomes allocated to it. Management of processes can help keep the system stable or help when the system becomes unstable. Here are some of the process management commands you use:
ps Displays information about running processes
kill Terminates a process
pgrep Finds a process based on its PID
pidof Displays all processes related to service or command
top Monitors system resources
renice Adjust the priority of a particular process
1. View Root Processes
To view process with more detailed information of the processes the root user currently owns, you can use the “ps u” command. Here, you see not only the PID, but also the CPU and memory utilization. A common set of options that usually use when working with the ps command is aux combined with the grep command to get detailed information about a particular process.
2. Terminate The Process
To terminate a process, we need to know the PID of the process. For example, if you want to stop the SSH service because it isn’t responding, you just have to look for the PID associated with the SSH daemon. As you can see, the PID of SSH service is 2162. To kill the process forcefully and effectively stop the SSH service, you can do the following:
# kill 2162
There are two more other commands you can use to determine the PID(s) of a service or command.
3. View System Process
With the top command you will have an overview of processes on the system, including memory usage, CPU utilization, and more.
4. Change The Priority Of Process
You can use the renice command to give that particular process higher priority on the CPU. The priority values range from -20 (first priority) to 20 (dead last priority). Only the root user may set processes to use a priority under 0. For example, I change the priority of SSH service from 0 (default) to -2.
Have fun!