Screen

Commands

General

screen -S coolCreate a new session named cool
screen -lsList running sessions
screen -r [cool]Reconnect to a detached session
screen -d -r [cool]Detach and reconnect to session

Session

C-a + ddetach

Windows

C-a + cCreate new window
C-a + AName window
C-a + kKill (unresponsive) window

Split screen

C-a + SSplit screen horizontally
C-a + |Split screen vertically
C-a + tabnext split tab
C-a :resize 60%Resizes the current region to take 60% of the screen
C-a + XRemove current split

Copy mode

Ctrl-a + [, C-a + Escenter copy mode
space barSet first mark/copy to buffer+exit copy mode
C-a + ]paste (for instance in vi)
root@server:~# cat | sendmail leo@domain.com
To:leo@domain.com
Subject:screen clipboard
...
stuff
...
Ctrl-D

Scrool mode on/off

C-a + sFreeze/block scrolling (feels like screen is dead)
C-a + C-qstop freezing mode

Making a copy of the screen buffer to a file

To write the entire contents of the scrollback buffer to a file, type Ctrl + A and : to get to command mode, then:

hardcopy -h <filename>

Source: https://stackoverflow.com/questions/4807474/copying-gnu-screen-scrollback-buffer-to-file-extended-hardcopy

~/.screenrc

A good sample indicating time and stuff (to know when you got disconnected).

autodetach on
startup_message off
hardstatus alwayslastline
shelltitle 'bash'

hardstatus string '%{gk}[%{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= w}%?%+Lw%?%? %{g}]%=[ %{=b r}%H %{= w}%Y/%m/%d %c:%s%{g} ]%{W}'

bind c screen 1
bind ^c screen 1
bind 0 select 10
screen 1

Explanations on hardstatus

%{=b kR}
%the escape character itself
{attribute/color modifier string terminated by the next }
=change the current attributes to the specified set
bbold
kblack background
Rred, the capitalized versions of the letter specify bright colors
}closing attribute/color modifier string, what comes after is affected

Documentation: http://www.gnu.org/software/screen/manual/html_node/String-Escapes.html

Connect to a console port

screen /dev/ttyUSB0

if you need to specify the baud rate, add it after the serial device. eg, for 57600 baud:

screen /dev/ttyUSB0 57600

Control a screen within a screen (even more inception)

https://unix.stackAexchange.com/questions/29140/how-do-you-detach-the-2nd-screen-from-within-another-screen