Linux Screen 命令用法(附实例演示)

Kevin 教程 2,348 次浏览 41条评论

Screen是Linux系统下的常用软件,可以同时创建多个命令行会话,并实现方便切换管理,能有效防止远程登录VPS因意外断线而丢失会话窗口。在运行长耗时任务时可通过Screen临时切换会话,让任务挂起到后台,以便用户继续其它操作。Screen也支持多用户会话共享(需具备setuid-root权限)。

Screen 安装

大多Linux发行版系统可以直接从软件仓库里安装Screen,命令如下。

操作系统 安装命令
CentOS yum install screen
Ubuntu & Debian apt-get install screen
Fedora dnf install screen
Arch Linux pacman -S screen
Gentoo emerge --ask app-misc/screen

Screen 用法

下面列出Screen常用命令,需要留意参数大小写,部分参数因大小写不同而有所区别。

作用说明 命令示例
创建会话并进入 screen -S <会话名称>
恢复指定会话 screen -r <会话名称>
列出所有会话 screen -ls
删除指定会话 screen -S <会话名称> -X quit
删除所有会话 killall screen
清除dead状态会话(因某些原因已结束的会话) screen -wipe
以下命令在会话中使用
退出当前会话窗口(不会影响进程继续运行) Ctrl+a组合键,接着再按d
创建新的终端会话 Ctrl+a组合键,接着再按c
强制关闭当前会话并结束里面的进程 Ctrl+a组合键,接着再按k
显示所有会话列表 Ctrl+a组合键,接着再按w
切换其它会话窗口(编号0-9) Ctrl+a组合键,接着再按0-9数字键
锁定当前会话,恢复需验证用户密码 Ctrl+a组合键,接着再按x
显示更多选项帮助信息 Ctrl+a组合键,接着再按?

Screen 屏幕分割

如果需要同时监视多个会话窗口,可以将窗口分割显示,效果如下图。

Screen 屏幕分割
Screen 屏幕分割显示

操作方法:先在当前会话窗口里按下Ctrl+a组合键,接着按Shift+|分隔符键(在Enter键左侧),这样会垂直分割出新的窗口(水平分割按S键)。然后Ctrl+aTab切换到不同窗口,Ctrl+ac再创建或恢复终端会话就可以了。如果要关闭当前会话之外的所有窗口,使用Ctrl+aQ

结束语

掌握以上Screen命令应该就能应对日常需求了。Screen还提供有丰富的定制特性,例如通过修改配置文件可以添加命令选项绑定键,设置会话自启动窗口,控制用户访问权限等高级用法。如需了解更多Screen的相关使用描述,可运行man screen命令查看说明文档。

评论列表

  1. #1

    dapoxetine without doctor prescription reviews https://dapoxetine.confrancisyalgomas.com/

  2. #2

    hydroxychloroquine treatment protocol https://hydroxychloroquine.webbfenix.com/

  3. #3

    viagra with dapoxetine for sale https://salemeds24.wixsite.com/dapoxetine

  4. #4

    how much ivermectin for 200 pound person https://ivermectin.mlsmalta.com/

  5. #5

    prescription medications and pregnancy https://buymeds.mlsmalta.com/

  6. #6

    prescription medications and pregnancy https://medpills.bee-rich.com/

  7. #7

    cheap vidalista online pharmacy https://vidalista40mg.mlsmalta.com/

  8. #8

    cialis https://wisig.org/

  9. #9

    ventolin inhaler copay assistance https://amstyles.com/

  10. #10

    dapoxetine combined with tadalafil https://ddapoxetine.com/

  11. #11

    has hydroxychloroquine been successful https://hydroxychloroquinee.com/

  12. #12

    cenforce gold for sale http://cavalrymenforromney.com/

  13. #13

    cialis soft gel caps https://cleckleyfloors.com/

  14. #14

    acyclovir dosage for genital herpes https://www.herpessymptomsinmen.org/productacyclovir/

  15. #15

    chloroquine dosage for coronavirus https://hydroxychloroquine.wisig.org/

  16. #16

    chloroquine dosage for coronavirus https://hydroxychloroquine.grassfed.us/

  17. #17

    nolvadex uk pharmacy https://tamoxifen.mrdgeography.com/

  18. #18

    vidalista side effects long term https://vidalista.mlsmalta.com/

  19. #19

    sample viagra pack https://viaplz.com/

  20. #20

    generic cefixime india buy online https://ceefexime.co/

  21. #21

    buy cialis online http://cialllis.com/

  22. #22

    generic cialis medication https://cialis.bee-rich.com/

  23. #23

    generic cialis medication https://cialis.mrdgeography.com/

  24. #24

    where can i buy cialis online https://cialis.adicbc.com/

  25. #25

    where can i buy cialis online https://cialis.buszcentrum.com/

  26. #26

    how stromectol works for corona https://ivermectin1st.com/

  27. #27

    I view something really special in this web site.

    http://www.vreyrolinomit.com/

  28. #28

    vidalista

  29. #29

    viagra subscription

  30. #30

    When someone writes an piece of writing he/she maintains the idea of a user in his/her mind that how a user can know it.
    Thus that’s why this article is great. Thanks! http://antiibioticsland.com/Bactrim.htm

  31. #31

    facultad de farmacia ull http://www.essinreceta.com/ cialis venta

  32. #32

    tadalafil daily use https://elitadalafill.com/ tadalafil 40 mg daily

  33. #33

    vardenafil 20 mg https://vegavardenafil.com/ vardenafil sublingual generic

  34. #34

    best place to buy viagra online viagra amazon
    price of viagra

  35. #35

    tadalafil vs sildenafil – eli lilly tadalafil tadalafil liquid

  36. #36

    alprostadil gel https://alprostadildrugs.com/ alprostadil penile injection

  37. #37

    As I website possessor I believe the subject material here is rattling excellent, thankyou for your efforts.

    https://www.youtube.com/watch?v=tm_FEaULxf8

  38. #38

    You are my intake, I possess few web logs and occasionally run out from to brand.

    https://www.youtube.com/watch?v=W9ED11cU594

  39. #39

    Somebody essentially help to make seriously posts I would state. This is the first time I frequented your website page and thus far? I amazed with the research you made to make this particular publish incredible. Great job!

    https://allcreditcarloans.co/autoloan/

  40. #40

    Have you ever heard of second life (sl for short). It is basically a video game where you can do anything you want. sl is literally my second life (pun intended lol). If you would like to see more you can see these Second Life authors and blogs

    http://www.avatarlanguages.com/nl/mediacoverage.php

  41. #41

    Have you ever heard of second life (sl for short). It is essentially a video game where you can do anything you want. Second life is literally my second life (pun intended lol). If you want to see more you can see these Second Life authors and blogs

    thegridlive.com/page/56/

发表评论

电邮地址用于 Gravatar 头像显示,不会被公开可见。