Screen - Attach Multiple Users to a Singe Screen

In Ubuntu, there is a utility called screen which is fantastic for allowing you to create screens whose display is shared between all other terminals within Byobu. This is great for allowing you to teach/show what you are doing to someone in the same terminal and vice versa (you can watch what they do). Byobu is built on screen so as you can imagine, you should be able to do the same in screen on CentOS. Unfortunately typing the screen -r command wont allow you to attach to an already attached session. The trick is to run this command when you create a screen and also when you want to attach to it.

    SCREEN_TITLE=my_screen_title
    screen -aAxRS $SCREEN_TITLE
    Let me explain what these switches mean:
    • a - Force all capabilities into each window's termcap.
    • A - Adapt all windows to the new display width & height. This will observe limitations. E.g if an sshd terminal is smaller than a physical console display (vga attached to the physical machine), the physical display will adapt to be smaller to the size of the terminal. However if the ssh terminal is expanded beyond the limitations of the physical session, then the terminal will be limited to allow all text to always be visible. A dashed line will be shown along the bottom showing the limit. Unfortunately there is no vertical line showing the column limit, but text will just wrap.
    • x - Attach to a not detached screen. (Multi display mode).
    • R - Reattach if possible, otherwise start a new session.
    • S - Name the screen as 'x'. (Multi display mode).

    This will attach to the first screen in the list regardless of whether it is currently attached to or not. I had thought it would attach to the first attached screen but no. If a screen is running that is not attached to, this will be ignored. Someone else who then runs the same command will automatically join you.

No comments:

Post a Comment