Screen for Power Session
Screen is a full-screen window manager of the console, which comes with every flavor of UNIX and Linux. He is best known for multiplexing a physical terminal between several processes. By using it, you can run any number of console-based applications within a single hotel.
For example, suppose I want to launch the 'top' to keep track of the system load, change my programming code and check my mail at the same time ... Usually, I must open at least 3 terminals to do that. But using the screen utility, I can run all these programs at the same time and physical terminal. Another feature of this wonderful utility is its ability to separate the terminal emulator program running, which ensures your work is in progress, even if you inadvertently close your window, or where you disconnect. After detaching, you can once again over the same session and resume control of the management jobs.
Here how to use this utility.
For example, suppose I want to launch the 'top' to keep track of the system load, change my programming code and check my mail at the same time ... Usually, I must open at least 3 terminals to do that. But using the screen utility, I can run all these programs at the same time and physical terminal. Another feature of this wonderful utility is its ability to separate the terminal emulator program running, which ensures your work is in progress, even if you inadvertently close your window, or where you disconnect. After detaching, you can once again over the same session and resume control of the management jobs.
Here how to use this utility.
1) First open a terminal and type :
$ screen
2) Screen starts and creates a new single window with a shell, pretty much like what you had before. The path name of the shell is taken from the $SHELL variable. New windows can be created within the same physical terminal using the screen commands.
3) Now that you have started screen in a terminal, suppose you want to run the 'top' program to check the System load and at the same time you want to compile a program too - Also you would like to switch between the two to see the progress made by both.
For that, first execute the first program to be run (say 'top'). now 'top' will start in the terminal.Now open a new window in screen by pressing the '[Ctrl + a] c' - which I will state as 'C-a c' . This will create a new window in the same terminal. Here, you can give commands to compile your program.
In screen, each window is given a unique identifier. The first window is numbered 0, the next window is 1 and so on. Now to switch between your 'top' and the compiling program, you can use the key 'C-a 0' and 'C-a 1' respectively.
You can also associate names with each running window - use 'C-a A' to give a name to the current window.
Here are a few other commands that might come in handy while toggling between various running windows :
- 'C-a p' and 'C-a n' can be used to switch to the next or previous window respectively.
- 'C-a N' - where N is the number from 0 to 9, that can be used to jump to the corresponding window.
- 'C-a w' displays a list of all windows. The unique ID of each window with its name and running process is displayed, for each window. The current window is marked with an asterisk(*).
- 'C-a k' - can be used to kill the current window. You can also type 'exit' to kill the current window. If no more windows are open, then screen exits. 'C-a \' also does the same thing.
- 'C-a d' - detaches the present screen session. You can also detach by closing the terminal running your screen utility. Though, this appears to close your terminal session, in reality this does not happen. It only unbinds your session from the current terminal. All the programs started under screen will still keep running.
You can also log out from the machine and re-login. Then start any terminal session and type 'screen -r' to once again be connected from where you left.
In case, there were more than one screen sessions running on the machine, Screen prompts for a host.tty.pid.
For example, say I have two screen sessions. So when I type 'screen -r' command, it gives the following message:
$ screen -r
There are several suitable screens on:
2999.pts-6.localhost (Detached)
1920.PTS-6.localhost (Detached)
Type
"screen [-d] -r [pid].tty.host" to resume one of them.
Choose the right tty.host to connect and you control your program. You can also share your screen session with others as the use of VNC. Imagine that you are having a problem with your code and you want to share with your boss which is located in another office. You can use the screen to share your session with your boss, and he can see what you are referring. The first user launches the screen in normal mode and executes the following ...
User1:The second user starts a new screen session and connects it to the first session using ...
[Ctrl-A]:multiuser on [RET]
[Ctrl-A]:acladd
User2:
screen -x
Screen website at Official Screen Home Page
♦DiggIt! ♦Add to del.icio.us ♦Add to Technorati Faves
0 comments:
Post a Comment