Basics of Gnu Screen

gnu.png

I’ve been using screen for the past 3 years and for the first time I’ve decided to seek out more functionality out of it.  So last week I spent about 2 hours looking up some of the different functionality that I can use in the day to day. Let me tell you I found a bunch of goodies that I use now religiously (For a week now ;) ).

So for those of you who do not know what a screen session is… (STRAIGHT FROM THE MAN PAGES) Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).  Essentially you can have 30 terminal sessions inside one terminal and much more…..

To run Screen all you need to do is type “screen” in your terminal. You more then likely do not have it installed by default. So for those of you who have the distributions below…

  1. Fedora/CentOS/RHE/ or any RedHat based system, you will need to run “yum install screen
  2. Ubuntu/Debian based systems, you will need to run “apt-get install screen
  3. Gentoo based systems, you will need to run “emerge screen

To start a new screen session all you have to do is type “screen”


Now that you are in a screen session, the fun begins now…

1- To start a new sub session (Virtual Session) type

((ctrl+a) c)
Please ignore the plus (+)symbol, this essentially means “ctrl a then c”

2- To switch between sessions…
((ctrl+a) <space bar>)

3- To switch between your previous session and the current one..
((ctrl+a) a)

4- To kill a frozen session…
((ctrl+a) k)

5- To see a list of available commands…
((ctrl+a) ?)

6- To see a list of virtual terminals you have open..
((ctrl+a))

7- To Detach from a screen session and not lose any of your virtual terminals…
((ctrl+a) d) ( This is one of the best features of screen!! )

8- To view  current screen sessions once you are logged out of screen..
“screen -list”

9- To reattach to an Attached session (Session that was not detached properly)
“screen -D -r <11546.pts-5.hostname>” (session name from the output of the screen -list command)

10- To reattach to a detached session..
“screen -r <11546.pts-5.hostname>” (session name from the output of the screen -list command)

10- To end that session you can either type
“exit” or a (ctrl+d)

11- To start a split screen session in you current screen session…
((ctrl+a) S)

12- To switch between split screens…
((ctrl+a) <tab button>)

13- To copy output from one split screen to the next…
((ctrl+a) [) now using the up and down arrow find the output you want to copy and from where you want to start copying hit the <space bar> and keep using the arrows to where you want to stop copying and hit the <space bar> again.

14- To paste the output from the previous command...
((ctrl+a) ]) Now if you want to paste it in the split terminal you would have to do step 2 then step 4.

I use the above commands especially to copy output from one terminal to next without a mouse.

15- Now lets say you want to lock our screen session from private eyes…
((ctrl+a) x)

To unlock your session just use your password for you account.

Related Posts

Comments are closed.