当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 20 篇帖子 ]  前往页数 1, 2  下一页
作者 内容
1 楼 
 文章标题 : [wiki]GNU Screen: an introduction and beginner's tutorial
帖子发表于 : 2005-08-24 16:30 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
GNU Screen: an introduction and beginner's tutorial

By jeduthun
Wed Mar 10th, 2004 at 07:23:33 PM EST

Most modern Unix-based operating systems (e.g. Linux, MacOS X, and BSD) come with a little console-mode utility called GNU Screen. It's a powerful tool in the hands of the console warrior, a veritable Swiss Army knife of text-mode human-computer interaction.

This utility, despite its considerable usefulness, goes unused by a great many people. Why is this? Few people even know it's there, and those that do rarely understand the problem it solves. In this article, I will explain what screen does for you, and provide a simple set of instructions for accomplishing basic tasks using screen. My audience is those that are skilled with the command line but who have little or no experience with screen itself.




What screen does

Screen is best described as a terminal multiplexer. Using it, you can run any number of console-based applications--interactive command shells, curses-based applications, text editors, etc.--within a single terminal. The desire to do this is what gets most people hooked on screen. I used to start a half-dozen terminal emulators when I logged into my machine: I wanted one to read my email, one to edit my code, one to compile my code, one for my newsreader, one for a shell into my web host, and so on. Now I start one terminal emulator, and run screen in it. Problem solved.

The other main cool feature of screen is its ability to decouple the terminal emulator from the running programs. This means that you can use screen to keep programs running after you accidentally close the terminal emulator, or even after you log out, and later resume right where you were. It means that the idea of a "session" in which you are running a number of console programs is a free-floating entity that you can bind to any terminal anywhere, or no terminal at all if you want.

Getting started with screen: launching and switching between programs

Start screen just by typing screen at your favorite command shell prompt. You'll probably be greeted by a welcome message. Dismiss this and you'll have with an empty terminal containing a shell prompt, which is pretty much what you had before you started screen. What happened?

Every program running under screen runs in a window, and every window is identified by a unique number. Screen made a new window, numbered it 0, and started a command shell inside it. Type something in your new window so you'll be able to recognize it when you switch to it later.

Now make another window; this will be window 1. To do this, type C-a c; that is, type Ctrl-a and then type c (mnemonic: create window).

Now that you have two windows, try switching between them. To do this, type C-a C-a, which will switch you to whichever window you were using before the current one. Some other useful window switching methods, which you'll need if you plan to run more than two programs:

1. Use C-a n and C-a p to switch to the next or previous window in the list, by number.
2. Use C-a N, where N is a number from 0 to 9, to switch to the corresponding window.
3. Use C-a " to get a full-screen list of windows. You can navigate this list with the arrow keys (or vi-style, with j and k), and pick a window to activate by pressing Enter when it's highlighted. C-a w will give you a small, non-interactive list of windows.

When you're using a window, type C-a A to give it a name. This name will be used in the window listing, and will help you remember what you're doing in each window when you start using a lot of windows.

Exiting the last program in a window will cause the window to disappear. You can also kill misbehaving programs with C-a K.

Detaching and reattaching: the magic of terminal decoupling

If you did the exercise above, you have successfully created a screen session. You can detach from this session by pressing C-a d. You can also detach just by closing the terminal emulator that contains the session. However, keep in mind that neither of these actually end your session. All they do is unbind your session from the current terminal. All of the programs you started running within screen are still running. Really.

Try it: just close whatever terminal emulator you were using to do the exercise above. Then log out, and log back in, if you desire. Start up a new terminal emulator, and type screen -r (the R, obviously, stands for "reattach"). You'll be right back where you were when you detached.

You can probably imagine a lot of good uses for this. You can start all your favorite console programs once and just leave them running in a persistent screen session. Some people have "screen uptimes" of several months.

One other good use for the detach and reattach is as a console-mode "remote desktop" feature. You can detach from a screen session at work, shell into the machine from home, and reattach. Very, very handy. With a bit of extra work, you can even have a number of terminals all attached to the same session--great for collaborative efforts and meetings.

Copying, pasting, and the scrollback buffer

Screen remembers a configurable number of scrollback lines, and you'll need them because you won't be able to use your terminal emulator's scroll features while running screen. You can access the scrollback buffer by entering "copy mode", which is accomplished by typing C-a [. You can mark text anywhere in the scrollback buffer and paste it with C-a ]. Screen is also capable of logging to files, but that's beyond the scope of this tutorial.

Monitoring for silence and activity

