• Screen

    6/24/2008

    As a sysadmin I have lots of terminal sessions open simply because it’s usually easier for me to type in few commands as opposed to clicking around the gui. To help with this I use GNU’s Screen command. It allows you to open up a terminal and then detach that window and do that as many times as you like.

    It does get rather confusing sometimes trying to remember what screen session is for what. This is what you see with multiple sessions:

    <code>

    There are screens on:
    15767.pts-0.voodoo (Detached)
    15809.pts-0.voodoo (Detached)

    <code>

    Now I have no idea what is in either of those with that name. And to reattach those screen would require me typing ’screen -r 15767.pts-0.voodoo’. That’s too many keystrokes for my liking ;-). Luckly screen has some options that can help you identify what is on each screen. Using the command ’screen -S server1′. So instead of the output above you’d see:

    <code>
    There are screens on:
    15922.server1 (Detached)
    15964.server2 (Detached)
    </code>

    Now all I have to type to reattach is ’screen -r server1′. Now that’s still a bit too much so I’m going to add an alias to my .bashrc file to make it a bit shorter..
    <code>
    alias jscreen=’screen -S $1′
    </code>

    After I run ’source ~/.bashrc’ and then jscreen will be available. All I have to is type ‘jscreen server3′ and my server3 session is created.

  • Leave A Comment

    Mail (will not be published) (required)