inline Find and kill a process from the terminal

Originally published on May 1st, 2020 (Last updated on May 1st, 2020)

To find a run­ning process on the machine the pgrep-com­mand (Note: Just using ps | grep will not yield good results):

$ pgrep [process]
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
...

Here, [process] is the name of the process you want to find. The name of the exe­cutable can be a good start for guess­ing the name if you’re not sure. 

In the result­ing out­put, find the PID of the process. Then, the kill-com­mand can be used to end it:

# gracefully:
$ kill -SIGTERM [pid]
# force
$ kill -SIGKILL [pid]

This will then end the spec­i­fied process.

If the process you need to kill is owned by a dif­fer­ent user, adding sudo might be necessary.

Comments

No com­ment sec­tion here 😄

You can reach me over at @knuth_dev or send me an Email.