Linux share terminal in real time
Posted by danielMar 31
How to share your terminal session with another user in real time.
Linux has a script command which is mainly used for ‘typescripting’ all output printed on terminal. Commands typed on a terminal and the resulting output can be written to a file for later retrieval.
One little known use of the script
command is for sharing your terminal session with another user, this would particularly be useful for telecooperation say between a user and instructor. The instructor can lead the session by executing commands on the shell while the student would observe. Here is one way of doing this –
1. Instructor creates a named pipe using mkfifo
instructor@linubuvma:/$ mkfifo /tmp/shared-screen instructor@linubuvma:/$ ls -al /tmp/shared-screen prw-rw-r-- 1 instructor instructor 0 Mar 31 00:08 /tmp/shared-screen instructor@linubuvma:/$ script -f /tmp/shared-screen
2. Student views the session in real time by reading the shared-screen file –
student@linubuvma:/tmp$ cat shared-screen Script started on Fri 31 Mar 2017 12:09:42 AM EDT
As soon as the student runs the
cat shared-screen
command, the script command also gets started on the instructor’s session.
Whatever is typed on the instructor’s terminal will show up on the student’s screen and the student’s terminal will be restored as soon as the instructor exits or terminates the script session –
instructor@linubuvma:/$ free -m total used free shared buffers cached Mem: 3946 3572 374 40 288 996 -/+ buffers/cache: 2288 1658 Swap: 4092 195 3897 instructor@linubuvma:/$ exit exit Script done on Fri 31 Mar 2017 12:12:02 AM EDT student@linubuvma:/tmp$
Note – the student’s screen will show the user id of the instructor at the bash prompt, as it is a replica of the instructors session. Once the instructor terminates the session, the student will get back to their original bash prompt.
References –
No comments
You must be logged in to post a comment.