How to kill a particular user terminal on Linux

Intro.

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.


Display termial name

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 !

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值