Sometimes, the application we launched from command promp failed to exit. What we require is terminating it without clicking the ‘X’ button in the top of the terminal window. In this case, we prefer the combination of w
and pkill
, read the flowing for details.
To kill the terminal process, we have to which terminal process we are going to kill! Apparently, w
is a simple command that could tell us who is doing what on the current Linux. An example is showing below.
$ w
14:14:26 up 5:28, 6 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
abc pts/1 172.16.1.137 09:42 3:34m 4:56 4:55 vim a.c
aban pts/4 192.168.1.7 09:30 16:26 0.18s 0.18s -bash
aban pts/5 192.168.1.7 09:31 1:47m 4.21s 4.13s nmon
cust pts/6 172.16.0.133 12:48 1:22m 0.07s 0.07s -bash
aban pts/9 192.168.1.7 13:59 11:38 0.20s 0.11s vim b.c
aban pts/10 192.168.1.7 14:02 2.00s 0.05s 0.00s w
In the code above, we could easily find the TTY we intend to kill. For instance, pts/2 is the teriminal we want to kill. What we have to do next is :
pkill -kill -t pts/2
What did just happen after click enter key on our keyboard? Just execute w
again, you will not miss the answer!
Have a try and if you have any question, do not hesitate to add post below.
Good luck !