Linux查看當前登入使用者並踢出使用者__Linux

來源:互聯網
上載者:User

1、查看當前登入使用者

[wilsh@lcl ~]$ whatis ww                    (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.00USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHATroot     tty3     -                09:25   23:25   0.10s  0.08s -bashroot     pts/0    192.168.105.188  09:32    9:38   0.02s  0.02s -bashroot     pts/1    192.168.105.188  09:36    9:32   0.03s  0.02s -bashwilsh    pts/2    192.168.105.188  09:41    0.00s  0.00s  0.00s w

2、踢出當前線上的使用者

a)pkill

[wilsh@lcl ~]$ whatis pkillpkill [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 style="color:#FF99FF;"><span style="background-color: rgb(255, 255, 153);">#在centos6.7 kernel 3.10.28中測試,發現寫完整的裝置名稱並不起作用(如/dev/pts/2),本文是在kernel 2.6.32中寫的,昨天晚上剛剛重啟編譯完3.10.28的核心,測試了一下又不可以了,鬱悶。</span></span>
 

b)skill

[wilsh@lcl ~]$ whatis skillskill                (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.00USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHATroot     tty3     -                09:25   31:32   0.10s  0.08s -bashroot     pts/0    192.168.105.188  09:32   17:45   0.02s  0.02s -bashroot     pts/1    192.168.105.188  09:36   17:39   0.01s  0.01s -bashwilsh    pts/2    192.168.105.188  09:57    0.00s  0.00s  0.00s w[wilsh@lcl ~]$ skill -9 -u wilsh


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.