程式扎記: [Linux 常見問題] How do you kick a benign user off your system?

標籤

2016年11月3日 星期四

[Linux 常見問題] How do you kick a benign user off your system?

Source From Here
Question
I was googling this a bit ago and noticed a couple of ways, but I'm guessing that google doesn't know all. So how do you kick users off your Linux box? also how do you go about seeing they are logged in in the first place? and related... does your method work if the user is logged into an X11 DE (not a requirement I'm just curious)?

How-To
There's probably an easier way, but I do this:
1. See who's logged into your machine -- use who or w:
# who
guest pts/2 2016-11-03 17:19 (61-228-152-120.dynamic.hinet.net)
john pts/1 2016-11-03 17:18 (61-228-152-120.dynamic.hinet.net)

2. Look up the process ID of the shell their TTY is connected to:
// ttylist: Select by tty. Nearly identical to -t and --tty, but can also be used with an empty ttylist to indicate the terminal associated with ps.
# ps t 2 // Here we want 'guest' to out
PID TTY STAT TIME COMMAND
14624 pts/2 Ss+ 0:00 -bash

3. Laugh at their impending disconnection (this step is optional, but encouraged)
# echo "HAHAH" | write guest pts/2

4. Kill the corresponding process:
# kill -9 14624


沒有留言:

張貼留言

網誌存檔

關於我自己

我的相片
Where there is a will, there is a way!