ZHANG BIAO . ORG

^


linux screen 命令详解

• LIUNX • 阅读: 69165

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-07-25 05:07:57
    回复

    1вин кыргызча расмий сайт http://1win41943.icu

  2. 2026-07-25 05:07:07
    回复

    Играю на 888starz месяца три, поэтому накидаю как оно по факту. Зашёл случайно, особо не ждал ничего, но остался. Создание аккаунта быстрая, без нервов — почту и телефон и всё, верификацию попросили только перед первым выводом. Минималка смешной, начинал с сотки рублей, чтобы пощупать.

    С играми тут глаза разбегаются — где-то около 3000 тайтлов. Провайдеры которым доверяешь: Pragmatic Play, NetEnt, Play'n GO, плюс Yggdrasil и Betsoft. Из любимого Gates of Olympus плюс Sweet Bonanza, иногда заглядываю в Book of Dead. Что порадовало стол с дилерами от Evolution — живые ведущие, их game show весело, хотя честно это лотерея.

    Насчёт приветственного грех жаловаться: накидывают бонус на первый деп плюс около 150 фриспинов. Отыгрыш как везде не подарок, так что читайте правила — я по первости не вкурил и подарок сгорел. Если интересно свежие условия и рабочие бонусы проще всего глянуть через 888starz скачать iphone чтобы не пролететь, цифры реальные. Периодически бывает небольшой ноудеп, но надо ловить момент.

    С выплатами что решает, и тут без криминала. Способов куча: Visa, Mastercard, Skrill и Neteller, ну и USDT. Криптой падает минут за 10-15, карты бывает до пары часов. Последний раз заказал — деньги пришли за полчаса. Единственное что напрягает — под выходные просят допверификацию, разово было.

    Мобилка отдельная тема: можно скачать 888starz на телефон, под iOS через профиль без танцев с бубном. Достать реально прямо с сайта, веб-версия работает шустро. Саппорт на связи круглосуточно, по-русски без ботов-тупиков. По документам есть кюрасаовская лицензия — для такого казино нормально. По итогу меня устраивает, 888starz один из рабочих вариантов, хотя идеала нет.

  3. 2026-07-25 05:07:18
    回复

    Кручу барабаны на 888starz уже пару месяцев, так что накидаю своими впечатлениями. Попал сюда по совету знакомого, скептически был настроен, но в итоге залип. Создание аккаунта быстрая, без нервов — почту и телефон и всё, верификацию попросили только перед первым выводом. Минималка копеечный, я закинул с мелочи, чтобы осмотреться.

    С играми тут реально жирно — где-то за пару тысяч позиций. Софт все топовые: Pragmatic Play, NetEnt, Play'n GO, а также Yggdrasil и Betsoft. Из любимого Gates of Olympus да Sweet Bonanza, под настроение захожу в Book of Dead. Плюсом идёт живой раздел от Evolution — живые ведущие, шоу типа Crazy Time весело, хотя на дистанции чаще сливаешь.

    По бонусам грех жаловаться: стартовый бонус на первый деп и ещё около 150 фриспинов. Условия отыгрыша честно говоря кусается, поэтому читайте правила — сам пролетел с этим по глупости. К слову актуальные промокоды и текущие предложения удобнее сверять через 888 starz skachat прежде чем заводить деньги, инфа не протухшая. Периодически бывает бонус за регистрацию, но надо ловить момент.

    С выплатами для меня главное, и тут претензий нет. Методов навалом: Visa, Mastercard, кошельки, плюс крипта. Криптой быстрее всего, карты дольше. Недавно снимал — дошло без волокиты. Что бесит — иногда могут придраться к докам, терпимо.

    Мобилка радует: есть apk под андроид, на айфон через профиль чуть муторнее. Скачать можно через зеркало, веб-версия работает шустро. Техподдержка отвечает круглосуточно, по-русски обычно за пару минут. По документам легально по Curacao — доверия добавляет. В общем пока не ушёл, 888starz свою нишу занял, но мелкие косяки есть везде.

  4. 2026-07-25 05:07:41
    回复

    Bookmark earned, calendar reminder set, share queued, all from one good post, and a look at securebusinessrelationships did the same, when a single reading session triggers multiple downstream actions you know the content has actually moved me beyond the page and this site is moving me at that higher level reliably.

  5. 2026-07-25 05:07:45
    回复

    мелбет пополнение россия http://melbet19011.online

  6. 2026-07-25 05:07:48
    回复

    mostbet oldal nem nyílik meg https://www.mostbet11366.icu

  7. 2026-07-25 05:07:19
    回复

    Really like that there are no exclamation marks or all caps shouting throughout the post, and a quick visit to globalonlinebuyinghub maintained the same calm voice, restraint in punctuation signals confidence in the content and this site clearly trusts its substance to do the persuading rather than relying on typographic emphasis.

  8. 2026-07-25 05:07:08
    回复

    Right, someone on another thread put me onto true fortune casino around Christmas and I've been playing fairly regularly since. Playing from the UK so the first thing I checked was the deposit options, and no complaints there so far.

    The game library is genuinely huge, I'd guess around a couple of thousand titles last I looked. Loads from Pragmatic Play, NetEnt, Play'n GO, Yggdrasil and Big Time Gaming all in there. I tend to stick to Gates of Olympus, and a bit of Book of Dead when I'm bored, but finding a specific slot takes a minute. For live casino fans, it's Evolution powering the live rooms — real croupiers, roulette and blackjack and Crazy Time and the other game shows if that's your thing.

    On the bonus side, the sign-up package was decent enough — a deposit match plus a chunk of free spins. Make sure you read the wagering first, I think it was 35x which is standard-ish but adds up. There's usually a no-deposit chip floating around too, so you can see what's live at true fortune no deposit bonus codes 2025 rather than taking the first thing you see. Min deposit is low, about ?10 I think, so no need to commit much to test it.

    Withdrawals have been the bit I care about most. Payments-wise I stick to Mastercard and Neteller, and they take crypto and Bitcoin if you prefer. Skrill withdrawals cleared within a day or two, but card ones dragged a bit. My only real moan — verification took a couple of goes before it went through.

    The mobile side is solid — no separate app but you don't really need one, loads quick on my Android. Live chat has been decent, answered within a few minutes. Licensing checks out, which is the main thing for me. Not perfect, but for a casual few spins it does the job.

  9. 2026-07-25 05:07:33
    回复

    Right, a bloke at work put me onto true fortune casino last year and I've been on it ever since. As a UK player so the first thing I checked was the deposit options, and it's all been smooth enough.

    Game-wise there's honestly massive, I'd guess around a couple of thousand slots and table games last I looked. They've got Pragmatic Play, Play'n GO, Play'n GO, Yggdrasil and Microgaming all in there. I tend to stick to Sweet Bonanza and Book of Dead, though the filtering is a bit clunky if I'm honest. If you're into live stuff, Evolution handle the live dealers — actual human dealers, blackjack, roulette and the game shows like Crazy Time which I get sucked into more than I should.

    As far as offers go, the sign-up package was pretty generous — a deposit match plus a chunk of free spins. Make sure you check the wagering first, mine was around 35x which is standard-ish but adds up. There's usually a no-deposit chip floating around too, so it's worth a see what's live over on fortune casino rather than taking the first thing you see. Min deposit is low, think it was a tenner, so no need to commit much to test it.

    Cashouts are where they've mostly delivered. I've used Skrill and the odd card deposit, there's also Neteller, crypto, the usual e-wallets. My e-wallet payouts landed in about 48 hours, though the card cashout took longer. The one thing that annoyed me — they asked for ID twice before it went through.

    Runs fine on mobile — no app needed, loads quick on my iPhone. Live chat has been decent, answered within a few minutes. They're regulated, which put my mind at ease. Won't pretend it's the best thing ever, but I keep coming back so that says something.

  10. 2026-07-25 05:07:49
    回复

    A piece that demonstrated competence without performing it, and a look at buildfuturefocusedpaths maintained the same self assured but unshowy register, the gap between competence and performance of competence is one I track and this site has clearly chosen to demonstrate rather than perform which I find much more persuasive as a reader.

  11. 2026-07-25 05:07:04
    回复

    Bookmark added without hesitation after finishing, and a look at clickfornewideas confirmed I should bookmark the homepage too rather than just this page, the rare site that earns category level trust rather than just single article approval is the kind I want to rely on across many different topics over time.

  12. 2026-07-25 05:07:39
    回复

    If I had to defend the time I spend reading independent blogs this site would feature in the defence, and a look at shopward reinforced that defensive utility, the ongoing case for non algorithmic reading is one I make to myself periodically and sites like this one provide the actual evidence that supports the case clearly.

  13. 2026-07-25 06:07:07
    回复

    Thanks for the clean writing, no broken sentences and no awkward translations like some other sites have, and a quick stop at pathclick kept that polish going nicely, it really does make a difference when a reader can move through a page without tripping on every line or going back to reread.

  14. 2026-07-25 06:07:23
    回复

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

    اللي بيوفروا الألعاب ناس محترمين زي Pragmatic Play وNetEnt. أنا بلعب كتير على سويت بونانزا وجيتس أوف أوليمبوس، وبحب كمان Book of Dead. لو مش من هواة السلوتس فيه قسم اللايف من Evolution بكروبيهات حقيقيين، وشوز زي كريزي تايم بتكسر الملل.

    بالنسبة للبونص كويس: الديبوزيت الأول بياخد بونص 100% ومعاه لفات مجانية، وفيه no deposit لو بتحب تجرب الأول. بس انتبه لحتة من شرط المراهنة اللي حوالي أربعين مرة — دي حاجة كتير بينسوها. لو عايز تشوف الأكواد الحالية شوفها عند تحميل 888starz وانت مطمن.

    اللي مريّحني إن فيه أكتر من وسيلة: فيزا وماستركارد، وسكريل ونتلر، وكمان كريبتو وبيتكوين. الـwithdrawal بياخد يوم لتلاتة على المحفظة، مقارنة بحاجات تانية سحبت منها. التسجيل نفسه مش معقد، والحد الأدنى للإيداع بسيط.

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

    في العموم أنا كمّلت عليه أكتر مما توقعت، و888starz apk هو اللي بلعب عليه أغلب الوقت. منظّم ومرخّص، وده بيريّح وانت بتحط فلوسك. لو حد جرّبه يشاركنا.

  15. 2026-07-25 06:07:45
    回复

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

    مطوري الألعاب ناس محترمين زي Pragmatic وPlay'n GO وBetsoft. أنا مدمن سويت بونانزا وجيتس أوف أوليمبوس، ومن وقت للتاني بجرب Book of Dead. اللي مبيحبش السلوتس فيه قسم اللايف من Evolution بموزعين حقيقيين، وشوز زي كريزي تايم بتكسر الملل.

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

    نقطة مهمة لينا كمصريين إن فيه أكتر من وسيلة: كروت بنكية، ومحافظ زي Skrill وNeteller، وكمان Bitcoin. السحب أسرع مع الكريبتو صراحة، مش زي مواقع بتماطل أسبوع. التسجيل نفسه مش معقد، والحد الأدنى للإيداع بسيط.

    اللي مضايقني شوية إن السابورت أحيانًا بيرد ببطء، ومرة قعدت مستني رد. غير كده تحميل التطبيق للأندرويد بيطلب إعدادات يدوية شوية، حاجة عادية بس مبتدئ ممكن يلخبط. 888starz apk شغال حلو على الموبايل وبيجيله تحديثات باستمرار.

    بعد كل التجربة دي أنا مبسوط أكتر مما توقعت، والتطبيق بقى أساسي على موبايلي. منظّم ومرخّص، وده حاجة مهمة وانت بتحط فلوسك. لو عندك سؤال اسأل.

  16. 2026-07-25 06:07:38
    回复

    Picked a single sentence from this post to remember, and a look at digitalbuyingexperience gave me another to keep, content that produces memorable lines is doing more than just transferring information and the small selection of sentences I keep from each reading session is one of the actual returns I get from reading carefully.

  17. JimmyVet
    2026-07-25 06:07:09
    回复

    https://gidromashin.com/product-category/zapchasti-k-gidronasosam/page/24/

  18. 2026-07-25 06:07:11
    回复

    A particular kind of restraint shows up in the writing, and a look at discoverbusinessdirections maintained the same restraint across pages, knowing what not to say is just as important as knowing what to say and this site has clearly developed strong instincts on both sides of that editorial line throughout pieces I have read.

  19. 2026-07-25 06:07:31
    回复

    Started a draft response in my head and ended without publishing it because the post said it well enough, and a look at trustedenterprisealliances produced the same effect, content that satisfies my urge to add to it by being complete enough on its own is rare and represents a particular kind of editorial completeness here.

  20. 2026-07-25 06:07:26
    回复

    Worth saying that the writing carries a particular kind of authority without making any explicit claims to it, and a stop at everydayvaluepurchase extended that earned authority feeling, sites that demonstrate expertise through the quality of their explanations rather than by stating credentials are sites I trust most and this site has it.