Linux Screen Command(Screen概述)

Screen Command

What can the Screen command be used for?

        塑料英文见谅,整理自How to Use Screen Command on Ubuntu,自行查看。
        Screen command can be used in the situation that you want to run a program in the background or run a task which requires a long time to process and execute.如果想在后台运行一个程序比如clash,或者跑一个时间很长、连接可能会断开的程序,就需要用到Screen。
        Screen allows users to use multiple terminal sessions inside a single window,which can be disconnected and then reconnected exactly from where the session was disconnected.

How to use Screen commend?

        首先,安装。一般Linux的发行版本都预装了screen,使用以下命令查看:

screen --version

        没有安装,直接apt install

sudo apt-get install screen

        启动,输入screen

screen

在这里插入图片描述        Press Enter and continue.Do so,and you will be brought to the terminal with nothing happening.你回车后返回了terminal,感觉啥也没做,但其实screen已经启动了。你可以先按 ctrl + a 再按 ? 就可以查询screen下的所有命令。
        Detachiing and Re-attaching to the Screen.其实就是后台运行以及恢复到前台运行。运行screen之后,再跑自己的程序或者代码,然后按ctrl + a和ctrl + d就可以实现后台运行。比如下面我更新一下apt,然后后台执行,提前已经运行了screen,有如下结果:
在这里插入图片描述
        恢复也很简单,输入:

screen -r

        如果你仅仅运行了一个后台程序,会直接恢复,否则会返回一个列表,需要你指定恢复哪个后台程序,比如我恢复apt update:

screen -r ID

在这里插入图片描述
        如果想退出:exit

在这里插入图片描述
        下面我就不贴图了。To find the session ID list the current running screen sessions with:

screen -ls

        给一个session命名。To create a named session, run the screen command with the following arguments:

screen -S session_name

        如果想要嵌套session,可以在打开一个screen后按ctrl + a和ctrl + c。在新出来的会话中exit,就会返回到上一个screen。使用ctrl + a 和 ctrl + n来切换到下一个session,ctrl + a 和 ctrl + p切换到上一个session。(嵌套状态)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值