centos强制踢掉某登录用户

linux是一个多用户操作系统,用户可以在不同的地方链接上LINUX服务器,在系统中我们可以用w或者who来查看用户

[root@7273 ~]# who
root     pts/0        2013-05-17 20:45 (58.63.138.162)
root     pts/1        2013-05-17 22:24 (118.186.197.221)

[root@7273 ~]# w
 22:33:29 up 4 days,  8:05,  2 users,  load average: 1.58, 1.36, 1.47
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    58.63.138.162    20:45    0.00s  0.03s  0.00s w
root     pts/1    118.186.197.221  22:24    4:40   0.02s  0.02s -bash

看看那个是自己登录得到
[root@7273 ~]# who am i
root     pts/0        2013-05-17 20:45 (58.63.138.162)
pkill,pts/1
接下来使用pkill踢掉用户
[root@7273 ~]# pkill -kill -t pts/1
接着用w或者who
[root@7273 ~]# w
 22:40:43 up 4 days,  8:12,  1 user,  load average: 1.58, 1.36, 1.40
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    58.63.138.162    20:45    0.00s  0.03s  0.00s w


大功告成


  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要实现 CentOS 用户登录后微信通知用户,可以使用以下步骤: 1. 创建一个微信公众号并获取其 AppID 和 AppSecret。 2. 在 CentOS 上安装 WeChaty,它是一个 Node.js 的微信个人号机器人SDK,可以用来构建微信机器人。 3. 使用 WeChaty 创建一个脚本,监听 CentOS用户登录事件。 4. 当用户登录成功后,使用 WeChaty 向指定微信用户发送消息通知。 下面是一个示例代码: ``` const { Wechaty } = require('wechaty'); const qrcodeTerminal = require('qrcode-terminal'); const axios = require('axios'); const bot = new Wechaty({ profile: 'default' }); bot.on('scan', (qrcode, status) => { if (status === 1) { qrcodeTerminal.generate(qrcode, { small: true }); } }); bot.on('login', async user => { console.log(`User ${user} logged in`); const url = `https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=<your_appid>&secret=<your_appsecret>`; const response = await axios.get(url); const token = response.data.access_token; const message = { touser: '<user_openid>', msgtype: 'text', text: { content: 'CentOS user logged in' } }; const sendUrl = `https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=${token}`; await axios.post(sendUrl, message); }); bot.start(); ``` 在代码中,`<your_appid>` 和 `<your_appsecret>` 需要替换为你自己的微信公众号 AppID 和 AppSecret,`<user_openid>` 是接收通知的微信用户的 OpenID。 运行脚本后,当 CentOS 用户登录成功时,就会自动发送一条微信消息给指定的用户

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值