Geek Culture

A new tech publication by Start it up (https://medium.com/swlh).

Follow publication

DevOps in Linux — Different Ways to Search and Kill Process

N ways to search and kill running process in Linux

Tony
Geek Culture
Published in
4 min readFeb 3, 2023

ps -ef | grep <name>

Use ps command to find the process you are looking for first:

$ ps -ef 
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 2022 ? 00:00:18 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
root 2 0 0 2022 ? 00:00:00 [kthreadd]
root 3 2 0 2022 ? 00:00:00 [rcu_gp]
root 4 2 0 2022 ? 00:00:00 [rcu_par_gp]
root 6 2 0 2022 ? 00:00:00 [kworker/0:0H-ev]
root 8 2 0 2022 ? 00:00:00 [mm_percpu_wq]
root 9 2 0 2022 ? 00:00:00 [rcu_tasks_rude_]
root 10 2 0 2022 ? 00:00:00 [rcu_tasks_trace]
root 11 2 0 2022 ? 00:00:00 [ksoftirqd/0]
root 12 2 0 2022 ? 00:00:29 [rcu_sched]
root 13 2 0 2022 ? 00:00:04 [migration/0]
root 15 2 0 2022 ? 00:00:00 [cpuhp/0]
root 16 2 0 2022 ? 00:00:00 [cpuhp/1]
...

or ps -ef | grep

$ ps -ef | grep python
txu 31263 987 0 22:07 pts/1 00:00:00 python3 -m http.server

At this time, if I want to kill my Python http server, I can use the kill command:

$ kill -s 9 31263

$
kill -l
1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3
38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Tony
Tony

No responses yet

Write a response