What is the purpose of screen?

Screen is a shell multiplexer. It allows us to run multiple shells within one shell. There is a scrollback history buffer for each virtual terminal and a copy-and-paste mechanism that allows the user to move 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 the current window, view a list of the active windows, turn output logging on and off, copy text between windows, view the scrollback history, switch between windows, etc. All windows run their programs completely independent of each other. Programs continue to run when their window is currently not visible and even when the whole screen session is detached from the users terminal.

How can we launch a new screen session?


How can we detach from current session?

CTRL+a d

How can we reconnect to existing session?

screen -r

How can we create a window?

CTRL+a c

How can we give current window a name?


How can we switch window?


How can we switch to next window?

CTRL+a n

How can we switch to previous window?

CTRL+a p

How can we get the list of windows?

CTRL+a "

You can navigate this list using the arrow key.

How can we switch to window 0 - 9?

CTRL+a 0-9

How can we get a small non-interactive list of windows?

CTRL+a w

How can we kill misbehaving programs?


How can we enter copy mode?

CTRL+a [

How can we paste?

CTRL+a ]

How can we enter the scroll mode?

If we need to scroll up to see the text that has scrolled past the screen, use the copy mode:

CTRL+a [

and then use the up or down arrow to move around.

How can we display a terse list of commands?

CTRL+a ?
CTRL+a _                  // stop monitoring the current window for 30 seconds of silence
CTRL+a M                  // start or stop monitoring current window for activity

List the currently running screen sessions:

screen -ls
screen -t editor 0
screen -t server 1 ssh me@myserver
screen -t IRC 2 irssi
screen -t Mail 3 mutt

screen is also capable of logging to files.

You can split the screen to see 2 windows at the same time.
man screen

Can two users collaborate on one document at the same time?
How to enter command mode? What is the purpose of the command mode?
What is screen's multi-user mode?

Competitions / Alternatives:

| Tmux

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License