
man screen
:
Screen is a full-screen window manager that multiplexes a physical ter‐
minal between several processes (typically interactive shells). Each
virtual terminal provides the functions of a DEC VT100 terminal and, in
addition, several control functions from the ISO 6429 (ECMA 48, ANSI
X3.64) and ISO 2022 standards (e.g. insert/delete line and support for
multiple character sets). There is a scrollback history buffer for
each virtual terminal and a copy-and-paste mechanism that allows moving
text regions between windows.
When screen is called, it creates a single window with a shell in it
(or the specified command) and then gets out of your way so that you
can use the program as you normally would. Then, at any time, you can
create new (full-screen) windows with other programs in them (including
more shells), kill existing windows, view a list of windows, turn out‐
put logging on and off, copy-and-paste text between windows, view the
scrollback history, switch between windows in whatever manner you wish,
etc. All windows run their programs completely independent of each
other. Programs continue to run when their window is currently not vis‐
ible and even when the whole screen session is detached from the user's
terminal. When a program terminates, screen (per default) kills the
window that contained it. If this window was in the foreground, the
display switches to the previous window; if none are left, screen
exits.
技術解釋完畢後,它與在常規 gnome 終端中建立選項卡有何不同?
對於您可以從手冊中執行的操作列表,我已經可以建立新選項卡、終止選項卡、查看選項卡列表、在視窗之間切換。是不是有螢幕更方便?有人能用通俗的語言解釋一下好處嗎?
答案1
就在您 C&P 的手冊頁中:
Programs continue to run when their window is currently not visible and
even when the whole screen session is detached from the user's terminal.
簡而言之,當您的網路連線中斷時,您的screen
程式會繼續運行,當您重新登入時,您可以重新連線到該會話。
在其他時候,這可能很有用nohup
,例如,執行一個可以中斷網路連接幾秒鐘的腳本(讓您的會話終止並且您的腳本消失SIGHUP
可能會讓您的電腦脫離網路)。
我不知道有多少人使用 screen 的“螢幕管理”功能,但我知道很多人在註銷後分開程式以保持它們的運作。
答案2
為了SSH
會議,這是天賜之物。您可以擁有 1 個同時會話(即 TCP 連線)來實現遠端伺服器上的選項卡功能,而不是 5 個並發會話(即 TCP 連線)。
現在,想像一下,如果您必須管理 5 個不同的伺服器,每個伺服器上有 5 個選項卡。您將有 25 個單獨的選項卡。這樣你就可以有 5 個選項卡,然後你就知道你在哪個伺服器上。
另一個巨大的好處是,您可以從 TTY 註銷(在本例中,關閉選項卡),然後稍後重新連接,並且仍然可以進行會話。如果您只想稍後打開一個會話,但又不想在處理其他事情時花幾個小時查看它,那麼這對於管理伺服器以及在家中非常有幫助。
答案3
如果您知道 Microsoft 遠端桌面的工作原理,您就可以輕鬆了解螢幕的工作原理。除了文字控制台之外,大部分相同。因此,您可以從螢幕控制台分離(斷開連接),然後重新連接到離開的會話。使用熱鍵在螢幕視窗之間切換、複製、貼上、凍結、刪除等。
所以主要的好處是,如果您突然與初始化畫面的主機斷開連接,可以保存控制台的狀態,這樣您就可以重新連接回主機並重新連接上次會話。
screen -Dr (如果連接到其他人則斷開連接並連接到會話) Ca a Ca 空格Ca 退格鍵用於窗口旋轉Ca c # 創建新窗口閱讀man 了解更多信息,但這一個是最有用的熱鍵
答案4
使用 screen,您可以從另一台電腦或在重新啟動電腦後重新連接到 screen 會話。您可以在伺服器上繼續執行 ssh 會話,而無需讓終端機保持開啟。