安装
使用管理员权限,输入以下命令进行安装:(centos7.6)
yum -y install screen
如果是centos8的话有可能会出现以下情况:
[root@centos8 ~]#screen
-bash: screen: command not found
或者这个:
[root@centos8 ~]#yum -y install screen
CentOS Linux 8 - AppStream 3.9 kB/s | 4.3 kB 00:01
CentOS Linux 8 - BaseOS 6.9 kB/s | 3.9 kB 00:00
CentOS Linux 8 - Extras 1.9 kB/s | 1.5 kB 00:00
No match for argument: screen
Error: Unable to find a match: screen
[root@centos8 ~]#yum -y install screen
Last metadata expiration check: 0:02:06 ago on Wed 11 May 2022 11:30:57 PM CST.
No match for argument: screen
Error: Unable to find a match: screen
原因:因为centOS8后yum不存在screen资源
解决方案:先安装 epel
#yum -y install epel-release
等待安装完成后:
Installed:
epel-release-8-11.el8.noarch
Complete!
再去执行命令:
yum -y install screen
相关命令
创建窗口
screen -S tset
查看screen中运行的窗口
screen -ls
这里可以看到我们创建的test,前面有一个为ID号
连接到窗口
screen -r 10171
tips:其中10171是ID,换成自己的
如果使用screen -r (id)重新连接程序screen界面时,出现报错 There is no screen to be resumed matching xxxxxx。这是因为,突然断网,之前的screen还是处于打开状态的,1个screen无法同时打开2次,所以无法正常打开screen。(我是因为另一台机器还在链接着)
首先使用:screen -d xxxx(id)命令将窗口退出。
screen -d xxxx(id)
然后使用screen -r xxx(id)重新连接
screen -r xxx(id)
退出(在窗口中)
exit
如果不在窗口中(即窗口无法连接了)
screen -X -S id(窗口id) quit
tips:图片中的10171 就是id,直接替换就好
参考链接
1、https://blog.csdn.net/qq_50001789/article/details/131401754
2、https://blog.csdn.net/m0_72096792/article/details/130027721