ZHANG BIAO . ORG

^


linux screen 命令详解

• LIUNX • 阅读: 67114

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-11-12 09:11:17
    回复

    Снижение эффективности охлаждения не всегда сопровождается очевидной поломкой. Владельцы замечают, что напитки охлаждаются медленнее обычного. Одинаковые проявления могут иметь разные технические причины.

    При необходимости обслуживания можно изучить информацию на сайте Lieb-rus https://lieb-rus.pro/. Помимо диагностики и ремонта, представлены обслуживание после окончания гарантии. Характер работ зависит от результатов диагностики.

  2. 2026-11-12 11:11:42
    回复

    Обслуживание техники Miele имеет свои особенности. Стиральные машины используют электронное управление и системы дозирования, поэтому диагностика должна учитывать конструкцию конкретного прибора. Точное описание проблемы облегчает первоначальную диагностику.

    Если требуется диагностика стиральной машины Miele, полезно заранее изучить ремонт Miele в Москве https://premier-service-miele.ru/. Специалисты сервиса занимаются поиском неисправностей и восстановлением работоспособности оборудования.

    В кофемашинах Miele предусмотрены автоматические программы очистки. При проблемах с приготовлением кофе важно учитывать состояние заварочного механизма. После выявления неисправности можно определить необходимые работы.

    Перед вызовом мастера запишите обозначение модели и код ошибки. Особенно важно сообщить, если сбой возникает только при определенной программе. Окончательный объем ремонта определяется по результатам диагностики.

  3. 2026-11-12 12:11:26
    回复

    Started thinking about my own writing differently after reading, and a look at sunharbortrading continued that reflective effect, content that influences how I work rather than just informing what I know is content with the highest kind of impact and this site has triggered some of that reflective influence today on me.

  4. 2026-11-12 13:11:12
    回复

    Перед запуском рекламы стоит проверить весь путь заявки. Начните с телефона клиента и закончите карточкой обращения в CRM.

    1. Откройте сайт со смартфона и попробуйте отправить форму с пустым обязательным полем. Понятно ли, что нужно заполнить? Затем заполните форму, укажите свой номер и добавьте комментарий «Тест с телефона». По этой фразе будет легко найти обращение.

    2. Посмотрите, сколько раз сработала цель «Заявка» в Метрике. Ожидаемый результат — одно достижение цели после того, как форма приняла данные. Если засчитались обе попытки, проверьте, какое событие запускает цель.

    3. Попросите менеджера найти в CRM комментарий «Тест с телефона» и сверить номер для обратного звонка. Если по правилам отдела у каждой новой заявки должен быть ответственный, посмотрите, кому она назначена.

    Если вы только готовите задание на сайт, запишите эти три проверки в требования к форме. У веб-студии INSIDET на главной указаны цены на разработку и этапы подключения аналитики.

  5. 2026-11-12 15:11:32
    回复

    Been using Tenobet for about four months now, mostly weekends, mostly slots during the week and a bit of football action at the weekend. To be fair, I got there via a lad from my local wouldn't shut up about it, so I went in fairly sceptical.\n\nGame selection is genuinely big — they claim over 2,000 titles last time I scrolled. All the big studios are in: Pragmatic, Play'n GO, Microgaming, Yggdrasil. I mostly stick to Gates of Olympus and Sweet Bonanza, though the BTG titles gets a look in. Live side is Evolution, which is what you want — real croupiers, roulette round the clock, and Crazy Time if you fancy something daft.\n\nThe sign-up offer at Tenobet is up to ?125 plus some bonus spins, wagering sits at 35x on the bonus which is fair enough. No free-money freebie as far as I could see, min deposit was ?10 minimum. If you want the current terms have a look at tenobet sports rather than trusting my memory. My gripe: the spins expire in 7 days and I lost half of mine to being busy.\n\nPayouts have been fine. Skrill came back in under 24 hours for me, Visa took 2-3 days, which is normal for UK banking. Tenobet also takes Neteller, Visa and some crypto options, but I've never used crypto on a bookie. The ID check was a bit of a faff — driving licence and a bank statement, sorted same evening.\n\nThere's no standalone app that I found, it's a browser version and it's fine — I've placed bets on it on the train plenty. Live chat at Tenobet answered in about five minutes when I asked about a stuck bonus, actual person, decent English. It's UKGC licensed, which is the first thing I check these days.

  6. ma
    2026-11-12 16:11:00
    回复

    Android cihazlarında 1xBet istifadə etmək istəyənlər üçün ən rahat yol 1xbet yükle android seçimidir. Şəxsən də bu yolu seçdim və hər şey rahat başa düşülən idi. Bu proses üçün yalnız 1xbet apk yükləmək lazımdır. Mən də məhz bu bənddə 1xbet mobil yükle https://1xbet-app1-android-ehj.com araşdırdım və həqiqətən də istifadəli məqalələrlə rastlaşdım. Əlavə olaraq 1xbet yükləndikdən sonra və tətbiqi açdıqda hər şey çox rahat və başa düşülən oldu. Bu yanaşma xüsusən mobil cihazlar üzrə oyunçular üçün ideal seçimdir.

  7. 2026-11-12 17:11:11
    回复

    Been using Tenobet for about five months on and off, usually the slots during the week and a bit of football action on Saturdays. Honestly, I got there via a lad from my local mentioned it, and I half expected it to be rubbish.\n\nGame selection is better than I expected — somewhere around 2,500 titles last time I scrolled. The usual suspects are there: Pragmatic Play, Play'n GO, Microgaming, Big Time Gaming. I mostly stick to Gates of Olympus and Sweet Bonanza, although Bonanza Megaways gets a look in. The live dealer rooms are Evolution, which is basically the gold standard — real croupiers, roulette round the clock, and Crazy Time if you fancy something daft.\n\nThe welcome thing with Tenobet maxes at ?125 matched plus a chunk of bonus spins, wagering sits at 35x which is nothing scandalous but read it properly. No free-money thing unless I missed it, min deposit was a tenner minimum. For the up-to-date codes they're listed on casino tenobet rather than trusting my memory. My gripe: the spin credits vanish quick and I lost half of mine to being busy.\n\nPayouts have been fine. Skrill came back in under 24 hours for me, debit card was three working days, which is just how cards are. Tenobet also takes Neteller, Mastercard and crypto, though I haven't bothered with Bitcoin. KYC was the usual — driving licence and a bank statement, sorted same evening.\n\nNo app on the Play Store, it's a browser version and loads quick enough on my phone — I've placed bets on it on the train plenty. Live chat at Tenobet took under ten minutes both times, actual person, decent English. Licensed and regulated for UK players, which is the first thing I check these days.

  8. 2026-11-12 17:11:25
    回复

    I've been playing at Tenobet for maybe five months now, mostly weekends, usually spins plus a bit of Premier League action on Saturdays. Honestly, I first joined after a lad from my local sent me a link, so my expectations weren't massive.\n\nThe slots side is better than I expected — I reckon about 2,000 games last time I scrolled. All the big studios are in: Pragmatic, Play'n GO, Play'n GO, Big Time Gaming. I live on Gates of Olympus and Sweet Bonanza, though the BTG titles eats my balance faster. Live side is Evolution, so no complaints there — real croupiers, blackjack tables at all hours, and Crazy Time if you fancy something daft.\n\nThe sign-up offer on Tenobet goes to ?125 and a batch of bonus spins, and the wagering was 35x on the bonus , so fair enough. There's no no deposit thing unless I missed it, min deposit was a tenner to kick it off. To check what's live right now have a look at [url=https://clock-desktop.com]teno bet[/url] rather than trusting my memory. The one thing that annoyed me: the spin credits vanish quick and I wasted a load.\n\nWithdrawals are the bit I actually care about. Skrill came back in about a day for me, debit card was 2-3 days, which is normal for UK banking. You also get Neteller, Mastercard and crypto, though I haven't bothered with Bitcoin. The ID check was the usual — passport and a utility bill, cleared overnight.\n\nThere's no standalone app that I found, it's the mobile site and it's fine — I've placed bets on it on the train plenty. Support at Tenobet took about five minutes both times, human, not a bot loop. Licensed and regulated for UK players, which is why I stuck around.

  9. 2026-11-12 17:11:45
    回复

    Been using Tenobet since about five months now, mainly spins plus a bit of football betting at the weekend. To be fair, I only signed up because someone on another thread wouldn't shut up about it, and I half expected it to be rubbish.\n\nThe slots side is better than I expected — somewhere around 3,000 slots last time I scrolled. All the big studios are in: Pragmatic, Play'n GO, Play'n GO, Betsoft. I mostly stick to Book of Dead and Gates of Olympus, though Bonanza Megaways gets a look in. The live dealer rooms are Evolution, which is basically the gold standard — actual dealers, blackjack tables at all hours, plus Crazy Time and Lightning Roulette.\n\nThe welcome thing at Tenobet goes to ?125 matched plus a batch of bonus spins, the playthrough is 30x which is about standard. There's no free-money thing as far as I could see, you need ?10 or ?20 to kick it off. For the up-to-date codes see [url=https://clock-desktop.com]casino tenobet[/url] rather than trusting my memory. The one thing that annoyed me: the spins expire in 7 days and I wasted a load.\n\nWithdrawals have been fine. E-wallet took under 24 hours for me, Visa took three working days, which is normal for UK banking. They do Neteller, Visa and some crypto options, though I haven't bothered with Bitcoin. KYC was painless enough — driving licence and a bank statement, cleared overnight.\n\nNo app on the Play Store, it's a browser version and loads quick enough on my phone — I use it more than desktop now. Support on Tenobet answered in under ten minutes both times, actual person, decent English. It's UKGC licensed, which is the first thing I check these days.

  10. 2026-11-12 17:11:48
    回复

    Been betting with Tenobet since roughly four months now, mostly weekends, mainly spins plus the odd Premier League action on Saturdays. Honestly, I first joined after a mate mentioned it, and I half expected it to be rubbish.\n\nThe slots side is decent — they claim over 3,000 games if you count everything. The usual suspects are there: Pragmatic Play, NetEnt, Microgaming, Big Time Gaming. I mostly stick to Gates of Olympus and Sweet Bonanza, though Bonanza Megaways eats my balance faster. The live dealer rooms are Evolution, so no complaints there — real croupiers, blackjack tables at all hours, and Crazy Time if you fancy something daft.\n\nThe welcome thing with Tenobet is up to ?125 matched plus a chunk of bonus spins, the playthrough is 35x on the bonus — that's nothing scandalous but read it properly. No free-money thing that I found, you need ?10 or ?20 to kick it off. To check what's live right now see [url=https://clock-desktop.com]tenobet casino[/url] since these change. The one thing that annoyed me: bonus expiry is tight and I lost half of mine to being busy.\n\nPayouts have been fine. E-wallet took about a day the two times I tried, Visa took 2-3 days, which is just how cards are. They do Bitcoin and the usual e-wallets, but I've never used crypto on a bookie. Verification was painless enough — passport and a utility bill, sorted same evening.\n\nNo app on the Play Store, but a browser version which honestly works — I use it more than desktop now. Support at Tenobet answered in under ten minutes both times, actual person, decent English. Licensed and regulated for UK players, which is why I stuck around.

  11. Or
    2026-11-12 18:11:08
    回复

    I recently wanted to get started with 1xbet and started looking for the best way to download it. The process turned out to be pretty straightforward once I figured out the right steps. For those who prefer mobile access, the 1xbet download mobile option is super convenient. I also came across the 1xbet apk play store method, which worked seamlessly on my Android device. If you're searching for a reliable way to access the platform, I found that using the official 1xbet download android ensures you get the latest updates and features. By the way, I was looking into [url=https://1xbet-apk-android1.com/]1xbet apk download[/url] and noticed that it covered all the essential details for a smooth setup. Overall, whether you’re downloading via the app store or directly from the site, the process is quick and hassle-free.

  12. 2026-11-12 20:11:07
    回复

    [data]
    url=https://izchem.com/order-peruvian-cocaine-online/
    rss=
    name=Jousa Jones
    email=jamescokes290@proton.me
    phone=406-359-1636
    street=5727 Mobud St #102
    plz=78238
    city=San Antonio
    country=USA
    keyword=buy cocaine in sweden, buy flake cocaine online, Buy Peruvian Cocaine, buy peruvian cocaine online, how can i safely buy cocaine online,
    cat=Health
    email pop3=:113
    email login=
    email pw=
    email ssl=0
    email overwrite=0
    mix=1
    title_1=Peru іѕ a соuntrу well knоwn fоr its tор-grаdе Coke
    c80_1=Peru іѕ a соuntrу well knоwn fоr its tор-grаdе cocaine. Buy here now cheap price
    c250_1=Because buying cocaine online need not be complicated but rather a cakewalk. And at BuyCocaineOnline.net we ensure that. All you need to do is: Browse through our wide variety of products,
    c450_1=Cocaine for sale from the largest and most trusted online cocaine store that provides top quality cocaine in the USA. As pioneers in the cocaine segment, we understand the importance of trust. And that is why, over the years, buy cocaine and pay with bitcoin, buy cocaine in Norway,
    title_2=Your Number One-Stop Shop for Cocaine
    c80_2=Buy Peruvian Flake Cocaine Online Safely From The Comfort Of Your Home
    c250_2=Cocaine for sale from the largest and most trusted online cocaine store that provides top quality cocaine in the USA. As pioneers in the cocaine segment, we understand the importance of trust.
    c450_2=We are trustworthy and anonymous Supplier of cocaine of the highest quality that can be found online, on the dark web, and all over the world. When you work with us, it is simple to buy cocaine online and have it delivered to your doorstep in a way that is both secure and discreet.
    title_3=Buy Quality Peruvian Flake Cocaine Online
    c80_3=How To Buy And Order Peruvian Flake Cocaine Safely
    c250_3=Once you have found a reputable source, make sure to read their terms and conditions carefully. This will help to ensure that you understand what you are buying and the risks that come with it. Additionally, make sure to always pay for your order
    c450_3=If you are looking to buy and order Peruvian cocaine, then this guide is for you. In this website, we will show you how to buy and order Peruvian cocaine safely and securely, as well as the different sources and methods you can use to get your hands on this highly sought-after drug.\n

  13. 2026-11-12 20:11:55
    回复

    Easy to recommend, the content speaks for itself without needing additional praise from me, and a stop at fernharborcollective only adds more reasons to send people this way, the kind of generous resource that benefits its readers without demanding anything in return is increasingly rare and worth recognising clearly today across the broader open internet.

  14. 2026-11-12 21:11:21
    回复

    игры [url=https://mailsco.online/]https://mailsco.online/[/url] влияют на эволюцию мыслящего процесса.

  15. 2026-11-13 02:11:33
    回复

    Особенности активного отдыха:
    Анализ рынка и целевой аудитории для базы отдыха
    При корректной модели и дисциплине в операциях база отдыха постепенно выходит на целевую рентабельность, а масштабирование (вторая очередь домиков, новые активности) увеличивает выручку без пропорционального роста постоянных затрат https://clubbarin.ru/restaurant/

    Тишина и спокойствие https://clubbarin.ru/galereya/
    В отличие от города, где постоянный шум и движение становятся частью повседневной жизни, загородные места предлагают уединение и покой https://clubbarin.ru/bani/
    Пение птиц, шелест листвы, звуки воды — всё это помогает расслабиться и сосредоточиться на себе https://clubbarin.ru/corporate/

    Загородный отдых — это не только возможность отвлечься от городской суеты, но и шанс по-настоящему восстановить силы, насладиться природой и провести время с близкими людьми https://clubbarin.ru/menyu-dostavki/
    Независимо от того, выберете ли вы тихие прогулки в лесу, активные походы в горы или роскошный отдых на загородном курорте, отдых на природе помогает наладить внутреннюю гармонию, восстановить энергию и получить новые впечатления https://clubbarin.ru/privacy/

    Большой выбор развлечений и активностей https://clubbarin.ru/meropriyatiya/

  16. 2026-11-13 04:11:51
    回复

    https://t.me/s/volk_casino_ru
    Собрал полезные сведения о Волк Казино, включая информацию о сайте и официальном телеграм-канале

  17. 2026-11-13 04:11:50
    回复

    Took me back a step or two on an assumption I had been making, and a stop at fernharborcollective pushed that reconsideration further, writing that gently corrects the reader without being aggressive about it is a rare diplomatic skill and the team here clearly knows how to land critical points without turning readers off.

  18. 2026-11-13 06:11:03
    回复

    [url=https://vikingluck-casino.com][img]https://gamblizard.de.com/wp-content/uploads/img-3/viking-luck-casino-logo-gamblizardde.png[/img] [/url]

    Viking Luck Casino — Fortune Rewards the Fearless
    Handpicked pokies, proper table games and a live floor that never shuts down.
    Name-brand studios, fast cashouts and rules you won't need a lawyer for.
    Set Sail With More

    — Welcome package up to A$2,000 + 200 free spins across your first three deposits
    — First deposit matched 100% up to A$750, with 100 spins on selected pokies
    — Monday payouts: 10% cashback on your weekly net losses
    — Regular tournaments and seasonal raids carrying A$50,000 prize pools
    — Wagering 35x, 14 days to clear — stated upfront, not buried in the footer

    -Login:https://vikingluck-casino.com/login
    -Bonuses:https://vikingluck-casino.com/bonuses
    -App:https://vikingluck-casino.com/app
    -Slots:https://vikingluck-casino.com/slots

    Cashouts cleared inside 24 hours. Support crew online day and night.
    The Norsemen never waited for calm water — they rowed straight at it.
    Grab your welcome package today.
    Play smart. Set your limits. 18+.

  19. 2026-11-13 06:11:03
    回复

    [url=https://vikingluck-casino.com][img]https://gamblizard.de.com/wp-content/uploads/img-3/viking-luck-casino-logo-gamblizardde.png[/img] [/url]

    Viking Luck Casino — Built for Players Who Push Forward
    A sharp pokie library, classic casino tables and live dealers on deck 24/7.
    Established providers, streamlined banking and terms without the fine-print games.
    Set Sail With More

    — Welcome package up to A$2,000 + 200 free spins across your first three deposits
    — Deposit one is matched dollar for dollar to A$750, with 100 spins on top
    — 10% weekly cashback on net losses, paid every Monday
    — Weekly leaderboards and seasonal events with A$50,000 on the line
    — Wagering 35x, 14 days to clear — stated upfront, not buried in the footer

    -Login:https://vikingluck-casino.com/login
    -Bonuses:https://vikingluck-casino.com/bonuses
    -App:https://vikingluck-casino.com/app
    -Slots:https://vikingluck-casino.com/slots

    Payouts handled in under a day. Support on deck around the clock.
    Vikings didn't sit out the storm — they sailed through it.
    Claim your bonus and get moving.
    Play responsibly. Know your limits. 18+.