Linux Kill and Logout Users Command

栏目: IT技术 · 发布时间: 4年前

内容简介: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 the ps command, free command, skill com

S how do you kill a Linux user login session? Yet another newbie question that suggests sysadmin/people love to kill and show their power to the rest of the world. There is a package called procps . It includes various useful and 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

Linux Kill and Logout Users Command

Linux Kill and Logout Users Command

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 the ps command, free command, skill command, pkill command, pgrep command, snice command, tload command, top command, uptime command, vmstat command,w command, watch command andpwdx command.

WARNING:Do not kill the process owned by the root user (UID 0) or PID 1. Keep in mind that killing necessary processes such as sshd or nfsd or httpd may result in the system downtown. Be careful with all commands. Think twice before entering any of the following commands.

How To Halt/Stop a User Called vivek on Linux

Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following commands. First, switch to the root user by typing the su - and entering the root password, when prompted (you can also use the sudo command if configured on your machine). 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.

Resume Halted User Called vivek in Liuux

Send CONT single to user vivek, type the following command:

# skill -CONT -u vivek

Kill and Logout a User Called vivek under Linux

You can send KILL single, type the following command:

# skill -KILL -u vivek

Kill and Logout All Users

The ultimate command to kill and logout all users is as follows:

# skill -KILL -v /dev/pts/*

Linux Kill and Logout Users Command 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.

The pkill command

To halt or stop a user called vivek, enter:

# pkill -STOP -u vivek

Say you want to resume a user called vivek who was halted previously by the pkill command, enter:

# pkill -CONT -u vivek

Finally kill all php-cgi process owned by vivek user, enter:

# pkill -KILL -u vivek php-cgi

How to kill a Linux login session remotely

We can kill a Linux login session remotely by sending a hangup signal (SIGHUP) to the process running the login session. Typically BASH or KSH shell runs the login session. First, find out your current tty as we need to avoid killing ourselves. Type the tty command and press the [Enter] key:

# tty

Say you want to see all of the running processes of a user named wendy, enter:

# ps -fu {userNameHere}
 # ps -fu wendy

Look for the PID (process ID) in the second column. The sixth column shows the TTY to which your processes are connected. The last column gives a process name, which is a login shell. Finally, we are going to remove the remote shell. You must look for the shell PID and choose the PID that is not for your current tty and type:

# kill -HUP {PID}
 # kill -HUP 25250

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.

Conclusion

We cannot kill processes that are running on a Linux server other than the one you are logged into right now. For other remote Linux servers first, ssh into that box and run the above commands to kill users and log out of the systems. Set TMOUT to automatically log users out after a period of inactivity. See how to automatically logout BASH / TCSH / SSH users after a period of inactivity for more info.


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

算法引论

算法引论

[美]Udi Manber / 黄林鹏、谢瑾奎、陆首博、等 / 电子工业出版社 / 2005-9-1 / 35.00元

本书是国际算法大师乌迪·曼博(Udi Manber)博士撰写的一本享有盛誉的著作。全书共分12章:第1章到第4章为介绍性内容,涉及数学归纳法、算法分析、数据结构等内容;第5章提出了与归纳证明进行类比的算法设计思想;第6章到第9章分别给出了4个领域的算法,如序列和集合的算法、图算法、几何算法、代数和数值算法;第10章涉及归约,也是第11章的序幕,而后者涉及NP完全问题;第12章则介绍了并行算法;最后......一起来看看 《算法引论》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

随机密码生成器
随机密码生成器

多种字符组合密码