Cisco IOS devices maintain a session-based command history that allows network administrators to quickly recall, review, and reuse previously entered commands. This feature supports faster troubleshooting and more efficient CLI navigation on switches and routers.
Cisco IOS Command History
Something that the Cisco IOS devices do that can really help you out is that it keeps a history of the commands that you've typed into the device. This can really help out in a couple of different ways.
One that I'll use quite often is that you can toggle up through the commands you've already typed, so if there's a command you're using over and over again, you'll be able to recall that command very quickly. I'm going to show you an example of that here in a second.
The other thing that I can see where this could be really handy with is, let's say I entered a command into the device, maybe I entered it wrong and it caused a problem on the device, and now I need to figure out what it is that I typed in that is causing a problem. I'll go back through my history to see what commands I've typed in and how I can reverse what I did to make sure my device is functioning properly.
I'm on a switch here, and what I'm going to do is show you the history. To do that you just type in show history, and what it's going to do is show you the commands that I've typed in most recently. You can see that I've got some of the commands from my last video already in here, so I've got a little bit of a history going on here.
By the way, if I were to log out of this device and log back in, then I would not see the history again — it would create a new history for that session. So this is the history of my session here.
The way I can leverage this quickly is I can press the up arrow and it will scroll through the history. Just to note, this bottom one is the last one that I typed in, and it goes up through to the enable, so the enable was the first one I typed in, all the way through show history. When I press the up arrow, it's going up through that history, all the way through all those commands that I've typed in recently. If I press the down arrow, same thing, then it goes down through that history.
Another way that I can do this is with Control P and Control N, so I can use Control P and Control N to scroll up and down through that history.
Let's say I don't need a lot of history — maybe I want to reduce it, and maybe I just need three lines of history. There is a command I can change this with: terminal history size, and then I put in the size that I want it. So maybe I want it to be three lines. I hit enter, and now when I do a show history, it's only going to show me the last three lines that I've entered in.
Or maybe I want to increase it. More than likely I'm probably going to increase how much it's going to store, so maybe I want to go back 10 lines, and so I'll hit 10.
Notice that I'm using this in fact in several of my demos. You may notice that they're automatically coming up, and this is what I'm doing: I'm pressing the up arrow for it to come up — or one of the ways. There I've got show history, and I'm going to hit enter, and you can see that it's got now the last four lines that I've typed in. It doesn't include the lines that I've already shortened; I made the history smaller.
Let's say I don't want any history at all — I can turn it off. To turn it off I can do terminal no history, hit enter, and now when I do a show history, I don't see anything.
One thing that we can do to reverse this, let's say I do actually want to turn it on: I'm trying to press the up arrow so I can recall the terminal no history as a shortcut, and I don't have a history, so it's not doing it. I really like this feature, so I'm going to type in terminal history in order to make sure this is turned on, because I use this a lot.
This right here saves me a lot of time, because I just scroll up through those commands I've already typed and I'm not having to retype the same thing over and over again. Or maybe I'm recalling a command that I entered in wrong, and then I'm changing it to what I need to do, so I can quickly navigate the Cisco IOS and get the commands that I need.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →