Monday, February 25, 2019

Using the Screen command in Linux

The Screen command in Linux is useful if you are running operations that take a long time to finish in a remote shell like Putty (e.g. a copy or rsync job) and you're on an unstable network that might disconnect.

With a regular ssh session, any running jobs will terminate if you lose the connection.

Screen let's you open multiple sessions in one session and detach and reattach to these sessions (similar to tmux).

For more in-depth description of Screen, see this link.

To install the application, run:

On Ubuntu:
$ sudo apt install screen

$ sudo yum install screen

To start the application:

$ screen
Creates a new screen/session

screen -ls
shows all screens (runs from within a session)

$ Ctrl+a c
Creates a new window (press crtl+a then let go and then press c)

$ Ctrl+a + Ctrl+a
Switches between open windows

$ Ctrl+a d
Detach but keep sessions running

$ screen -R reattaches to screen, if only one screen (that can have multiple windows apparently)

$ Ctrl+a w
List all windows

$ Ctrl+a 0-9
Go to a window numbered 0 9, use Ctrl+a w to see number

If multiple sessions, then choose the session to connect to:

screen -r 4040.pts-0.ip-AC1E0807
(this is just an example)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.