Crmgo Blog

screen (window manager)

screen (window manager)

Installation: yum install screen sudo apt-get install screen Commands: screen – start with default parameters; screen -S – start with a specific name "name"; screen -U – start in UTF-8 mode; screen -ls – view existing screens with their names and...

screen (window manager)

Installation:

yum install screen

sudo apt-get install screen

Commands:

screen – start with default parameters;
screen -S – start with a specific name «name»;
screen -U – start in UTF-8 mode;
screen -ls – view existing screens with their names and status (output format: pid.tty.host, «attached» – active, «detached» – inactive, «dead» – dead);
screen -wipe – remove «dead» sessions;
screen -r – attach to a screen;
screen -r name – attach to a specific screen named «name» (you can specify the first few letters);
screen -R [name] – attach, or create if it does not exist;
screen -x [name] – attach to a specific active screen named «name», i.e., one that is already attached to from another session.

To avoid dealing with the above commands, you can use the following command for remote SSH access:
ssh -t login@host screen -Rd – after logging into the server, you immediately enter a running screen session; if it does not exist, it will be created. If it is already attached to from another location at that time, it will simply disconnect there.
ssh -t login@host screen -RD – the difference is that in the other session, not only will the screen be disconnected, but you will also be logged out of the SSH session itself.

Keys:

Case sensitivity, as usual in *nix systems, matters; Ctrl+a is the control key combination, followed by another key.
Ctrl+a space – switch to the next window in the session;
Ctrl+a c – create a new window;
Ctrl+a A – name the current window;
Ctrl+a « – view the list of windows with the ability to switch to any of them;
Ctrl+a ‘ – switch to a specific window by name or number;
Ctrl+a [0-9] – switch to the corresponding window (you can view the numbering using Ctrl+a «);
Ctrl+a a – switch between the last two windows;
Ctrl+a n – switch to the next window;
Ctrl+a p – switch to the previous window; you can also use BackSpace instead of the p symbol;
Ctrl+a d – detach from screen;
Ctrl+a Esc – switches screen to «copy mode». Navigation through the screen becomes available (by the way, movement key combinations like those in VIM or less work, including search – «/»);
Ctrl+a M – monitor activity (triggers when new information appears);
Ctrl+a _ – monitor inactivity (triggers when information stops arriving in the terminal);
Ctrl+a * – show a list of all currently connected displays.

Note: This post may be AI-assisted and then human-edited. Editorial responsibility: Dmytro Lomaka, Kaltenkirchen.