Monday, March 14, 2022
Since searching for a process and killing process is such a common task there's are shortcut commands available for these tasks in form of pgrep and pkill. As you suspect these commands are used for finding and killing processes respectively.
For example we can search for gnome processes like this instead of combining the ps command with the grep command
Or to get more information you can use the command like command below to get the full listing
[jhuynh@cent7 ~]$ ps -F -p $(pgrep gnome)
The pkill command works in similar fashion, so instead of killing the process by the number, you can just kill the bash process with this command pkill PID, one caveat is that it does not work like kill -9 so your usage may be limited.
Another useful command is the top command, this command will sort the processes that uses the most resources first by default. All you have to do is type top in the terminal
You sort it by other attributes as well such as memory, by default it's by CUP usage, to get to the other options type the f key
Select %MEM and type s to select it and press esc to sort the top screen by memory usage
No comments:
Post a Comment