ZHANG BIAO . ORG

^


linux screen 命令详解

• LIUNX • 阅读: 67841

linux screen 命令详解
一、背景

系统管理员经常需要SSH 或者telent 远程登录到Linux 服务器,经常运行一些需要很长时间才能完成的任务,比如系统备份、ftp 传输等等。通常情况下我们都是为每一个这样的任务开一个远程终端窗口,因为它们执行的时间太长了。必须等待它们执行完毕,在此期间不能关掉窗口或者断开连接,否则这个任务就会被杀掉,一切半途而废了。

二、简介

GNU Screen是一款由GNU计划开发的用于命令行终端切换的自由软件。用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换。

GNU Screen可以看作是窗口管理器的命令行界面版本。它提供了统一的管理多个会话的界面和相应的功能。

会话恢复
只要Screen本身没有终止,在其内部运行的会话都可以恢复。这一点对于远程登录的用户特别有用——即使网络连接中断,用户也不会失去对已经打开的命令行会话的控制。只要再次登录到主机上执行screen -r就可以恢复会话的运行。同样在暂时离开的时候,也可以执行分离命令detach,在保证里面的程序正常运行的情况下让Screen挂起(切换到后台)。这一点和图形界面下的VNC很相似。
多窗口
在Screen环境下,所有的会话都独立的运行,并拥有各自的编号、输入、输出和窗口缓存。用户可以通过快捷键在不同的窗口下切换,并可以自由的重定向各个窗口的输入和输出。Screen实现了基本的文本操作,如复制粘贴等;还提供了类似滚动条的功能,可以查看窗口状况的历史记录。窗口还可以被分区和命名,还可以监视后台窗口的活动。
会话共享
Screen可以让一个或多个用户从不同终端多次登录一个会话,并共享会话的所有特性(比如可以看到完全相同的输出)。它同时提供了窗口访问权限的机制,可以对窗口进行密码保护。
GNU's Screen 官方站点:http://www.gnu.org/software/screen/

三、语法

screen -AmRvx -ls -wipe-h <行数>-s

参数说明

-A  将所有的视窗都调整为目前终端机的大小。
-d <作业名称>  将指定的screen作业离线。
-h <行数>  指定视窗的缓冲区行数。
-m  即使目前已在作业中的screen作业,仍强制建立新的screen作业。
-r <作业名称>  恢复离线的screen作业。
-R  先试图恢复离线的作业。若找不到离线的作业,即建立新的screen作业。
-s  指定建立新视窗时,所要执行的shell。
-S <作业名称>  指定screen作业的名称。
-v  显示版本信息。
-x  恢复之前离线的screen作业。
-ls或--list  显示目前所有的screen作业。
-wipe  检查目前所有的screen作业,并删除已经无法使用的screen作业。

四、常用screen参数

screen -S yourname -> 新建一个叫yourname的session
screen -ls -> 列出当前所有的session
screen -r yourname -> 回到yourname这个session
screen -d yourname -> 远程detach某个session
screen -d -r yourname -> 结束当前session并回到yourname这个session

在每个screen session 下,所有命令都以 ctrl+a(C-a) 开始。
C-a ? -> 显示所有键绑定信息
C-a c -> 创建一个新的运行shell的窗口并切换到该窗口
C-a n -> Next,切换到下一个 window
C-a p -> Previous,切换到前一个 window
C-a 0..9 -> 切换到第 0..9 个 window
Ctrl+a [Space] -> 由视窗0循序切换到视窗9
C-a C-a -> 在两个最近使用的 window 间切换
C-a x -> 锁住当前的 window,需用用户密码解锁
C-a d -> detach,暂时离开当前session,将目前的 screen session (可能含有多个 windows) 丢到后台执行,并会回到还没进 screen 时的状态,此时在 screen session 里,每个 window 内运行的 process (无论是前台/后台)都在继续执行,即使 logout 也不影响。
C-a z -> 把当前session放到后台执行,用 shell 的 fg 命令则可回去。
C-a w -> 显示所有窗口列表
C-a t -> Time,显示当前时间,和系统的 load
C-a k -> kill window,强行关闭当前的 window
C-a [ -> 进入 copy mode,在 copy mode 下可以回滚、搜索、复制就像用使用 vi 一样

C-b Backward,PageUp 
C-f Forward,PageDown 
H(大写) High,将光标移至左上角 
L Low,将光标移至左下角 
0 移到行首 
$ 行末 
w forward one word,以字为单位往前移 
b backward one word,以字为单位往后移 
Space 第一次按为标记区起点,第二次按为终点 
Esc 结束 copy mode 

C-a ] -> Paste,把刚刚在 copy mode 选定的内容贴上

文章标签: liunx
点此生成 >> 文章海报