One of the disadvantages of running a bunch of programs within screen is that you can't keep an eye on all of them at the same time, since in general you can only see one at once. (Actually, you can split the screen and look at more than one at a time, but that's an advanced topic beyond the scope of this tutorial.) To help mitigate this problem, Screen has features that allow you to monitor a window for silence--useful for knowing when a compile has finished, for example--or activity--useful for knowing when someone is finally talking on your favorite IRC channel, for example.

To start or stop monitoring the current window for 30 seconds of silence, type C-a _; to start or stop monitoring a window for activity, type C-a M.

Making it go away

As you've seen from the section on detaching and reattaching, screen is not easy to kill. You can't just close its containing terminal. (Actually, you can, but then all those processes are still running on your system, ready to be reattached.) There's no "quit" key in the How do you fully exit screen?

To my knowledge, the only way to do this nicely (i.e. without sending nasty signals to processes that don't deserve it) is to close each of your screen windows. Exit whatever programs or shells each is running, and they will go away. When the last program running inside screen is exited, screen itself will go away.

Other stuff

Screen does much, much more than I've described above, but it's enough to get you started. You can type C-a ? for a terse list of commands available while you're in screen. The screen man page has a wealth of info, too. And here are some web resources, if you have questions:

Yahoo GNU Screen Group
A fairly high-traffic mailing list for screen. Many knowledgable people hang out here.

Sven Guckes' Screen Page
Another overview page; a good deal more terse than this one.

The official screen home page
No explanation needed here. The page is surprising sparse on details.

The screen man page
Nicely formatted and separated by section. Good reference. Be sure to check out the sections on using .screenrc to customize screen.

Screen FAQ
Not for newbies, but a good resource to dig into for troubleshooting.



source:http://www.kuro5hin.org/story/2004/3/9/16838/14935


最后由 millenniumdark 编辑于 2006-07-22 20:02,总共编辑了 1 次

页首
 用户资料  
 
2 楼 
 文章标题 : 節譯
帖子发表于 : 2005-08-24 16:35 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
GNU Screen:介紹/新手指導

作者:jeduthun
時間:2004。3。10

Chinese Translation:
millenniumdark


最后由 millenniumdark 编辑于 2006-01-17 18:05,总共编辑了 2 次

页首
 用户资料  
 
3 楼 
 文章标题 :
帖子发表于 : 2005-08-24 16:57 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
大多數現代的以Unix為基礎的操作系統(比如,Linux,、MacOS X和BSD)帶有一個叫做GNU Screen的終端模式下的小工具。如果把終端比作戰士,那GNU Screen就是戰士手中強有力的武器,對於文本模式下的人機合作而言,它是一把真正的瑞士軍刀。

僅管這一工具具有相當大的作用,相當多的人卻從未使用過。為什么會這樣呢?甚至很少有人知道它的存在,知道它的存在的人很少能理解它解決的問題!在這篇文章中,我將解釋screen會為你做什么,并且提供一些使用screen完成基本任務的簡單的介紹。我的讀者是那些能熟練
使用命令行,但是對screen本身沒有經驗或只有很少經驗的人。


页首
 用户资料  
 
4 楼 
 文章标题 : 問題
帖子发表于 : 2005-08-24 17:03 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
multiplexer怎么翻譯?

简明英汉词典 多路(复用)器

现代英汉综合大辞典 多路转接器[转换器, 扫描装置, 复用设备]; 转换开关; 时间划分开关

英汉计算机大词典 多重通道,信号连乘器,转换开关

我翻的多重化装置是因為日本好像是這么翻的


页首
 用户资料  
 
5 楼 
 文章标题 : 求教
帖子发表于 : 2005-08-24 17:14 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
curses-based application是什么?


页首
 用户资料  
 
6 楼 
 文章标题 :
帖子发表于 : 2005-08-24 17:34 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
screen是干什么的

對Screen最好的描述:一個終端下的多重化装置。使用它,你可以運行任意數量的基于終端的應用程序——交互的命令shell,基于 curses的應用程序,文本編輯器,等等——在單個終端之下。對於做到這點的渴望正是大多數人迷上screen的原因。我曾經在登錄到系統後打開半打終端模擬器:我想讓一個來讀我的郵件,一個來修改我的代碼,一個編譯我的代碼,一個用於讀新聞,一個用於我的web host的shell,等等。現在我只需要打開一個終端模擬器,然後在其中運行screen。問題解決了。

screen的另一個主要的非常酷的特性是它能把運行的程序和終端模擬器分離開來。這意味者你可以使用screen使程序在你意外地關閉終端模擬器後,甚至注銷以後繼續運行,以後可以從你中斷的地方重新開始。這意味着你運行一大堆終端程序的會話的概念是一個自由漂移的東西,你可以把它和任何地方的任何終端聯系在一起,如果你愿意,也可以不和任何一個終端聯系在一起。


最后由 millenniumdark 编辑于 2005-08-24 20:13,总共编辑了 1 次

页首
 用户资料  
 
7 楼 
 文章标题 :
帖子发表于 : 2005-08-24 18:17 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
開始使用screen:運行以及在程序間轉換

要啟動screen,只需在你最喜歡的命令shell提示符下鍵入screen。很可能你會收到一個歡迎信息。退出這個後,你會得到一個空白的終端帶有一個shell提示符,和你啟動screen差不多。發生了什么?

在screen下運行的每個程序在一個窗口下運行,每個窗口被標記為一個獨一無二的數字。Screen建立了一個新窗口,標記為0,在里面啟動一個命令shell。在你的新窗口下打些東西,這樣等一會儿你轉回來的時候就能認出它。

現在再建立一個窗口;那會是窗口1。按C-a c來做這個,C-a c指按Ctrl-a接着按c(加强記憶:創建(create)窗口)。

現在你有兩個窗口了,嘗試在它們之間轉換。要做這個,按C-a C-a,這會將你轉到你在當前窗口前使用的窗口。另外一些有用的窗口轉換方法,如果你打算運行兩個以上的窗口,你會需要它們的:

1,使用C-a n和C-a p來轉換到下一個或上一個窗口,這里的順序是按數字排列的。
2,使用C-a N——N可取0到9之間的數字——來轉到相應的窗口。
3,使用C-a " 來獲得一份窗口的全屏列表。你可以使用箭頭鍵(或者vi風格的j和k)來瀏覽列表,選擇一個窗口來激活它,在它高亮顯示的時候按enter。C-a w會給你一個小的,不交互的窗口列表。

當使用一個窗口的時候,按C-a A給它起名。這個名字將用於列在窗口列表時,在你使用一大堆窗口的時候也能幫助你記憶你在每個窗口里的工作。

退出一個窗口中的最後一個程序使窗口消失。你也可以使用C-a K來殺死所有反常的程序。


页首
 用户资料  
 
8 楼 
 文章标题 :
帖子发表于 : 2005-08-24 18:43 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
卸下和再附加:終端分离的魔法

如果你做了上面的練習,你已經成功地建立一個會話了。你可以按C-a d卸下這個會話。你也可以通過關閉包含這個會話的終端模擬器來卸下會話。然而,牢記,這兩種方法都沒有真正結束你的會話。它們只是從當前終端解下了你的會話。所有你在screen啟動的正在運行的程序還在運行。千真萬确。

試試這個:關閉任何你用來做上面的練習的終端模擬器。接下來,注銷,重新登錄,如果你想這樣。啟動一個新的終端模擬器,鍵入screen -r(顯然,這里的R代表reattach)。你會回到你卸下會話的那一點的。

你大可以想象一下這帶來的一大堆好處。你可以啟動所有你喜愛的終端程序,然後只要讓它們一直運行在一個持續的screen會話中。有些人讓screen在那儿運行幾個月。

另一個卸下和再附加的好用場就是終端模式的遠程桌面特性。你可以卸下一個上班時的screen會話,在家里用shell登錄那臺機器,然後再附加。非常,非常順手。再加上一點努力,你甚至可以把許多終端都和同一個會話聯系在一起——對劦同工作和會議來說,這很棒。


最后由 millenniumdark 编辑于 2005-08-24 20:16,总共编辑了 1 次

页首
 用户资料  
 
9 楼 
 文章标题 :
帖子发表于 : 2005-08-24 19:36 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
复制,粘貼,以及回滾緩沖

Screen會記下回滾行數,記下的次數可以更改,你會需要它們,因為你運行screen時無法使用你的終端模擬器的滾屏特性。你可以通過進入“复制模式”訪問回滾緩沖,這可以通過按C-a [來完成。你可以標記在回滾緩沖中的任何地方的文本,然後用C-a ]粘貼。Screen也可以寫入文件,但這在本指導的範圍以外。


页首
 用户资料  
 
10 楼 
 文章标题 :
帖子发表于 : 2005-08-24 19:50 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
監視沉默和活動

在screen里運行一大團程序的缺點之一是你不可能同時監視所有程序,因為通常來說,你每次只能看見一個。(事實上,你可以分割屏幕然後一次看到不止一個程序,但那是一個進一步的話題,不在本指導的範圍之內。)為了減少這一麻煩,Screen擁有如下的特性,使你可以監視一個窗口的沉默——比如,有助於知道編譯的完成——或者監視一個窗口的活動——比如,有利於知道什么時候有人終於到你喜愛的IRC頻道了。

開始或停止監視當前的窗口的30秒沉默了30秒,按C-a _ ;開始或停止監視當前的窗口的活動,按C-a M。


页首
 用户资料  
 
11 楼 
 文章标题 : 原文有誤
帖子发表于 : 2005-08-24 19:56 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
原文有誤

引用:
There's no "quit" key in the How do you fully exit screen?


漏字了。


页首
 用户资料  
 
12 楼 
 文章标题 :
帖子发表于 : 2005-08-24 19:58 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
讓它走開

正如你在卸下和再附加這一塊看到的,screen不容易殺死。你不可以僅僅關閉它的包涵終端。(準确地說,你可以,但是所有的進程還在你的系統上運行,等待再附加。)那里沒有退出鍵。那你如何完全退出screen?

据我所知,漂亮地做到這一點的唯一方法(即不向進程發送它們不應得到的糟糕的信號)是關閉每個screen窗口。退出每個窗口中所有正在運行的程序或shell,它們就會走開。當在screen中的最后一個程序退出了,screen自身也會關閉。


页首
 用户资料  
 
13 楼 
 文章标题 : over
帖子发表于 : 2005-08-24 20:34 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
最後一段介紹的都是english的內容,故偷懶不翻

這樣就算完成了

粗粗讀了一遍,修改了些小mistake.


页首
 用户资料  
 
14 楼 
 文章标题 :
帖子发表于 : 2006-03-16 0:39 
头像

注册: 2005-08-29 14:49
帖子: 1119
地址: 杭州
送出感谢: 0 次
接收感谢: 3
GNU Screen: an introduction and beginner's tutorial
GNU Screen:介绍和新手教程

By jeduthun
Wed Mar 10th, 2004 at 07:23:33 PM EST

leal's Improvement:
based on millenniumdark's work

Most modern Unix-based operating systems (e.g. Linux, MacOS X, and BSD) come with a little console-mode utility called GNU Screen. It's a powerful tool in the hands of the console warrior, a veritable Swiss Army knife of text-mode human-computer interaction.
大多數現代Unix类操作系統(比如Linux,、MacOS X和BSD等)都帶有一個叫做GNU Screen的終端模式下的小工具。如果把終端比作戰士,那GNU Screen就是戰士手中強有力的武器,對於文本模式下的人機交互而言,它是一把名副其实的瑞士軍刀。

This utility, despite its considerable usefulness, goes unused by a great many people. Why is this? Few people even know it's there, and those that do rarely understand the problem it solves. In this article, I will explain what screen does for you, and provide a simple set of instructions for accomplishing basic tasks using screen. My audience is those that are skilled with the command line but who have little or no experience with screen itself.
僅管這一工具用处很大,却被很多人所忽视。原因何在?因为它的存在几乎少有人知,即便是那些知道的人也很少能理解它要解决的问题!在這篇文章中,我將解釋screen會為你做什么,并且提供一些使用screen完成基本任務的簡單介紹。本文目标读者是那些能熟练使用命令行,但对screen本身只有很少或几无经验的人。


What screen does
screen之作用

Screen is best described as a terminal multiplexer. Using it, you can run any number of console-based applications--interactive command shells, curses-based applications, text editors, etc.--within a single terminal. The desire to do this is what gets most people hooked on screen. I used to start a half-dozen terminal emulators when I logged into my machine: I wanted one to read my email, one to edit my code, one to compile my code, one for my newsreader, one for a shell into my web host, and so on. Now I start one terminal emulator, and run screen in it. Problem solved.
一言以蔽之,screen是个终端的多路复用器。借助screen,你可以在单个终端内運行任意数量的基于終端的應用程序,如交互的命令shell,基于curses的應用程序,文本編輯器等等。做到這點的渴望正是大多數人迷上screen的原因。过去我登录到系统后,常常得打开六七个终端模拟器:一个用来读邮件,一个用来编辑代码,一个来编译代码,一个用来阅读新闻,一个用作登录web主机的shell,等等。现如今,我只要启动一个终端模拟器,然后在其中运行screen。Ok,一切搞定。
(译注:Ncurses是一个能提供功能键定义(快捷键),屏幕绘制以及基于文本终端的图形交互功能的动态库,ncurses为new curses之意,故curses也可参考该定义,网址:http://www.linuxfocus.org/ChineseGB/March2002/article233.shtml)

The other main cool feature of screen is its ability to decouple the terminal emulator from the running programs. This means that you can use screen to keep programs running after you accidentally close the terminal emulator, or even after you log out, and later resume right where you were. It means that the idea of a "session" in which you are running a number of console programs is a free-floating entity that you can bind to any terminal anywhere, or no terminal at all if you want.
screen另一个很酷的主要特性是它能使运行着的程序脱离终端模拟器。也就是说即使你不小心关闭终端模拟器,screen也能让程序继续运行;甚至在你注销之后,它也能让程序在你下次登录后从上次中断处继续执行。也就意味着,所谓的“会话”——你在期间运行大量终端程序——是个自由流动的实体,你可以把它绑定到任意处的任意终端上,甚至根本不绑定,只要你愿意。


_________________
用心×恒 | 豆瓣 | 门户 | Blog


页首
 用户资料  
 
15 楼 
 文章标题 :
帖子发表于 : 2006-03-16 20:56 
头像

注册: 2005-08-29 14:49
帖子: 1119
地址: 杭州
送出感谢: 0 次
接收感谢: 3
Getting started with screen: launching and switching between programs
screen新手上路:启动以及在程序间进行切换

Start screen just by typing screen at your favorite command shell prompt. You'll probably be greeted by a welcome message. Dismiss this and you'll have with an empty terminal containing a shell prompt, which is pretty much what you had before you started screen. What happened?
在你最爱的命令shell提示符下键入screen即可启动screen。也许会收到一条欢迎信息,任意键略过该信息,就会进入一个空白终端,只包含一个shell提示符,一切和你启动screen之前实在是差不多。那究竟暗藏了什么?

Every program running under screen runs in a window, and every window is identified by a unique number. Screen made a new window, numbered it 0, and started a command shell inside it. Type something in your new window so you'll be able to recognize it when you switch to it later.
在screen下運行的每個程序在各自窗口内運行,每個窗口都有一个独一无二的数字标志号。Screen建立一个新窗口,标记为0,并在窗口内启动一个命令shell。试着在新窗口里输入些东西,以便过会儿你切换回到该窗口时能认出它来。

Now make another window; this will be window 1. To do this, type C-a c; that is, type Ctrl-a and then type c (mnemonic: create window).
現在再建立一個窗口;那會是窗口1。按C-a c即可建立新窗口;详细步骤为,先按下Ctrl-a,然后按c(即创建create窗口)。

Now that you have two windows, try switching between them. To do this, type C-a C-a, which will switch you to whichever window you were using before the current one. Some other useful window switching methods, which you'll need if you plan to run more than two programs:
現在你有兩個窗口了,试着在两者之间进行切换。具体动作为按C-a C-a,它会切换到当前窗口之前你使用的窗口。如果你打算运行两个以上的程序,你会需要如下一些有用的窗口切换方法:

1. Use C-a n and C-a p to switch to the next or previous window in the list, by number.
2. Use C-a N, where N is a number from 0 to 9, to switch to the corresponding window.
3. Use C-a " to get a full-screen list of windows. You can navigate this list with the arrow keys (or vi-style, with j and k), and pick a window to activate by pressing Enter when it's highlighted. C-a w will give you a small, non-interactive list of windows.
1,使用C-a n和C-a p切换至窗口列表里的下一个或上一个窗口,按窗口号排序。
2,使用C-a N——N为0到9之間的數字——切换至相应窗口。
3,使用C-a " 來獲得一份全屏的窗口列表。你可以使用箭頭鍵(或者vi風格的j和k)瀏覽列表,在某窗口项处于高亮显示时,按回车键可激活该窗口。C-a w会显示一个小型、不能交互的窗口列表。

When you're using a window, type C-a A to give it a name. This name will be used in the window listing, and will help you remember what you're doing in each window when you start using a lot of windows.
使用一個窗口的時候,按C-a A可以給它起名。這個名字將显示在窗口列表里,当你使用大量窗口时,它可帮助你回想起自己在每个窗口里干吗来着。

Exiting the last program in a window will cause the window to disappear. You can also kill misbehaving programs with C-a K.
退出一個窗口中的最後一個程序后,该窗口便自行消失。你也可以用C-a K來殺死那些反常的程序。


_________________
用心×恒 | 豆瓣 | 门户 | Blog


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 20 篇帖子 ]  前往页数 1, 2  下一页

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 2 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译