想從終端快速踢掉系統中其他登錄者,可以先用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