使用屏幕有什么好处?

med*_*iev 4 gnu-screen

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.
Run Code Online (Sandbox Code Playgroud)

抛开技术解释,它与在常规 gnome 终端中创建选项卡有什么不同?

对于您可以从手册中执行的操作列表,我已经可以创建新选项卡、杀死选项卡、查看我的选项卡列表、在窗口之间切换。只是屏幕更方便吗?有人可以通俗地解释一下好处吗?

vor*_*aq7 8

就在您 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.
Run Code Online (Sandbox Code Playgroud)

简而言之,当您的互联网连接中断时,您screen的程序会继续运行,当您重新登录时,您可以重新连接到该会话。

在这可能有用的其他时候是您将使用 的时候nohup,例如运行一个可以中断网络连接几秒钟的脚本(让您的会话终止并且您的脚本消失SIGHUP可能使您的机器脱离网络)。

我不知道有多少人使用 screen 的“屏幕管理”功能,但我知道很多人在注销后分离程序以保持它们运行。


小智 5

对于SSH会议来说,这是天赐之物。您可以拥有 1 个并发会话(即 TCP 连接)来实现远程服务器上的选项卡功能,而不是 5 个并发会话(即 TCP 连接)。

现在,想象一下,如果您必须管理 5 个不同的服务器,每个服务器上有 5 个选项卡。您将有 25 个单独的选项卡。这样你就可以有 5 个选项卡,然后你就知道你在哪个服务器上。

另一个巨大的好处是,您可以从 TTY 注销(在本例中,关闭选项卡),然后稍后重新连接,并且仍然可以进行会话。如果您只想稍后打开一个会话,但又不想在处理其他事情时花几个小时查看它,那么这对于管理服务器以及在家中非常有帮助。


小智 5

如果您了解 microsoft 远程桌面的工作原理,您就很容易理解 screen 的工作原理。除了文本控制台外,几乎相同。因此,您可以从屏幕控制台分离(断开连接),然后重新连接到离开的会话。使用热键在屏幕、复制、粘贴、冻结、杀死等窗口之间切换。

因此,主要好处是,如果您突然与初始化屏幕的主机断开连接,则可以保存控制台状态,以便您可以重新连接回主机并重新连接上次会话。

screen -Dr(如果连接了其他人并连接到会话,则断开连接) Ca a Ca space Ca backspace For window rotate Ca c # to create new windows read man for more,但这是最有用的热键