The operating system completes tasks one by one through processes, which are the basic units of managing transactions. Processes have their own independent processing environment and system resources. In the Linux system, if there are too many processes, it will occupy system resources, thus causing unnecessary trouble, then we need to close the process, so how does Linux shut down the process?Here's how to do it.
1. Check the process
Before shutting down a process, we must first look at the running process. We can use the following command:
1. ps command.
The ps command can display all processes of the current user, including the process ID, process startup time, and CPU utilization. The commonly used command options are as follows:
ps -ef: displays all process information.
ps -aux: Displays information about all processes, including those of other users.
ps -u username: displays the process information of the specified user.
2. Top command.
The top command displays the processes that are running on the system in real time, including process IDs, CPU usage, and memory usage. The commonly used command options are as follows:
top: displays the current process information in real time.
Top -p PID: displays the information about the specified process ID.
2. Close the process
1. Kill command.
The kill command can shut down a specified process. The commonly used command options are as follows:
kill pid: disables the specified process.
kill -9 pid: forcibly shut down the specified process.
2. pkill command.
The pkill command can shut down a process based on its name. The commonly used command options are as follows:
pkill processname: disables the process with the specified process name.
pkill -9 processname: forcibly shut down the process with the specified process name.
3. killall command.
The killall command can shut down a process based on its name. The commonly used command options are as follows:
Killall ProcessName: disables the process with the specified process name.
killall -9 processname: forcibly shut down a process with the specified process name.