- So, are you serious about becoming
a better network engineer?
Are you going to become better than others around you,
or others in the industry?
In this video, I'm gonna show you how to use
Linux commands on Cisco IOS devices,
so that you can do things that others don't know how to do.
In a previous video, which I've linked here, and below,
I showed you how to enable or use Linux commands
by running a single command on a Cisco IOS device.
I'm not talking about dropping into a Linux shell,
or running a virtual machine on a Cisco device.
By simply typing one command on a Cisco IOS device,
you can run Linux commands, such as grep,
man, more, and many others.
You can also run scripts on Cisco IOS devices.
So, in other words, you can run Linux scripts
directly on the device by enabling a single command.
Now, this video is a continuation of the previous video,
and additional videos that I've created.
I wanted to add scripting to this video,
but the video's got too long,
so in this video I'm gonna answer some questions.
I'm also gonna address some feedback that I've received
about showing you additional options available
through these commands.
These commands are available as part of the Cisco IOS Shell.
You don't need to run anything fancy
to use these commands on Cisco IOS.
It's available on traditional Cisco IOS,
as well as additional platforms, such as IOS XE.
Now, I'm gonna ask you a favor.
If you find this video useful,
please consider subscribing to my YouTube channel.
Please like this video.
Click the bell to get notifications,
so that you know when I upload videos like this.
Change your life today.
Spend time going through this video
and learning things that other network engineers don't know
so that you can amaze a senior network engineer
when they see what you can do,
or you can amaze someone when you go for an interview.
Learn these commands, and set yourself apart from others.
Okay, so without further ado, let's get started.
(upbeat music)
Don't believe people who tell you
that you can't use Linux commands such as grep,
or man, or more, on Cisco IOS.
You can on traditional Cisco IOS.
Now, this feature is available
from version 15.1 of Cisco IOS.
It's been around for a long time.
This document, as you can see,
was first published in March 25, 2011,
so it's been around for a long time,
but you do need version 15 or later of Cisco IOS.
I've got, in this GNS3 topology,
a traditional Cisco IOS switch, and IOS router,
but I've also got a XE router.
So this is a Cisco CSR.
Now if you're not sure what that is,
this is classic, or traditional Cisco IOS
that's been around for many years.
Now, if you've used traditional devices,
such as 3750 switches, or 2800 routers, and so forth,
this is the IOS that we're talking about.
So, in this example, this switch is using vIOS layer two.
This router is a Cisco IOS vRouter,
so show version on the router,
notice it's running vIOS, or IOSv.
That's the version of IOS,
but this CSR router is running IOS XE,
so notice Virtual XE Software.
Notice the difference here, X86 64-bit Linux.
Wikipedia has a decent explanation of what Cisco IOS XE is.
It's basically the new IOS.
The problem with traditional Cisco IOS is it's monolithic.
There were so many features in it
that it became very difficult to manage or to develop on.
Traditional Cisco IOS supports things such as IPX,
AppleTalk, from many, many years ago.
Some of those features have been removed,
but what you'll find is a lot of features still exist
in the monolithic, traditional, classic Cisco IOS.
This version of IOS was developed
for the ASR 1000 series routers,
and the big thing to note is it's built on Linux,
so rather than just having Cisco IOS
running directly on a switch or router,
we have Linux running,
and then the IOS runs as a separate process on top of Linux,
and that's why you can drop down
to a Linux shell in Cisco IOS XE.
Now why am I telling you this?
Because one of the questions I got asked is,
"Is this Linux feature supported on XE?",
and the answer is yes.
But I'm not just gonna show you that,
I'm gonna show you an answer to another question as well.
One of the questions was, from a number of people,
was, "David, does it use a lot of CPU?
"Does it use a lot of memory to enable this feature?",
and I want to show you
that there are two ways to set this up.
You can either use the terminal option,
or you can use the configuration option.
The configuration option is the option
that I showed you in the previous video,
where I said shell processing full.
That is actually what they recommend.
Basically, that feature is then enabled on the device,
but you don't have to do it that way.
You can enable it just for the current terminal.
So, back in my GNS3 topology,
what I'll do is I'll do this on XE.
So notice, if I type show run | grep, and let's say, face,
it tells me that grep is not a supported command,
but if I enable terminal shell,
that feature will be available on this device.
So, show run | grep face, and notice that works.
If I exit out of the console,
so I've exited out of the console in this example,
and go back into the console,
and type show run | grep face,
notice the command is no longer supported.
So again, if I type terminal,
and there's a bunch of options here, but let's say shell,
and then run that command again, you'll notice it works,
but as soon as I exit out of the shell,
that command no longer works,
so I'm only enabling this for the current terminal.
So if you're concerned about processing power,
memory utilization, just enable it on your current terminal.
It'll only work for the current terminal,
and then it'll stop working once you exit your terminal.
Now I haven't seen any information
saying that this will use a lot of memory,
or take a lot of CPU power.
You're basically just extending the commands
that the device can support.
Okay, so there I've answered two questions.
Is it supported in XE, yes it is.
Is it supported on traditional IOS, yes it is.
Can you enable it just for the current terminal,
yes you can, so if you're concerned
about leaving this running,
only enable it for your current terminal.
So if you're working on the device,
and you type that command,
you'll be able to do things that a engineer
who doesn't know about this won't be able to do.
So they'll see you using commands
that doesn't work for them,
because you've just enabled the terminal shell
on your current shell, so that's quite nice to know.
Now someone else commented, "David, you should have shown
"that grep doesn't have to be case-sensitive",
so let me show you that.
Firstly, on a switch, if I type show run | include face,
this is not using the Linux commands, this is just include,
notice that works, but if I say Face with uppercase,
it doesn't work, because this is case-sensitive.
So the traditional include exclude commands
use regular expressions, and they're case-sensitive.
Now, the same is true if I use grep here.
Notice show run | grep face, that works,
but if I use Face, uppercase, it's not gonna work.
Okay, I'm getting a duplex mismatch in my GNS3 topology.
I'll quickly fix that, so, duplex full on the router.
Go back to the switch.
Notice this doesn't work.
So show run | grep Face, uppercase, doesn't work.
Not gonna work in this example,
but if I say -i, notice it does work,
because I'm saying ignore case.
Now if you're not sure about commands, simply use man.
So use the man pages, or manual pages.
So man, and the specific command,
and notice -i, or hyphen i, ignore case.
So that's really nice.
If you're not sure about is it uppercase,
or is it lowercase, or if you just want
to ignore case, then use -i.
Makes it a lot simpler in many ways to search for text.
Now, once again, to see the functions available,
use the command show shell functions,
so I'll just do that again,
show shell functions shows you
the various functions available, and here's a nice one.
Number the lines in the input.
If I type show run, traditionally I can use this command,
show run line number.
That shows me lines next to the running configuration.
That doesn't work, as an example,
with the command show ip route,
so notice show ip route line number,
the switch is doing a domain lookup here.
It works with show run, but doesn't work with ip route.
So I'll just type no ip domain-lookup
so we don't have that happening again,
so again, notice show ip route line number doesn't work.
Show ip route ?, a lot of options here,
but no options for line number,
but what I can do is say | nl,
and notice I get line numbers next to the output.
Now this switch is learning a lot of routes from the router,
so perhaps you don't want to do it that way.
You probably want to push this to more,
so you can see one page of output at a time,
or you may want to push this to a file,
so that you don't have so much output displayed.
So rather than doing it that way, I'm gonna say | more.
Notice I get one page at a time,
and I can use Spacebar to go through the output,
or simply use Q to quit, so just quit out of that,
if I don't want to see the entire configuration.
What's nice about this is I could say grep
for, let's say, 70, so show me line 70,
but I may just want to see a line that begins with 70,
so caret means beginning of line.
This is basic regular expressions.
So that could be quite useful.
You can now use line numbers on any command.
So, show ip interface brief shows me a list
of interfaces on the switch.
I can point that to nl to get line numbers,
so I'll just make this a bit bigger,
so notice I see line numbers,
and what you could do is,
when you're talking to someone else,
say, "Go and have a look at line number 20", as an example.
Now, again, I'm just using very basic examples here.
Use your imagination to think
about what you could use this for.
I could, as an example, once again, say grep caret,
beginning of line, let's say, 20.
Have a look at line 20.
So if you and I were discussing a configuration,
I could say, "Use this command,
"and go and look at this specific line in the output
"of any command, and then let's discuss that command."
Rather than trying to look for a command
in a long, running configuration,
or in a big routing table or something,
we can narrow it down to a specific line.
Now, you can also do this.
So, show ip interface brief, and let's do sort.
That just sorts the output.
Notice this is typically at the beginning.
So, show ip interface brief, we have Interface,
IP-Address, Method, Status, Protocol first,
but you could sort the output if you like,
and then push that to more.
So if you wanted to sort
output alphabetically, you could do that.
Let's do a funny one with show run.
So typically, show run looks like this.
There's a standard show run,
but what I'll do is sort that alphabetically,
and as you can see, the output is just being dumped,
so I should've pushed that to more,
once again, so let's push that to more.
And notice bgp is the first command,
then we've got ip, then a login, then media-type.
It goes all the way down to vlan.
So I've been able to sort the output.
So if you wanted to sort something alphabetically,
you could do that, rather than trying to look for something,
but I mean, there are, perhaps, better ways of doing this.
You could just, for instance, grep for something,
and in this case, I've used the wrong word,
so let's say vlan, grep for vlan.
Now I've gotta ask this, because this is YouTube.
Please subscribe to my YouTube channel.
Click on the bell to receive notifications
when I post a new video,
and please put comments below this video.
Tell me, did you find this video useful?
Have you got ideas of things
that you can do with what you've learnt in this video?
(upbeat music)