Switch records or stores command that have been entered. It is very useful features to recall long and complex commands.
By default, switch records 10 commands in its history buffer. We can change this number for a current terminal session or for all session.
To change this number for current terminal session, go into priviledeged mode and enter the below command
csr1000v-1#terminal history size ?
<0-256> Size of history buffer
The range is 0 to 256. We will specify the range 4.
csr1000v-1#terminal history size 4
Use show history to check last entered commands. In our case, it display last 4 commands that have been entered
csr1000v-1#show history
show running-config
show startup-config
show ip bgp summary
show history
csr1000v-1#
Changing history buffer for all session.
To change buffer size for all session, enter below command for a particular line such as line vty 0 4
csr1000v-1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
csr1000v-1(config)#line vty 0 4
csr1000v-1(config-line)#history ?
size Set history buffer size
<cr> <cr>
csr1000v-1(config-line)#history size 3
csr1000v-1(config-line)#
We can also disable this feature using command “terminal no history” for current session and “no history” line mode for all session.
Netmiko Script to change history buffer size for current termial session
from netmiko import ConnectHandler
net_connect = ConnectHandler(device_type = 'cisco_ios', host='131.226.217.143', username='developer',password ='C1sco12345')
output = net_connect.send_command("show terminal | include History")
print('Current history buffer ')
print(output)
print()
print('Changing the history buffer size to 9.....')
net_connect.send_command("terminal history size 9")
output = net_connect.send_command("show terminal | include History")
print(output)
Output
Current history buffer
History is enabled, history size is 3.
Changing the history buffer size to 9.....
History is enabled, history size is 9.
Process finished with exit code 0