Cisco IOS – Set Terminal Length & Width

There are times where you need to specify the length and width of the terminal when issuing commands either to properly format the output to be parsed by scripts easier, or to eliminate the need to hit space or return when issuing commands that have multiple pages of output. Most of the time I will only change these if I am gathering output as a part of my script.

Below is an example of changing the length of the terminal, you can specify the terminal length up to 512 lines if you want more than that you will need to specify the terminal length of 0, which is unlimited lines of output. Setting the length to 0 will allow for the entire output of a command like ‘show run’ to be printed to the terminal in its entirety after issuing the command. Below is an example of setting the length to 0.


To reset the length of the terminal to its default issue the following command.


The same concept applies to setting the terminal width, you can specify a width up to 512 columns, or if you want each intended line of output to display in its entirety on a single line versus automatically making line returns to fit properly in the terminal, you can set it to 0. The only times I have set the terminal width to 0 is for parsing output of commands like ‘show vlan’ which gives the vlan, name, status, and the ports that are assigned to that vlan displayed in a single line seperated by spaces. When the terminal width is set at its default it will make line returns after about 6 interfaces. For my scripts to parse this properly I need those ports on the same line, setting the terminal width to 0 before gathering that output will format it the way I need. Below is an example of setting the terminal width to 100.


And an example of resetting the terminal to its default width.


A thing to keep in mind these commands only last for the session, so if you establish a new SSH session the terminal will be reset to defaults. If you want to check what your terminal length and width is set to at its current moment issue a ‘show terminal’ command and in the output you will see the terminal length and width among other information. You can see the length and width can be found on line 3 of the output below.


Leave a Comment