1、首先是使用who命令查看当前有多少个终端登陆了Linux系统

[root@:vg_adn_tidbCkhsTest /usr/local/redis/bin]#who
mobdev   pts/1        2019-01-14 05:37 (ec2-18-136-70-46.ap-southeast-1.compute.amazonaws.com)
mobdev   pts/2        2019-01-15 03:01 (ec2-18-136-70-46.ap-southeast-1.compute.amazonaws.com)

2、接下来查看自己的当前终端是多少

[root@:vg_adn_tidbCkhsTest /usr/local/redis/bin]#tty
/dev/pts/1

3、可以看到自己的终端名称是/dev/pts/1。现在我们要杀死pts/2这个用户终端,先取出这个终端的进程号

[root@:vg_adn_tidbCkhsTest /usr/local/redis/bin]#ps -t /dev/pts/2
  PID TTY          TIME CMD
 9360 pts/2    00:00:00 bash

4、我们看到进程号是9260,现在把它kill掉

[root@:vg_adn_tidbCkhsTest /usr/local/redis/bin]#kill -9 9360
[root@:vg_adn_tidbCkhsTest /usr/local/redis/bin]#ps -t /dev/pts/2
error: TTY could not be found

当我们kill掉的时候,可以看到已经没有这个tty终端了。注意普通用户是没有权限执行此操作的。


1 Comment

최저가 해외 가상서버 추천리스트 2021 | 다비도브 linux vps서버운영일기 · 2021-01-30 at 16:25

[…] 테스트  주소 : 테스트 ip / 다운로드 테스트 […]

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *