IOS Console Customization

By stretch | Monday, May 10, 2010 at 3:07 a.m. UTC

This article offers a few tips to customize the behavior of a Cisco IOS router's VTY and console lines.

Set a Custom Escape Character

The default IOS escape sequence is ctrl-^x, or "control-shift-6, x", as we can see from the output of show terminal:

Router# show terminal
Line 6, Location: "", Type: "xterm"
Length: 25 lines, Width: 120 columns
Baud rate (TX/RX) is 9600/9600
Status: PSI Enabled, Ready, Active, No Exit Banner, Automore On
  Notify Process
Capabilities: none
Modem state: Ready
Special Chars: Escape  Hold  Stop  Start  Disconnect  Activation
                ^^x    none   -     -       none         
Timeouts:      Idle EXEC    Idle Session   Modem Answer  Session   Dispatch
                never         never                        none     not set
...

This obscure sequence probably has some historical significance, but it is most commonly used on IOS today to interrupt a ping or traceroute command. We can set a custom escape character to something more convenient, such as ctrl-c (which is the ASCII character 3):

Router(config)# line vty 0 15
Router(config-line)# escape-character ?
  BREAK            Cause escape on BREAK
  CHAR or   Escape character or its ASCII decimal equivalent
  DEFAULT          Use default escape character
  NONE             Disable escape entirely
  soft             Set the soft escape character for this line

Router(config-line)# escape-character 3

We can now simply use ctrl-c in place of ctrl-shift-6. The "x" generally isn't necessary.

Alternatively, a temporary custom escape character can be defined for the current session only using the terminal escape-character EXEC command.

Increase the History Size

By default, the terminal history (which records recently used commands and is invoked with the up arrow) is limited to the last 20 commands. We can increase the history size under line configuration or via the terminal command:

Router(config)# line vty 0 15
Router(config-line)# history size ?
    Size of history buffer

Router(config-line)# history size 100

show history can be used to inspect the contents of the history buffer.

Infinite Terminal Length

Often you'll need to copy a good amount of text from the console (e.g. the output of show run or show tech-support). Depending on the terminal emulator in use, you may notice the copied or saved text has been polluted with lines reading "--More--" followed by unprintable characters (^H), which were inserted by the IOS CLI pager. A handy solution for this is to temporarily set the terminal length to zero, which effectively sets an infinite terminal length and disables terminal paging.

Router# terminal length ?
    Number of lines on screen (0 for no pausing)

Router# terminal length 0

To return the terminal length, use terminal length appended with the desired number of lines (typically 24). If you want to permanently alter the terminal length, use the length command under line configuration.

Include Timestamps on Show Commands

IOS includes an option to automatically timestamp the output of show commands. This can be handy when producing records for documentation or archival purposes.

Router(config)# line vty 0 15
Router(config-line)# exec prompt timestamp
Router(config-line)# ^Z
Router# show ip interface brief
Load for five secs: 0%/0%; one minute: 0%; five minutes: 1%
Time source is hardware calendar, *03:14:21.123 EDT Wed Apr 14 2010

Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0              70.174.182.38   YES DHCP   up                    up      
FastEthernet1              unassigned      YES NVRAM  up                    down
...

Lock the Terminal

A little-known feature that might come in handy: IOS allows you to temporarily lock your console session. First, locking must be enabled under line configuration:

Router#(config)# line console 0
Router#(config-line)# lockable

Simply issue the lock command, and provide and confirm a password of your choosing (it need not be your username's password) to lock the terminal. Provide the password again to unlock the terminal.

Router# lock
Password: 
Again:

Locked

Password: 
Router#

For more tips like these (but not necessarily related to the console itself) check out the IOS Tips wiki page!

About the Author

Jeremy Stretch is a network engineer living in the Raleigh-Durham, North Carolina area. He is known for his blog and cheat sheets here at Packet Life. You can reach him by email or follow him on Twitter.

Posted in Tips and Tricks

Comments


shivlu
May 10, 2010 at 9:31 a.m. UTC

good tricks

regards Shivlu Jain http://www.mplsvpn.info


Mike (guest)
May 10, 2010 at 12:59 p.m. UTC

Great post usefull stuff, as always.


Colby
May 10, 2010 at 1:00 p.m. UTC

Changing the escape character is sweet, didn't know you could do that.


hunter_thom
May 10, 2010 at 2:48 p.m. UTC

Nice writeup. I've seen those commands before, but haven't used them myself.


dlots
May 10, 2010 at 7:18 p.m. UTC

thanks I always hate ctrl shift 6 x


dantel
May 11, 2010 at 12:58 a.m. UTC

I've recently started using the exec-timeout parameter since the default is annoyingly short. Thanks for the tips.


Roland (guest)
May 16, 2010 at 10:48 a.m. UTC

I like also "logging synchronous " on both vty and console.


Kish (guest)
April 18, 2012 at 8:18 a.m. UTC

Thankks Jeremy nice very useful.

Comments have closed for this article due to its age.