Linux查看当前登录用户并踢出用户的命令
1、查看当前登录用户
1
2
3
4
5
6
7
8
9
|
[wilsh@lcl ~]$ whatis w
w (1) - Show who is logged on and what they are doing
[wilsh@lcl ~]$ w
09:49:30 up 1 day, 17:19, 4 users , load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty3 - 09:25 23:25 0.10s 0.08s - bash
root pts /0 192.168.105.188 09:32 9:38 0.02s 0.02s - bash
root pts /1 192.168.105.188 09:36 9:32 0.03s 0.02s - bash
wilsh pts /2 192.168.105.188 09:41 0.00s 0.00s 0.00s w
|
2、踢出当前在线的用户
a)pkill
1
2
3
4
5
6
|
[wilsh@lcl ~]$ whatis pkill
pkill [pgrep] (1) - look up or signal processes based on name and other attributes
[wilsh@lcl ~]$ pkill -KILL -u wilsh #-u用来指定用户名
[wilsh@lcl ~]$ pkill -9 -u wilsh # -KILL -9都是可以的。
[wilsh@lcl ~]$ pkill -KILL -t pts /2
[wilsh@lcl ~]$ pkill -KILL -t /dev/pts/2 # 这种写法是错误的。因为在man page中明确说明,如果要使用-t参数,那么就不能带/dev/前辍。<span><span>#在centos6.7 kernel 3.10.28中测试,发现写完整的设备名并不起作用(如/dev/pts/2),本文是在kernel 2.6.32中写的,昨天晚上刚刚重启编译完3.10.28的内核,测试了一下又不可以了,郁闷。</span></span>
|
b)skill
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[wilsh@lcl ~]$ whatis skill
skill
(1) - send a signal or report process status
[wilsh@lcl ~]$ skill -9 -t pts /2
[wilsh@lcl ~]$ w
09:57:37 up 1 day, 17:28, 4 users , load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty3 - 09:25 31:32 0.10s 0.08s - bash
root pts /0 192.168.105.188 09:32 17:45 0.02s 0.02s - bash
root pts /1 192.168.105.188 09:36 17:39 0.01s 0.01s - bash
wilsh pts /2 192.168.105.188 09:57 0.00s 0.00s 0.00s w
[wilsh@lcl ~]$ skill -9 -u wilsh
|
总结
以上所述是小编给大家介绍的Linux查看当前登录用户并踢出用户的命令,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
原文链接:https://www.cnblogs.com/caicairui/archive/2018/05/04/8989156.html
本文由主机测评网发布,不代表主机测评网立场,转载联系作者并注明出处:https://zhuji.jb51.net/linux/5194.html