Go4Expert (http://www.go4expert.com/)
-   Unix (http://www.go4expert.com/articles/unix/)
-   -   Use screen Command To Create Multiple Terminal Sessions (http://www.go4expert.com/articles/screen-command-create-multiple-terminal-t28981/)

pradeep 30Aug2012 19:20

Use screen Command To Create Multiple Terminal Sessions
The GNU/Linux screen program is quite unknown, except for geeks & *nix experts, it helps you create multiple terminal sessions from a single one and lets you detach from the screen, at the same time maintaining the sessions as if you had never left the session and you can attach/connect to the session anytime you want afterwards.

Another feature of the screen program is that it allows multiple people to use the same sessions, thereby providing a terminal session 'sharing' feature. In this article we'll be looking into using screen to create and manage multiple sessions.

Using screen Command

First let's look at starting a screen session, it can be simply started with,


$ screen

but, that will have a arbitrary screen session name chosen by the screen program. So, this would be more suited,


$ screen -S my_tail_log

This will immediately start a new session and attach it, in case you want to start a screen in detached mode, useful for startup scripts, try this


$ screen -dm -S my_tail_log

To resume a detached screen,


$ screen -r my_tail_log

To attach to an already attached running screen (say for sharing, multiple users can attach to the same session)


$ screen -x my_tail_log

To create a new window inside a screen when attached to it, use Ctrl + A and then C.

To view the list of running windows in a screen and select one from the list, use Ctrl + A and then ".

To change a window's title, use Ctrl + A and then capital A.

To detach from a screen, use Ctrl + A and then D.

To list all the running screens,


$ screen -ls

You can use multiple windows inside a screen to work on different things, say one for editing code, another for executing the programs, and another one to view logs/debugging etc. It's very easy to share working while on a teleconferencing call and all users can see, execute & discussion commands and outputs.

All times are GMT +5.5. The time now is 10:34.