Tuesday 27 December 2011

" Screen " command in linux


The following shows Multi Screen in GUI .

similarly "Screen" command Helps us to have multiple screens for the same shell in linux.



To Enter into different screens :

Execute the screen command once .
$screen

now it goes to screen 0

now in this new screen , type $screen  , it goes to screen 1 ......this goes on and on ...

To come out of a screen :

To exit screens one by one from the latest present screen , type
$exit
Now if you are in "i" th  screen , you are pushed to "i-1" th screen...

To detach all the screen at once ,
press ctrl +A D

Top View of what screens are and where it is  ....



We are in a terminal(parent) .
In which we can have a number of sockets . Each socket has a number of screens .

Each time we come to the terminal(parent) and type $screen we open a new socket
In this socket at first, screen 0 is displayed . then in this if we type
$screen
we are attaching another screen to same socket , and named as screen 1,, and so on

And now if we come to terminal by ctrl +A D , and type $ screen , we open a new socket ..
Outline is as follows ,

                                                                            -------------screen 1              
                                                                           |
                                     ------- ------ ------socket 1 ------------screen 2
                                    |
Terminal (parent)  -----
                                    |                                      
                                     ------- ----- -------socket 2 --------------screen 1
                                                                           |
                                                                           -------------- screen 2
                                                                           |
                                                                           L--------------screen 3

(sorry for the dirty diagram , I just tried to do with keyboard , due to time constraints )
In short , screens are like grand children of terminal.

so when ever we type ctrl +A D , we come to parent , from here we select a socket and from socket we select screens there.)
say if, the socket id is 12899.pts-0.cu147

This is done by
$ screen -r 12899.pts-0.cu147

so we selected the socket .

press enter

We have now entered into socket 12899.pts-0.cu147

here we can select the screens .

Uses of having the concept of screens .................

When there is process which is known to take a lot of time (say 10 hrs) . Then we cannot wait for 10 hrs for the process to get completed (some of my friends used to do this , to show that they have no work for 10 hours).But my Educator did not want to allow this. So he suggested this idea,that we can have a different screen for the new process we are to be engaged  with.

Now , say we have a process running in a screen and we have switched to a new screen .How to go to that old screen in which our process is running ( screen 0 or screen 1 or screen2 ....  ), when we have already detached from that screen .

Ctrl + A  '
and then type the screen number of the screen to which you want to navigate to.

(Note : dont try this from parent screen(It is foolish because as i told before , the parent only has sockets and sockets inturn have screens) we have to enter into socket and try selecting screens )

Giving Names for screens and accessing screens using it

As I cannot remember screen numbers  , I started searching for methods to give names to screens , instead of having names like screen 0 : bash , screen 1 : bash ...........

Ya , I found a solution ,,,, they have command .....

If you are in a particular screen say screen 1, then press

ctrl + A shift + A
then delete the word bash in the prompt saying "Set window's title to : bash" appearing at the bottom of the screen and type the name of the running process (or anything of your wish , so that you can make out later)
And press enter

Now how to get this screen back after navigating to some other ....????????

First get the list of screens attached by pressing

Ctrl + A "

The list appears ,, from this list select the process by using navigation keys and press enter , you will be dragged to that screen .

This is What I Know about SCREEN command .



No comments:

Post a Comment