GNU Screen Tips

Taking a break from the OSPF workbook to write up a brief summary of my favorite GNU screen hotkeys.

Basic hotkeys

Ctrl+a Ctrl+a = Return to your last terminal

Ctrl+a p and Ctrl+a n will move you to the previous and next terminals, respectively.

Ctrl+a d = Detach from your current session

From any command prompt, type screen -ls to list your open screen sessions.

[531][charlie] ~ $ screen -ls

There are screens on:
        29333.pts-2.champion    (03/20/2010 07:04:40 PM)        (Detached)
        26943.pts-3.champion    (03/20/2010 06:16:20 PM)        (Detached)

2 Sockets in /var/run/screen/S-charlie.

If you only have one session open, just type screen -r to rejoin.

If you have multiple sessions, type screen -r 123 where 123 is the socket number from the list command.

Tip: You only need to type enough characters to make the number unique.

So in the example above, you could type screen -r 26 to rejoin the second session.

Writing to multiple screens

Another great time saver is writing to multiple screens at once.

Here is how I use it with my Dynamips lab.

First, I want to make sure I’m no longer in configuration mode.

At the screen command prompt (Ctrl+a : ) enter
at \# stuff end\015

which will send "end" to all your terminals. Now you can "write mem" to all your devices simultaneously.  Again, at the screen command prompt enter

at \# stuff wr\015

At this point I will quickly rotate through the devices to make sure things are saved, return to dynamips and issue a save /all or export /all.

Tada, all my configs are now saved.  Of course, you could use one line but I prefer to use two to ensure there is no lag between the two commands.


About this entry