Linux Screen allows you to:
start a new screen session with session name
screen -S <name>
or list running sessions/screens
screen -ls There are screens on: 5628.fuckwit (15/02/17 10:56:09) (Attached) 5233.pts-0.geekstuff (15/02/17 09:33:51) (Detached) 2 Sockets in /var/run/screen/S-username.
attach to a running session
screen -x
to session with name
screen -r <name>
the “ultimate attach” Attaches to a screen session. If the session is attached elsewhere, detaches that other display. If no session exists, creates one(If multiple sessions exist, uses the first one).
screen -dRR
To detach your session use the escape "ctrl a" followed by "d" without quotes
^a d
To you can also detach a running session using the screen command
screen -d <name>
Type exit to Exit from screen session and return to the standard command prompt.
exit [screen is terminating]
The screen application is very useful, if you are dealing with multiple programs from a command line interface and for separating programs from the terminal shell. It also allows you to share your sessions with others users and detach/attach terminal sessions.
Just type screen at the command prompt. Then the screen will show an introduction interface type space or return to start like as if at the command prompt type exit to return to the standard command prompt.
screen is an application and as such also has its own cammands and parameters which can be seen by typing "Ctrl-a" followed by “?” both without quotes. Then you will see all commands or parameters on screen.
Screen key bindings, page 1 of 1. Command key: ^A Literal ^A: a break ^B b license , removebuf = clear C lockscreen ^X x reset Z colon : log H screen ^C c copy ^[ [ login L select ' detach ^D d meta a silence _ digraph ^V monitor M split S displays * next ^@ ^N sp n suspend ^Z z dumptermcap . number N time ^T t fit F only Q title A flow ^F f other ^A vbell ^G focus ^I pow_break B version v hardcopy h pow_detach D width W help ? prev ^H ^P p ^? windows ^W w history { } quit \ wrap ^R r info i readbuf < writebuf > kill K k redisplay ^L l xoff ^S s lastmsg ^M m remove X xon ^Q q ^] paste . " windowlist -b - select - 0 select 0 1 select 1 2 select 2 3 select 3 4 select 4 5 select 5 6 select 6 7 select 7 8 select 8 9 select 9 I login on O login off ] paste . | split -v :kB: focus prev [Press Space or Return to end.]
One of the advantages of screen that is you can detach it. Then, you can restore it without losing anything you
have done on the screen. Here is how I can make use of it with handbrakeCLI:
I started to rip a dvd at home and it was still running when I left for work. Unfortunately I had selected the wrong title an the recording didn't work
so, if I start a new instance the rip it will take 6 hours to complete but I finish work in 4 hours.
In a normal session if you disconnect the SSH session, or suddenly the connection lost by accident, then the download process will stop.
You have to start from the beginning again. To avoid that, we can use screen to start the process then detach it.