
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 した man ページからそのまま引用します:
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
セッションに関しては、これは天の恵みです。リモート サーバー上のタブ機能に 5 つの同時セッション (つまり、TCP 接続) を設定する代わりに、1 つだけ設定できます。
さて、5 つの異なるサーバーを管理し、それぞれに 5 つのタブがある場合を想像してください。25 個の個別のタブがあることになります。これを使用すると、5 つのタブだけで、どのサーバーにいるのかがわかります。
もう 1 つの大きな利点は、TTY からログオフ (この場合はタブを閉じる) して、後で再接続してもセッションを維持できることです。これは、サーバーを管理する場合や、自宅で後でセッションを開始したいが、他の作業をしながら何時間もセッションを見続けたくない場合に非常に役立ちます。
答え3
Microsoft リモート デスクトップの仕組みがわかれば、Screen の仕組みも簡単に理解できます。テキスト コンソールのみであること以外は、ほとんど同じです。そのため、Screen コンソールからデタッチ (切断) し、後で離れたセッションに再接続することができます。ホットキーを使用して、Screen 内のウィンドウを切り替えたり、コピー、貼り付け、フリーズ、終了などを実行できます。
したがって、主な利点は、画面が初期化されているホストから突然切断された場合にコンソールの状態を保存し、ホストに再接続して前回のセッションに再接続できることです。
screen -Dr (他のユーザーが接続している場合は切断し、セッションに接続します) Ca a Ca space Ca backspace ウィンドウを回転するには Ca c # 新しいウィンドウを作成するには 詳細についてはmanを参照してください。ただし、これは最も便利なホットキーです
答え4
screen を使用すると、別の PC から、または PC を再起動した後で、screen セッションに再接続できます。ターミナルを開いたままにせずに、サーバー上で ssh セッションを実行したままにすることができます。