Useful IOS tricks (part 3) – the ‘do’ command
Jan.03, 2011, under Networks
I have a very short but very useful command for you today. You’ll often find yourself working within the IOS config mode, and you might forget little things such as ‘what is the interface number I need’, or ‘what is the current IP assigned to this interface’. Following this you probably go through a series of commands like the ones below
Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int fa 0/^Z <---Arrgh forgot which interface it was, Ctrl+Z out of config mode % Incomplete command. Router#sh ip int brief Interface IP-Address OK? Method Status Prot ocol FastEthernet0/0 10.10.10.1 YES NVRAM up up FastEthernet0/1 192.168.0.1 YES NVRAM up up Router#conf t <---OK found it, back into config mode Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int fa 0/0 etc
This gets annoying pretty fast, but luckily you can execute exec commands from within config mode by preceding them with ‘do’! This is a lot nicer:
Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int fa 0/ <---Arrgh forgot which interface it was, lets try 'do' % Incomplete command. Router(config)#do sh ip int brief Interface IP-Address OK? Method Status Prot ocol FastEthernet0/0 10.10.10.1 YES NVRAM up up FastEthernet0/1 192.168.0.1 YES NVRAM up up Router(config)#int fa 0/0
Much easier right? There are of course a few caveats, the main one being that you can’t use the ‘?’ symbol to remind you of the commands but its still a great little time saver.