3 月 172015
安装
[root@localhost ~]# yum -y install screen
描述
启动screen并运行top命令
[root@localhost ~]# screen
退出并保持当前screen会话
Ctrl+a+d
查看
[root@localhost ~]# screen -ls There is a screen on: 16688.pts-4.localhost (Detached) 1 Socket in /var/run/screen/S-root. [root@localhost ~]#
激活screen会话
[root@localhost ~]# screen -r 16688
打开多个screen会话窗口并在窗口间切换
Ctrl a c创建一个新窗口并运行vi编辑器
Ctrl a c创建一个新窗口并运行htop
使用Ctrl-a p上翻窗口
使用Ctrl-a n下翻窗口
使用Ctrl-a Ctrl-a在两个窗口间切换
使用窗口编号快速切换窗口
Ctrl-a 0-9
Ctrl-a c创建一个新窗口并使用Ctrl-a k杀掉当前窗口
异常关闭的SSH连接及screen会话窗口的恢复
-D (-r) Detach and logout remote (and reattach here).
杀掉无法正常切换的screen会话进程
[root@localhost ~]# screen -ls There is a screen on: 16521.pts-0.localhost (Attached) 1 Socket in /var/run/screen/S-root. [root@localhost ~]# ps 16521 PID TTY STAT TIME COMMAND 16521 ? Ss 0:00 SCREEN [root@localhost ~]# kill -9 16521 [root@localhost ~]# screen -ls There is a screen on: 16521.pts-0.localhost (Dead ???) Remove dead screens with 'screen -wipe'. 1 Socket in /var/run/screen/S-root. [root@localhost ~]#
清除已杀死的screen会话进程
[root@localhost ~]# screen -wipe There is a screen on: 16521.pts-0.localhost (Removed) 1 socket wiped out. No Sockets found in /var/run/screen/S-root. [root@localhost ~]# screen -ls No Sockets found in /var/run/screen/S-root. [root@localhost ~]#
远程演示
screen -x
screen -x lesson1
screen -S lesson1
会话锁定和解锁 屏幕无显示但会接受键盘操作
锁定 Ctrl-a s 解锁Ctrl-a q
密码会话锁定
Ctrl-a x
屏幕分割