headermask image

header image

Screen utility in Linux

If you are like me then you would be remotely logging into Linux machines. Using normal ssh you would get a shell to work with. This is a sort of limitation as I eventually would have to log off from the shell. This situation is very evident in cases where the testing is involved. The automated tests scripts may run for hours together. In these situation you would like to know the output of the script. One simple work around would be to redirect the output to a text file. This works most of the time. But consider that I would like to do a bunch of changes in the remote machine and every one of the tasks involves a new shell. Then I need to consider the feasibility of opening many remote windows on my machine and every time i need to login using the credential. A big pain. There have been few solutions for this. You could vnc into the system and have a virtual desktop available to you. You can open as many windows as you want and leave it open so that you can continue working from either office or home. This also makes sense but what if I am running short of memory and wouldn’t like to spawn a Vnc session in the remote machine? And its very irritating to work on the remote desktop via VNC as it’s slow and it hits the productivity. There are also security issue with VNC sessions. VNC sessions are not as secure as ssh are. So if the system administrator is very fond of security, then you wouldn’t have the liberity of using a vnc session. The ports will probably be blocked as a Corporate policy in many of the corporates. But many would allow you to run a ssh session and the password authentication would be stricter in those cases. So this brings us back to the idea of using the shell session. Linux provides you a wonder tool known as screen. It gives you the following abilities,

  • Multiple windows within the single shell session
  • Resume option is available.
  • Many users can resume the session
  • Collaboration is available
  • There may be many more things that I may missed out. You may want to read the man pages :-)

    The following screen shot shows the screen screenshot from my laptop. It looks cool ;-)

    Screen

    The screen can further be customized using the following

    [cisco@bh1 ~]$ more ~/.screenrc
    deflogin off
    bind -c selectHighs 0 select 10
    bind -c selectHighs 1 select 11
    bind -c selectHighs 2 select 12
    vbell on
    startup_message off
    escape `\`
    shelltitle K
    bindkey -k k8 prev
    bindkey -k k9 next
    bindkey -k k1 select 1
    bindkey -k k2 select 2
    bindkey -k k3 select 3
    bindkey -k k4 select 4
    bindkey -k k5 select 5
    bindkey -k k6 select 6
    bindkey -k k7 select 7
    hardstatus alwayslastline
    hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}'
    # Multiuser config
    multiuser on

    Create a file named “.screenrc” in the home folder. You should be done with this cool looking screen working for you.

    Final notes before I end this, Ctl a then c to open a new shell and the rest are in the config files.

    Hope you enjoy screen for the rest of your remote logins.

    If you liked my post, feel free to subscribe to my rss feeds

    2 Comments so far (Add 1 more)

    1. Oops, it was suppose to be ctl a then c. CTRL A+C. It was a typo.

      1. Prasad MNR on March 13th, 2008 at 12:12 am
    2. CTRL + C to open a new shell ? that sounds awkward. CTRL + C is meant for misbehaving programs.

      2. vadiraj on March 13th, 2008 at 12:04 am

    Post a Comment

    Your email is never published nor shared. Required fields are marked *

    *
    *