Linux Trick for screen collaboration or shell sharing

14 / Nov / 2010 by Tarun Pareek 1 comments

In recent week, i got to know about really good way of collaborating the screen in a linux.
Let us take a scenario, Suppose User having name ‘B’ on the 5th floor of the company is having a problem/difficulty related to code execution, unable to figure out what to do?, and then he call the fellow guy who can help him out, but he is on 1st floor his name is ‘Lazy A’.
Lazy A guy is really lazy, so here come handy screen collaboration trick to help him out and save him from walking 4 Floors to reach 5th one (:phew!:)
Lazy A support guy open its terminal and perform the following tricks consisting of 4 steps:
1. ‘Lazy A’ remote login into the User B system through following command:

lazyA# ssh B

2. After that Lazy A logged in as super user B, on B machine

B# su - B

3. Now Lazy A is on the B machine logged in as super user B, and ‘Lazy A’ runs the following command,

B# screen -S sos

4. Then Lazy A guy ask B to run following command on his/her system :

B# screen -x sos

Note that same alias ‘sos’ is being used by both in last 2 commands, and both guy are logged in as same user.
Actually the last two command cause both user session joined together in linux shell and now both users can type on there shell and see what other is typing or doing to fix the issue, and this is how lazy A help out the B without walking to 5th floors.
After providing help, ‘Lazy A’ terminate the session by performing ctrl-C and then ctrl-D command on its terminal. Thats the way they get detach from each other and get back to there respective work.
And code happily ever after 🙂
Example to Test command on your machine:
To test the ‘screen -S’ and ‘screen -x’ command you can open two separate terminal or shell on your linux system, then run following command on your 1st terminal or shell
Terminal 1:

# su - tarun
tarun# screen -S mytest

And run another command on Terminal 2:

tarun# screen -x mytest

Then type on any screen you will see what you are doing on one is appearing on both the shells. To terminate session use ctrl-C and then ctrl-D. 🙂
Tarun Pareek


comments (1 “Linux Trick for screen collaboration or shell sharing”)

Leave a Reply

Your email address will not be published. Required fields are marked *