Howto: Linux Kill and Logout Users

gnome桌面一个terminal,要用gnome-session-quit而不是logout来logout这个用户

 

http://www.cyberciti.biz/tips/howto-linux-kill-and-logout-users.html

Howto: Linux Kill and Logout Users

 

Howto: Linux Kill and Logout Users

by nixCraft on August 14, 2006 · 32 comments· LAST UPDATED March 9, 2011

in Howto, Linux, Monitoring

Yet another newbie question that suggests people love to kill and show their power to rest of the world ;)

There is a package called procps. It includes various useful (nifty) utilities. One of such utility is skill which is responsible to send a signal to users and process such as:

  • Halt user terminal
  • Kill user and logout

The  procps package contains utilities to browse the /proc filesystem, which is not a real file system but a way for the kernel to provide information about the status of entries in its process table. Procps includes ps, free, skill, pkill, pgrep, snice, tload, top, uptime, vmstat, w, watch and pdwx commands.

Task: How To Halt/Stop a User Called vivek

Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following commands. First, switch to the root user by typing su - and entering the root password, when prompted (you can also use sudo if configured). Type the skill command as follows: # skill -STOP -u vivek The skill command sends a terminate command (or another specified signal) to a specified set of processes.

Task: Resume Halted User Called vivek

Send CONT single to user vivek, type the following command: # skill -CONT -u vivek

Task: Kill and Logout a User Called vivek

You can send KILL single, type the following command: # skill -KILL -u vivek

Task: Kill and Logout All Users

The ultimate command to kill and logout all users is as follows: # skill -KILL -v /dev/pts/*

WARNING! These tools are obsolete, unportable and it is here due to historical reasons. Consider using the killall, pkill, and pgrep commands instead as follows.

pkill command

To halt or stop a user called vivek, enter: # pkill -STOP -u vivek To resume a user called vivek, enter: # pkill -CONT -u vivek To kill all php-cgi process owned by vivek user, enter: # pkill -KILL -u vivek php-cgi

Other useful nifty utilities provided by procps package

  • w command :  Show who is logged on and what they are doing.
  • kill command : Send signal to a process (explains how to kill process under Linux)
  • top command : Display Linux tasks and other important stuff
  • vmstat command : Display virtual memory statistics.
  • free command : Display free and used memory (RAM) statistics.
  • slabtop command : Display kernel slab cache information in real time.

 

 

如何强制踢出Linux中登录的用户

1.找出要踢的用户

输入:who

显示:

user@cloud-5:~$ who user     tty7         2009-09-01 03:09 (:0) user     pts/0        2009-09-01 17:30 (:0.0) user     pts/1        2009-09-01 17:47 (10.1.50.249)

 

2.比如我想要踢掉控制台tty7的用户

输入:sudo pkill -kill tty7

显示:

user@cloud-5:~$ sudo pkill -kill tty7 [sudo] password for user:

输入密码即可踢出用户

 

注:踢出控制台的用户也许需要root的权限

posted @ 2014-12-08 03:11  alxe_yu  阅读(271)  评论(0)    收藏  举报