linux系统中中断已连接的用户
1、用w命令查看当前系统登录的用户
[root@rhel7 ~]# w
:: up :, users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/ 192.168.1.100 : .00s .06s .02s w
lxj2 pts/ 192.168.1.100 : .00s .00s .00s -bash
rusky pts/ 192.168.1.100 : .00s .01s .01s -bash
[root@rhel7 ~]#
USER —登录的用户名
TTY —登录后系统分配的终端号
FROM—远程主机名,即从哪儿登录来的
LOGIN@—何时登录
IDLE—空闲了多长时间,表示用户闲置的时间。这是一个计时器,一旦用户执行任何操作,该计时器便会被重置
JCPU—和该终端(tty)连接的所有进程占用的时间,这个时间里并不包括过去的后台作业时间,但却包括当前正在运行的后台作业所占用的时间
PCPU—指当前进程(即在WHAT项中显示的进程)所占用的时间
WHAT—当前正在运行进程的命令行
2、使用ps -u username命令查看用户进程,然后kill掉对应用户的sshd进程
[root@rhel7 ~]# ps -u lxj2
PID TTY TIME CMD
? :: sshd
pts/ :: bash
[root@rhel7 ~]# kill -
[root@rhel7 ~]# ps -u lxj2
PID TTY TIME CMD
[root@rhel7 ~]# w
:: up :, users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/ 192.168.1.100 : .00s .17s .00s w
rusky pts/ 192.168.1.100 : :07m .00s .00s -bash
[root@rhel7 ~]#
3、还有另外一种方式是使用pkill命令终止用户连接
[root@rhel7 ~]# w
:: up :, users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/ 192.168.1.100 : .00s .18s .01s w
lxj2 pts/ 192.168.1.100 : .00s .02s .02s -bash
rusky pts/ 192.168.1.100 : :45m .00s .00s -bash
[root@rhel7 ~]# pkill -kill -t pts/
[root@rhel7 ~]# w
:: up :, users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/ 192.168.1.100 : .00s .18s .00s w
rusky pts/ 192.168.1.100 : :46m .00s .00s -bash
[root@rhel7 ~]# pkill -kill -t pts/
[root@rhel7 ~]# w
:: up :, user, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/ 192.168.1.100 : .00s .19s .01s w
[root@rhel7 ~]#
========
其它:通过用户的ssh进程号来中断用户连接:
使用pstree -p 命令来查出用户的会话ID。
[root@rhel7 test]# pstree -p
.......
├─rhnsd()
├─rhsmcertd()
├─rngd()
├─rsyslogd()─┬─{rsyslogd}()
│ └─{rsyslogd}()
├─rtkit-daemon()─┬─{rtkit-daemon}()
│ └─{rtkit-daemon}()
├─smartd()
├─sshd(1422)─┬─sshd(7495)───bash(7502)───su(8544)───bash(8545)───su(8965)───bash(8970)───pstree(10449)
│ ├─sshd(7788)───bash(7792)───su(7873)───bash(7874)
│ └─sshd(8609)───sshd(8615)───bash(8618)
├─systemd-journal()
├─systemd-logind()
├─systemd-udevd()
├─tuned()─┬─{tuned}()
│ ├─{tuned}()
│ ├─{tuned}()
│ └─{tuned}()
├─udisksd()─┬─{udisksd}()
│ ├─{udisksd}()
│ ├─{udisksd}()
│ └─{udisksd}()
├─upowerd()─┬─{upowerd}()
│ └─{upowerd}()
└─wpa_supplicant()
根据上图中的sshd部分,删除最近连接的会话7788。
kill -9 7788
linux系统中中断已连接的用户的更多相关文章
- Linux系统中的以太网连接
1.在Linux中,以太网连接接口被命令为:eth0,eth1等,其中0,1表示网卡编号. 2.lspci来查看网卡硬件信息(USB则是lsusb) 3.ifconfig来查看接口信息 ifconfi ...
- Linux 系统中用户切换
1. Linux系统中用户切换的命令为su,语法为: su [-fmp] [-c command] [-s shell] [--help] [--version] [-] [USER [ARG]] 参 ...
- 用户管理 之 在Linux系统中,批量添加用户的操作流程
一.阅读此文件您需要掌握的基础知识: <Linux 用户(user)和用户组(group)管理概述><用户(user)和用户组(group)配置文件详解><Linux 用 ...
- 用户管理 之 Linux 系统中的超级权限的控制
在Linux操作系统中,root的权限是最高的,也被称为超级权限的拥有者.普通用户无法执行的操作,root用户都能完成,所以也被称之为超级管理用户. 在系统中,每个文件.目录和进程,都归属于某一个用户 ...
- Linux 系统中用户切换(su user与 su - user 的区别)
1. Linux系统中用户切换的命令为su,语法为: su [-fmp] [-c command] [-s shell] [--help] [--version] [-] [USER [ARG]] 参 ...
- 在Linux系统中增加和删除用户
linux创建账户并自动生成主目录和主目录下的文件 在Linux系统中增加和删除用户 Linux添加用户(user)到用户组(group) usermod -a -G groupA user linu ...
- linux系统中用户切换
1. Linux系统中用户切换的命令为su,语法为: su [-fmp] [-c command] [-s shell] [--help] [--version] [-] [USER [ARG]] 参 ...
- (转)浅谈 Linux 系统中的 SNMP Trap
原文:https://www.ibm.com/developerworks/cn/linux/l-cn-snmp/index.html 简介 本文讲解 SNMP Trap,在介绍 Trap 概念之前, ...
- linux系统状态网络、权限、用户大杂烩
来来来,我们聊一下liunx系统相关的知识!! 首先从查询网络配置开始 ifconfig 查询.设置网卡和ip等参数 ifup,ifdown 脚本命令,更简单的方式启动关闭网络 ip命令是结合了ifc ...
随机推荐
- birt 运行环境搭建(部署到tomcat)
最近一直在研究eclipse的birt,各种坑~~~~(>_<)~~~~. Requirements:tomcat version:7.0,birt-runtime-4.6.0-20160 ...
- jQuery firefox chrome IE 绑定mousewheel事件
$doc.on('mousewheel DOMMouseScroll',function(){ $htmlBody.stop(true); $goTop.stop(true); });
- tomcat启动报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable
linux 下 启动tomcat 报: Neither the JAVA_HOME nor the JRE_HOME environment variable is definedAt least o ...
- Ural 1099 Work Scheduling
http://acm.timus.ru/problem.aspx?space=1&num=1099 题意:有n个人,很多对合作关系,每个人只能和一个人合作,求最多能选出多少人. 一般图匹配 # ...
- Codeforces Round #312 (Div. 2) B.Amr and The Large Array
Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. ...
- Merge Two Sorted Lists—LeetCode
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing t ...
- C++ Primer Plus(第6版)中文版——课后练习程序代码
博客内容经历了一次整理,以前发的博文太散.没什么水准,搞的随笔分类越来越多orz,这次把CPP这本书的课后练习的程序代码放到一起方便查阅与修改..嗯 9.6.1 #ifndef _9..1_H_ #d ...
- 1036 : Trie图 (AC自动机)
题目大意: 输入 n 个目标单词和一个文本串,判断文本串中是否存在某些目标单词. 思路 赤裸裸的 AC自动机. 代码: #include<iostream> #include<cst ...
- Unity中OnGUI绘制贪吃蛇
Square.cs : public class Square : MonoBehaviour { public int row, col; public Rect rect; public Text ...
- oracle for update和for update nowait
原文地址:http://www.cnblogs.com/quanweiru/archive/2012/11/09/2762223.html 1.for update 和 for update nowa ...