Let’s continue with more IOS tips. Although the examples are shown on routers, they also work on IOS-based switches.
With recent versions of IOS you can execute privileged mode commands from the various “config” modes by prefacing the command with the keyword “do”. Here are some examples:
- Router(config)#do show running-config (displays the running config)
- Router(config-if)#do sh start (displays the startup config)
- Router(config-line)#do copy run start (saves the running config to NVRAM)
- Router(config-ext-nacl)#do wr (also saves the running config to NVRAM)
- Router(config-subif)#do ping 18.104.22.168
- Router(config-router)#do trace 10.20.30.40
Unfortunately, once you’ve gotten into the habit of typing “do” to the point where you can’t type a command without it, you’ll find that if you try to use it from user or privileged mode, it doesn’t work:
- Router>do show interface (this doesn’t work)
- Router#do sh run (neither does this)
- Router#do wr (nor this)
On a related topic, you can move from a subordinate config mode, such as “config-if” or “config-router”, to global config mode (GCM) with the “exit” command:
In other words, “exit” took us one level up. You can also move from a subordinate mode to GCM by executing any GCM command. Note how this moves us to GCM, executes the command, and leaves us in GCM:
- RouterA(config-router)#hostname RouterB
You can also jump from one subordinate config mode to another:
- Router(config-if)#router rip
Note that if you jump from one interface to another, the prompt doesn’t change, but you’re wherever you last told the router to be:
- Router(config)#int fa0/0 (places us into interface config mode for fa0/0)
- Router(config-if)#shutdown (shuts down fa0/0)
- Router(config-if)#int s1/1 (moves us to serial 1/1)
- Router(config-if)#shut (shuts down serial 1/1)
Since the prompt does not indicate which interface you’re configuring, if at any time you’re not sure where you are, execute the commands necessary to put yourself back where you need to be. This applies to routing protocols, as well, for which the prompts all appear as “config-router”:
- Router(config)#router rip (places us into router config mode for RIP)
- Router(config-router)#version 2 (selects RIP v2)
- Router(config-router)#router ospf 1 (moves to OSPF process 1)
- Router(config-router)#router-id 22.214.171.124 (configures router ID for OSPF 1)
Online help and tab-key completion for a command are only available at the native prompt for that command. For example, this will display the available IP routing protocols:
- Router(config)#router ?
But this will not:
- Router(config-if)#router ?
Likewise, this will display the interface types:
- Router(config)#int ?
But you can’t display the interface types from within interface config mode:
- Router(config-if)#int ?
The tab key will work here, displaying “interface” as the complete keyword:
But not here:
Next time, more IOS tips and tricks!