如何暫停或終止當前登錄的用戶session – Linux

from Howto: Linux Kill and Logout Users.

 

踢人的感覺就是這麼好味喔~🙂

 

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

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

%d 位部落客按了讚: