码迷,mamicode.com
首页 > 其他好文 > 详细

pkill命令用法之 - 从终端踢掉其他登录者

时间:2017-06-23 15:33:08      阅读:2550      评论:0      收藏:0      [点我收藏+]

标签:linux   命令   pkill   

想从终端快速踢掉系统中其他登录者,可以先用w命令查看当前所有登录信息,并确定自己所在终端号。


[root@gateway ~]# w

 10:14:52 up  6:01,  3 users,  load average: 0.00, 0.01, 0.05

USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT

root     tty1                      10:10   36.00s  0.23s  0.23s -bash

gentoo   pts/0    10.1.1.110       10:14   12.00s  0.07s  0.07s -bash

root     pts/1    192.168.10.198   09:46    4.00s  0.19s  0.01s w

[root@gateway ~]# 


命令显示中有“w”的行所指明的TTY值就是你当前登录的终端号(pts/1),接下来用pkill命令按需求踢掉其他的登陆者即可,假如现在你想踢掉当前登录用户gentoo,从上面的w命令看gentoo用户所在的终端号为(pts/0),使用如下pkill命令:


[root@gateway ~]# pkill -9 -t pts/0


再用w命令查看


[root@gateway ~]# w

 10:23:53 up  6:10,  2 users,  load average: 0.00, 0.01, 0.05

USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT

root     tty1                      10:10    9:37   0.23s  0.23s -bash

root     pts/1    192.168.10.198   09:46    1.00s  0.24s  0.01s w

[root@gateway ~]# 


登录用户gentoo就已经被踢下去了。



命令格式:

pkill -signal -t SIGNAL


-signal

--signal signal

   Defines the signal to send to each matched process.  Either the numeric or the symbolic

   signal name can be used.  (pkill only.)

-t, --terminal term,...

   Only match processes whose controlling terminal is listed.  The terminal name should be

   specified without the "/dev/" prefix.

SIGNAL

   Signal     Value     Action   Comment

  ────────────────────────────────────

   SIGHUP        1       Term    Hangup detected on controlling terminal

                                 or death of controlling process

   SIGINT        2       Term    Interrupt from keyboard

   SIGQUIT       3       Core    Quit from keyboard

   SIGILL        4       Core    Illegal Instruction

   SIGABRT       6       Core    Abort signal from abort(3)

   SIGFPE        8       Core    Floating point exception

   SIGKILL       9       Term    Kill signal

   SIGSEGV      11       Core    Invalid memory reference

   SIGPIPE      13       Term    Broken pipe: write to pipe with no readers

   SIGALRM      14       Term    Timer signal from alarm(2)

   SIGTERM      15       Term    Termination signal

   SIGUSR1   30,10,16    Term    User-defined signal 1

   SIGUSR2   31,12,17    Term    User-defined signal 2

   SIGCHLD   20,17,18    Ign     Child stopped or terminated

   SIGCONT   19,18,25    Cont    Continue if stopped

   SIGSTOP   17,19,23    Stop    Stop process

   SIGTSTP   18,20,24    Stop    Stop typed at terminal

   SIGTTIN   21,21,26    Stop    Terminal input for background process

   SIGTTOU   22,22,27    Stop    Terminal output for background process

本文出自 “望云眷蜀” 博客,请务必保留此出处http://wyjs6.blog.51cto.com/465920/1941180

pkill命令用法之 - 从终端踢掉其他登录者

标签:linux   命令   pkill   

原文地址:http://wyjs6.blog.51cto.com/465920/1941180

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!