[教程]screen的安装和简单使用

写在前面

为什么要使用screen

1.有时候,我们远程连接ssh,执行命令,进行编译等大量需要等待时间的时候,我们可以很方便的关闭ssh会话窗口,随便干点别的什么事情去,而不会中断操作,该操作还在screen中运行着,只要下次重新连接该会话窗口就行。

2.有时候,远程连接ssh,经常会因为网络原因导致ssh中断,无法完成需要的操作。

安装screen

yum install screen -y #centos系
apt install screen -y #debian系

简单使用screen

#建立一个会话窗口
screen -S chuangkou #这是建立了一个名为:chuangkou的screen会话窗口
#退出该会话窗口
ctrl+a,然后按d
#列表目前小鸡上所有的已开会话窗口
screen -ls
#重新连接到名为chuangkou的会话窗口
screen -R chuangkou
#就能看到之前运行情况了

写在后面

就是这么简单,解决大问题

PS后记

最近有台机器,centos7.8的,在打算用yum进行安装screen时,出现大量的错误,如下图

[root@promote ~]# yum install screen
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 6.5 kB 00:00:00
base: mirrors.ustc.edu.cn
epel: mirrors.bfsu.edu.cn
extras: mirrors.ustc.edu.cn
updates: mirrors.cn99.com
http://mirrors.ustc.edu.cn/centos/7.8.2003/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
http://mirrors.163.com/centos/7.8.2003/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.cn99.com/centos/7.8.2003/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.njupt.edu.cn/centos/7.8.2003/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.aliyun.com/centos/7.8.2003/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://ftp.sjtu.edu.cn/centos/7.8.2003/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.nju.edu.cn/centos/7.8.2003/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.cqu.edu.cn/CentOS/7.8.2003/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.neusoft.edu.cn/centos/7.8.2003/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirror.bit.edu.cn/centos/7.8.2003/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

需要重建元数据

yum clean all
yum makecache

这回,就能正常yum了