ZHANG BIAO . ORG

^


linux screen 命令详解

• LIUNX • 阅读: 67285

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-09-15 23:09:50
    回复

    Miami is all about making an impression, and your car sets the tone for everything. Some had decent cars but felt impersonal. Then I found the right place. rent a luxury car miami — the fleet was top-tier. The staff was incredibly professional and easy to work with. Every drive became a highlight of the trip. If you're heading to Miami and want to make your trip stand out. exotic car rental miami exotic car rental miami Save it, share it, don't lose it for South Beach. If you want a luxury car in Miami — just use the link. Luxury car rental Miami — make every mile memorable!

  2. 2026-09-15 23:09:43
    回复

    Took a quick scan first and then went back to read properly because the post deserved it, and a stop at dumbbelldrift kept me reading carefully too, the kind of writing that earns a slower second pass rather than getting skimmed and forgotten is something I value highly when I happen to find it.

  3. 2026-09-16 01:09:09
    回复

    Ən çox diqqət etdiyim şey bonus şərtləri idi. İlk depozitdən sonra xoş gəlmə bonusu əldə etdim. 1xbet bonusları — bonuslar həm idman mərclərinə, həm də kazino oyunlarına aiddir. Bonus şərtləri şəffafdır və sadədir. Və onlardan istifadə etmək çox rahatdır. 1xbet bonus shartlari 1xbet bonus shartlari Bonusları vaxtında aktivləşdirin, qaçırmayın üçün Bakı. 1xbet bonus ilə əlavə qazanc əldə etmək istəyirsinizsə — linkə keçin. 1xbet bonus — daha çox imkan, daha çox uduş!

  4. 2026-09-16 07:09:23
    回复

    Miami is a city that thrives on style and energy. A few companies caught my attention, but many had limitations. Then I found a company that truly delivered. rent a luxury car miami — the fleet was incredible. The staff was professional and genuine. It added a whole new level of excitement to my trip. If you want a rental experience that stands out. miami exotic car rentals miami exotic car rentals Save it, share it, don't lose it for South Florida. If you want a luxury car in Miami — just use the link. Luxury car rental Miami — drive the dream!

  5. 2026-09-16 08:09:03
    回复

    Closed three other tabs to focus on this one and never opened them again, and a stop at kitchenkismet similarly held attention exclusively, content that crowds out other reading from working memory is content with real density and this site has demonstrated that density across multiple pages I have visited so far this morning.

  6. 2026-09-16 09:09:38
    回复

    I wanted to make sure I fit the vibe, so I started looking for a premium rental. Others had great reputations but were out of my budget. Then I found the sweet spot. luxury car rental miami — Every car was clean, polished, and ready to go. No pressure, no gimmicks — just good service. Cruising through Miami Beach felt like a dream. If you want a car that makes a statement and delivers on performance. miami supercar rental miami supercar rental Check the link for the full fleet and pricing for South Beach. It's the easiest way to make your trip unforgettable. Luxury car rental Miami — arrive in style, leave with memories!

  7. 2026-09-16 09:09:19
    回复

    If you've ever been to Miami, you know it's a city that demands style. I spent some time researching rental options before my trip. Fortunately, I stumbled upon exactly what I was looking for. rent a luxury car miami — I was genuinely impressed. The team made the process simple and stress-free. I couldn't have asked for a better experience. If you're looking for a car that matches the city's energy. rental luxury car miami rental luxury car miami Save it, share it, don't lose it for South Beach. If you want a luxury car in Miami — just use the link. Luxury car rental Miami — drive in style, create memories!

  8. 2026-09-16 12:09:14
    回复

    Onlayn mərc edən hər kəs bilir ki, promo kodlar əlavə üstünlük deməkdir. Hər dəfə yeni mövsüm, böyük turnir və ya bayram günlərində. 1xbet promo kodlar — depozit miqdarım artır. Heç bir gizli məqam yoxdur. Beləliklə, hər kəs özü üçün faydalı bir şey tapa bilər. 1xbet promo kodu 1xbet promo kodu Bütün aktiv promo kodlar, şərtlər və istifadə qaydaları buradadır üçün region. 1xbet promo kodu ilə əlavə bonus əldə etmək istəyirsinizsə — linkə keçin. 1xbet promo kodu — daha çox imkan, daha çox uduş!

  9. 2026-09-16 12:09:24
    回复

    I wanted to feel the energy of the city from behind the wheel of something truly special. I needed a place with a great selection, fair pricing, and solid reviews. luxury car rental miami — Everything was clean, polished, and ready to impress. The staff was warm and professional. I chose a car that was perfect for cruising around Miami. If you're planning a trip to Miami and want to make it memorable. real car rental https://luxury-car-rental-miami-bvk.com Save it, share it, don't lose it for South Florida. It's the easiest way to turn your trip into an unforgettable experience. Luxury car rental Miami — arrive in style, leave with stories!

  10. 2026-09-16 12:09:42
    回复

    Thank you for the genuine effort here, it shows in every paragraph and not just the headline, and after my visit to supplystack I was sure this site cares about getting things right rather than chasing clicks, which is the main reason I will come back later this week to read more.

  11. 2026-09-16 15:09:47
    回复

    Thanks for putting this online without locking it behind email signups or paywalls, and a quick visit to breakfastbay kept that open feel going, content that trusts the reader to come back rather than gating access is the kind of approach I will reward with regular return visits over time happily.

  12. 2026-09-16 17:09:23
    回复

    Mobil cihazlardan mərc etmək üçün ən yaxşı həll yolu tətbiqi yükləməkdir. Tətbiq daha sürətli, daha rahat və daha sabit işləyir. 1xbet yukle — bir neçə dəqiqəyə yüklənir. Tətbiq bütün funksiyaları özündə birləşdirir: idman mərcləri, kazino, canlı yayımlar, ani ödənişlər. 1xbet tətbiqi ilə mərc etmək daha zövqlüdür. xbet yukle xbet yukle Yükləyin, quraşdırın, başlayın üçün Azərbaycan. Bu, ən rahat yoldur. 1xbet yüklə — hər zaman, hər yerdə mərc et!

  13. 2026-09-17 06:09:20
    回复

    So I decided to go with something more premium. I looked at a few different rental companies before my trip. Then I found a company that stood out from the rest. rent a luxury car miami — Every vehicle was in top condition. They made sure I understood everything and helped me find the right car. I picked a car that was perfect for the trip. If you're heading to Miami and want a car that matches the city's energy. miami supercar rental miami supercar rental Save it, share it, don't lose it for South Florida. If you want a luxury car in Miami — just use the link. Luxury car rental Miami — drive the dream!

  14. 2026-09-17 08:09:30
    回复

    Искал нормальную букмекерскую контору — сказали, что в Азербайджане всё работает стабильно. 1xbet вход — всё просто и понятно. Большой выбор спортивных событий. Бонусы для новых игроков и постоянные акции. Уже несколько месяцев играю — никаких проблем. 1xbet регистрация 1xbet регистрация Сохраните, поделитесь, не потеряйте для Баку. Это самый надёжный способ. 1xbet — это просто, быстро и всегда доступно!

  15. fortuna_vaMa
    2026-09-17 10:09:31
    回复

    Lange nur gelesen, jetzt schreibe ich selbst, und bei Play Fortuna taucht immer die gleiche Frage auf: Betrug oder serioes. Ich spiele dort seit dem Winter, also rede ich nicht von Geruechten aus zweiter Hand. Vorab: bei mir wurde keine Auszahlung verweigert, aber es gibt Punkte, die man kennen sollte.

    Zum rechtlichen Teil: der Anbieter arbeitet mit einer Curacao Lizenz, nicht die deutsche Aufsicht. Das heisst nicht automatisch Betrug, bedeutet aber, dass man sich bei Streit nicht an eine deutsche Behoerde wenden kann. Wer das nicht moechte, sollte die Finger davon lassen. Das 1000 Euro Limit pro Monat gibt es dort nicht, was Vor- und Nachteil zugleich ist.

    Zum Bonus - hier entstehen die meisten Beschwerden. Angeboten wird ein Match Bonus samt Freispielen, mit einem Umsatz von 40x. Wichtig ist das Einsatzlimit pro Dreh im Bonus, wer darueber geht, dem wird der Gewinn gestrichen. Die gueltigen Bonusregeln stehen auf play fortuna casino abzocke am besten vorher durchlesen.

    Zu den Zahlungen: bis etwa 300 Euro ging es binnen 24 Stunden, bei ueber tausend Euro waren es mehrere Werktage. Fuer das KYC brauchte es Perso und eine Rechnung, die erste Rechnung war zu alt und wurde abgelehnt, der zweite Versuch klappte sofort. Wer die Papiere erst am Ende einreicht, muss mit Verzoegerung rechnen.

    Mein Fazit: von Betrug wuerde ich nach meiner Erfahrung nicht sprechen, wohl aber ein Angebot, bei dem man selbst aufpassen muss. Der Grossteil der Kritik kommt von Leuten, die Bonusbedingungen gebrochen haben, weniger um reale Auszahlungssperren. Verifizierung sofort, Bonus nur mit gelesenen Regeln - so entfallen die typischen Streitpunkte.

  16. 2026-09-17 11:09:32
    回复

    After a long flight, the last thing I wanted was a boring rental car. Sedans, compact cars, and the occasional minivan. That's when I discovered a game-changer. premium car rental Miami Airport with RealCar — Located right near the airport, easy to find. Drove straight from the airport to South Beach. Just a smooth start to my trip. They were flexible with timing. If you're flying into Miami and want to arrive in style. luxury cars rental Miami RealCar luxury cars rental Miami RealCar Check the link for the full fleet and pricing for the area. It's the easiest way to start your Miami trip. RealCar — arrive in luxury, drive in style!

  17. 2026-09-17 17:09:44
    回复

    After a long flight, the last thing I wanted was a boring rental car. Nothing that matched the Miami vibe. That's when I discovered a game-changer. luxury car rental at Miami Airport by RealCar — And the fleet was absolutely stunning. I picked a sleek convertible. Just a smooth start to my trip. They were flexible with timing. If you want a premium car ready for you as soon as you land. RealCar luxury car rentals Miami Airport RealCar luxury car rentals Miami Airport Save it, share it, don't lose it for Miami. Want a luxury car waiting for you at MIA — just use the link. RealCar — arrive in luxury, drive in style!

  18. 2026-09-17 20:09:58
    回复

    Работаю заведующим отделением в больнице. Но когда столкнулся с оптимизацией работы отделения. Менеджмент в здравоохранении — решил пройти профессиональную переподготовку. Теперь применяю это на практике. Отделение стало работать эффективнее. Советую всем руководителям в медицине. работники медицинских организаций государственной системы здравоохранения работники медицинских организаций государственной системы здравоохранения Сохраните, поделитесь, не потеряйте для России. Это надёжный путь к росту. Менеджмент в здравоохранении — управляй качеством!

  19. 2026-09-17 21:09:55
    回复

    Now realising the post has been quietly doing important work in my mind for the past hour, and a stop at horrorhubshop extended that quiet processing, content that continues to do work after I close the tab is content with afterlife in the mind and this site is producing those long lived effects at a meaningful rate.

  20. 2026-09-18 04:09:05
    回复

    Ne yapsam boş, çünkü doğru kod olmadan ekstra bonus gelmiyor. 1xbet promosyon kodu 2026 — kayıt olurken bu kodu girmen gerekiyor. Kayıt ekranında promosyon kodu alanı var. 1xbet promosyon kodu nasıl kullanılır diye düşünenler için. Şimdi düzenli olarak promosyonları takip ediyorum. 1xbet promo code turkey 1xbet promo code turkey Linke göz atın için şehir. En kolay ve güvenilir yol bu. 1xbet promosyon kodu — daha fazla kazanç, daha fazla şans!