已经是第一篇文章了~
下一篇 : 2021年双十二,博客搭建完成
留言

取消回复



已有 28310 条留言
  1. 2026-08-13 05:08:40
    回复

    1win sayt orqali kazino https://1win04703.help

  2. DavidSow
    2026-08-13 07:08:37
    回复

    https://sadakat.net/images/pages/?romashka_svoystva_i_primenenie_narodnaya_medicina.html

  3. JoshuaVit
    2026-08-13 08:08:03
    回复

    https://momocentral.com/

  4. 2026-08-13 09:08:59
    回复

    يا جماعة بصراحة أنا لسه مسجل من تقريبًا ٥ شهور وقلت أكتب اللي شفته. اللي عجبني من البداية حجم قسم السلوتس — الرقم عدّى ٥٠٠٠ لعبة تقريبًا وده مش رقم متزوّق لأني فضلت أقلب فيهم. الغالبية من Pragmatic Play ومعاها NetEnt و Play'n GO، يعني Gates of Olympus و Sweet Bonanza و Book of Dead موجودين زي ما انت متوقع.

    قسم الديلر المباشر ده اللي أنا قاعد عليه أغلب الوقت — كله تحت Evolution والديلرز حقيقيين، والصورة واضحة جدًا لو النت مش زي حالته في مصر أحيانًا. Crazy Time دي حكاية تانية بالرغم إن النتيجة عشوائية جدًا. طاولات الروليت والبلاك جاك متاحة بحدود مراهنة معقولة.

    بخصوص العروض — بونص الترحيب بيضاعف أول إيداع وفيه فري سبينز معاه على ألعاب معيّنة بس، بس خد بالك من الـwagering — حوالي ٤٠x ودي نقطة أنا شخصيًا مش مبسوط منها. أقل إيداع صغير جدًا يعني تقدر تدخل بمبلغ رمزي وتشوف. تقدر تتابع الأرقام الرسمية من خلال تنزيل 888starz للاندرويد لو مهتم، بدل ما تعتمد على ذاكرتي.

    فتح الحساب أخد مني دقيقتين والتحقق من الهوية خلص في يوم تقريبًا. فلوسي بتوصل عادة في ٢٤ ساعة على Skrill، Visa و Mastercard بطيئة شوية، ٣ أيام تقريبًا. والكريبتو أسرع حاجة وده مفيد جدًا لينا في مصر.

    الجزء الخاص بالموبايل شغال معايا كويس — تنزيل 888starz للاندرويد بتتم من الموقع مباشرة، وده بيبقى غريب لناس أول مرة تعمله بس بعد التثبيت الأداء أحسن بكتير. السبورت شغالين ٢٤ ساعة والتواصل بالعربي متاح. الترخيص كوراساو — يعني مش أقوى ترخيص في السوق، واللي عاش هناك من غير مشاكل يقول رأيه. الحاجة الوحيدة اللي بتغيظني إن القوايم متلخبطة على الشاشة الصغيرة ومحتاجة تنظيم.

  5. 2026-08-13 09:08:01
    回复

    والله بصراحة أنا لسه بلعب هناك من حوالي ٤ شهور وقلت أنزل رأيي بدل ما حد يسأل تاني. اللي عجبني من البداية كمية الألعاب — الرقم عدّى ٥٠٠٠ لعبة تقريبًا وده اللي شفته بعيني لأني فضلت أقلب فيهم. Pragmatic Play مسيطرة ومعاها NetEnt و Play'n GO، يعني Gates of Olympus و Sweet Bonanza و Book of Dead مش هتدوّر عليهم كتير.

    قسم الديلر المباشر هو اللي بضيّع فيه فلوسي بصراحة — كله تحت Evolution وفيه كروبيه بني آدمين، وجودة البث ممتازة طالما النت عندك محترم. Crazy Time صراحة بلعبها كتير بالرغم إن بتاكل الرصيد بسرعة. الطاولات الكلاسيكية متاحة بحدود مراهنة معقولة.

    بخصوص العروض — مكافأة التسجيل بيضاعف أول إيداع مع لفات مجانية على سلوتس محددة، الحاجة اللي لازم تقراها من متطلب المراهنة — ٤٠ ضعف ودي نقطة أنا شخصيًا مش مبسوط منها. الحد الأدنى للإيداع رمزي فتقدر تجرّب من غير ما تخاطر بكتير. تقدر تتابع العروض الحالية والشروط عبر تنزيل 888starz للاندرويد قبل الإيداع، أحسن من كلامي.

    فتح الحساب كان سريع جدًا والـKYC أخد حوالي ٢٤ ساعة. طلبات السحب آخر مرة سحبت بقت أقل من يوم على المحافظ الإلكترونية، أما الفيزا بطيئة شوية، ٣ أيام تقريبًا. لو عندك محفظة كريبتو دي أسرع طريقة وده حل كويس مع مشاكل التحويلات هنا.

    الموبايل شغال معايا كويس — تنزيل 888starz للاندرويد مش من جوجل بلاي عشان قوانين المتجر، وده ممكن يخض حد أول مرة بس التطبيق فعلًا أسرع من الموقع. خدمة العملاء شغالين ٢٤ ساعة وفيه عربي. الترخيص كوراساو — مش MGA يعني، واللي عاش هناك من غير مشاكل يقول رأيه. الحاجة الوحيدة اللي بتغيظني إن الواجهة مزدحمة شوية وبتلاقي نفسك بتدوّر.

  6. 2026-08-13 10:08:39
    回复

    يا جماعة بصراحة أنا لي قرابة خمس شهور بجرب المنصة دي وكنت فاكر إن الموضوع هيبقى زي غيره، بس الحقيقة لأ. اللي شدني من البداية إن فتح الحساب مستغرقش أكتر من دقيقتين وأقل مبلغ إيداع في متناول أي حد — من دولار تقريبًا، يعني مفيش ضغط مالي من أول يوم.

    أكتر حاجة بلعبها السلوتات وخصوصًا Gates of Olympus — Pragmatic Play ليها حضور قوي. كمان في إصدارات من Play'n GO وBig Time Gaming، والمكتبة كبيرة فعلًا — بيتكلموا عن آلاف العناوين وفعلًا حاسس بيه وأنا بتصفح. القسم المباشر شغال على Evolution والديلرز حقيقيين وCrazy Time بتلاقي عليها زحمة دايمًا.

    حكاية المكافأة، استفدت من الترحيبي الأول ووصل لمبلغ محترم مع لفات مجانية في حدود ١٠٠ لفة مش كلها مرة واحدة. بس انتبه: متطلب المراهنة في حدود ٣٥ ضعف وأنا شخصيًا اتحرقت أول مرة. فيه كمان عروض بدون إيداع من وقت للتاني، وتقدر تتابع التفاصيل والأكواد الحالية على 888starz تنزيل قبل ما تسجل.

    موضوع سحب الأرباح كان أحسن من توقعاتي. آخر مرة سحبت وصلت خلال ساعات. فيه اختيارات كتير: فيزا وماستركارد، سكريل ونيتيلر، وE-wallets، ووفيه دعم للعملات الرقمية زي البيتكوين — ودي نقطة مهمة للمصريين لأن الكروت أحيانًا بتتعب.

    الموبايل بقى الأساس بالنسبة لي. تنزيل 888starz للاندرويد بسيط — بتحمل ملف الـ888starz apk من الموقع لأن جوجل بلاي مبيسمحش بألعاب القمار، وده طبيعي مش حاجة مقلقة. التطبيق خفيف وبيشتغل عادي على موبايل قديم، بس الحاجة اللي بتغيظني إن فيه نوتيفيكشنز بتيجي طول الوقت وسكتها من أول أسبوع.

    خدمة العملاء متاح ٢٤ ساعة بس الرد بالعربي بيتأخر شوية. الموقع شغال بترخيص Curaçao ويعني مش MGA بس معروف ومنتشر. طبعًا فيه عيوب، إجراءات الـKYC كانت مملة شوية وحسيت بضيق ساعتها.

  7. 2026-08-13 10:08:38
    回复

    Learned something from this without having to dig through layers of fluff, and a stop at blog33memorys added a bit more context that helped tie things together for me, definitely a useful corner of the internet for anyone who wants real information without the usual marketing nonsense around it that often ruins similar pages.

  8. 2026-08-13 10:08:33
    回复

    If patience for careful reading is rare these days finding sites that reward it is rarer still, and a stop at iconflow extended that rare reward, the diminishing returns on shallow content reading have made me more selective about where to spend reading time and this site is meeting the higher selectivity bar consistently.

  9. 2026-08-13 10:08:24
    回复

    Worth pointing out that the post avoided the temptation to summarise everything at the end, and a look at fluentform continued that confident closing approach, content that trusts readers to retain the substance without being reminded of it at the end is content that respects the reader and this site practices that respect.

  10. 2026-08-13 10:08:34
    回复

    Reading this slowly to give it the attention it deserved, and a stop at 5-g earned the same slow read, choosing to read slowly is a small act of respect for content quality and very few sites earn that respect from me but this one did so without any explicit ask which is the cleanest way.

  11. 2026-08-13 10:08:12
    回复

    Picked something concrete from the post that I will use immediately, and a look at blog44hits added another concrete piece, content that produces immediately useful output rather than just abstract appreciation is content that earns its place in my regular rotation without needing any further evaluation from me at this point honestly.

  12. 2026-08-13 10:08:14
    回复

    A memorable post for me on a topic I had thought I was tired of, and a look at brightbuild suggested the same site can refresh other tired topics, sites that can revive my interest in subjects I had written off as exhausted are doing rare work and this one is clearly doing that for me today.

  13. 2026-08-13 11:08:50
    回复

    Found the rhythm of the prose particularly enjoyable on this read through, and a look at joltcloud kept that musical quality going across the related pages, sentence rhythm is something most blog writers ignore but it makes a real difference in how content lands with the careful reader who cares.

  14. 2026-08-13 11:08:00
    回复

    Just sat with this for a bit longer than I usually would because the points are worth thinking about, and after blog33behavior I had even more to chew on, the kind of post that nudges your thinking forward without forcing the issue is something I have always appreciated in good writing online.

  15. 2026-08-13 11:08:50
    回复

    Picked this post to share in a Slack channel where I knew it would be appreciated, and a look at risereach suggested I will share more from here later, content worth sharing into a professional context is content that has earned a higher kind of trust than mere personal interest and this site has it.

  16. 2026-08-13 11:08:20
    回复

    Polished and informative without feeling overproduced, that is the sweet spot, and a look at appfactor hit it again, you can tell when a site has been built with care versus thrown together for the sake of having something to put online and this is clearly the former approach taken by the team.

  17. 2026-08-13 11:08:28
    回复

    Reading this triggered a small reorganisation of my own thinking on the topic, and a stop at blog33read furthered that reorganisation, content that affects the shape of my mental model rather than just decorating it with new facts is content with structural rather than informational impact and this site provides that.

  18. 2026-08-13 12:08:00
    回复

    Thank you for not assuming the reader already knows everything, the explanations meet me where I am, and a look at blog66along did the same, that consideration is what makes a site feel welcoming rather than gatekeepy which is sadly the default mood across the modern web today for most subjects covered.

  19. 2026-08-13 13:08:21
    回复

    Qale do'stlar, men bu yerda deyarli olti oydan beri stavka qilaman, shuning uchun tajribamni yozib qo'yay dedim. Ochig'i, boshida shubha bilan qaragandim — bizda bunaqa saytlar to'lib yotibdi, ko'pchiligi pul to'lamaydi. Lekin 888starz menda shu paytgacha umuman aldamadi.

    O'yinlar tomonini aytsam, tanlov haqiqatan katta — menimcha 5000dan oshadi, aniq sanamadim. Asosan Pragmatic Play o'yinlarini tepaman: Gates of Olympus va Sweet Bonanza klassika, ba'zan Play'n GO ning Book of Dead ga o'tib turaman. NetEnt va Yggdrasil dan ham yetarlicha bor, faqat bularni kamroq ochaman. Live qismi alohida gap — Evolution dan, tirik krupyelar, Crazy Time bo'lsa ishdan keyin dam olishga juda mos.

    Bonus tomoni ham yomon emas: dastlabki to'ldirishda 100% ustiga va yana 150 frispin tushadi. Ammo shu yerda shartga qarab qo'ying — odatda x40 atrofida, ya'ni darrov chiqarolmaysiz, sabr kerak. O'zim avvaliga qoidalarni o'qimay olib yubordim va biroz kuyib qoldim. Amaldagi takliflarni 888starz skachat dan tekshirib olishingiz mumkin, pul tashlashdan avval shuni maslahat beraman.

    To'lovlar bo'yicha: Visa va Mastercard ishlaydi, Skrill bilan Neteller ham bor, Bitcoin orqali ham mumkin — o'zim ko'proq USDT dan foydalanib turaman, chunki tezroq. Eng kam summa arzimagan, deyarli 10 000 so'm atrofida bo'lsa kerak. Yaqinda chiqarib oldim — kriptoga yarim soatda tushdi, kartaga esa bir kunga yaqin kutdim.

    Telefon versiyasi to'g'risida ikki og'iz: rasmiy sahifadan ilovani olish mumkin, Android da bemalol o'rnatiladi, iPhone egalari ham variant bor, lekin sal chalkashroq. Mobil brauzerda ham normal ishlaydi, ilova esa yengilroq tuyuldi. Menga yoqmagan jihat — hujjat tekshiruvi ancha sekin bo'ldi, ikki kun kutdim, support xizmati rus tilida normal ishlaydi, o'zbek tilida gohida sekinroq. Ruxsatnoma Curacao dan, demak xalqaro standart — kimdir buni yoqtirmaydi, men uchun muhim emas, chunki to'lovda hozircha aldanmadim.

  20. Peterintex
    2026-08-13 13:08:32
    回复

    https://abcweselne.pl/forum-slubne/cytotec-abortion-pills-in-sharjah-971521786258-buy-mifepristone-misoprostol-200mcg-pills-in-sharjah.html