I am not sure how deep I am going to dive into the Linux realm, as I do not intend to go so far as to go through a Linux+ certification course for a Linux Admin, but I did purchase David Bombal’s Linux for Network Engineers course on Udemy.
This will not be structured labs or Topologies (yet), but random notes as I familiarize myself with Linux, so my initial posts will probably seem fairly random and get better with time as I move on with Linux concepts.
Currently I have run the Ubuntu Bash Shell on my Windows 10 machine, bridged some EVE-NG routers to my Laptops network to at some point start using Python / Ansible push commands to them, however I need to learn to walk before I can run.
The first step to walking in my programming / Automation adventure is Linux!
I know that a lot of Network OS and GUI Applications such as CUCM servers run on a Linux platform that you never see or interact with, though I was surprised to see that some Cisco devices actually let you jump to Linux Bash Shell and Python by typing “run bash” and then “python” once in Bash Shell.
My 7200 images cannot perform this, however David Bombal demonstrates it on a Cisco Nexus Switch, which I doubt I can run with EVE-NG 🙂
I have installed an Ubuntu 18.x Virtual Machine I will be attempting to integrate with EVE-NG, however Ubuntu Linux Bash Shell can be installed natively on Window 10 with the following link:
https://docs.microsoft.com/en-us/windows/wsl/install-win10
From there you can go to the Windows 10 store to download which flavor of Linux you want to use, however it will only run the Bash Shell, for a Desktop version you will need to grab a Desktop Linux image and run it as a VM with VirtualBox or VMware Player which are both free to download and use.
This runs the same Bash Shell you get from downloading the Windows 10 Linux Shell, however from here you can jump between Bash and Desktop to familiarize with the OS structure, there is another HUGE advantage to creating a Linux VM vs Windows 10 Bash:
When you issue Bash Shell commands they will produce output to guide your learning!
To demonstrate this, I’ll use a common Bash command “ls” that is meant to list items in your current directory, first on Windows 10 native Bash Shell then in my VM:
Windows 10 Bash Shell “ls”
Ubuntu VM Bash Shell “ls”
As you can see unless you already know Linux Bash, you will need a VM to really be able to play with the Bash Shell and understand its structure, also we get a little message at the top in the VM advising to run commands as an admin (root) to use “sudo” before the Bash command – So learning Bash within a VM environment is almost necessary.
Speaking of Bash commands, I will explore that a bit here with some commands
There are some similarities between Bash commands and Windows Command Prompt that I learned just watching some quick reference videos, and the commands make sense in Bash / the command name is intuitive to its operation, however when working in Bash there is no ? to baby you along like Cisco IOS.
One thing to note quick is with Linux, the term folder and directory are interchangeable, as referencing a folder is exactly the same as referencing a point in the directory!
Also “Working Directory” refers to the Directory that you are currently working in.
A look at some of the similar commands from Bash to Command Prompt:
dir – Directory (to display a directories contents)
mkdir – Make Directory (to create a new folder / directory)
cd – Change Directory (to move to a different working directory)
pwd – Print Working Directory (Display contents of working directory)
ls – Lists general items in a directory (brief)
ll – Lists all content in a directory (verbose)
Before moving along I want to demonstrate how some of these translate to IOS
I fired up my physical lab for this demo as my EVE images are for some reason glitchy, so I logged into R1 and tested out some commands:
I first look at the current working directory / contents
R1#
R1#dir
Directory of flash:/
1 -rw- 36814048 Jul 21 2010 22:05:30 +00:00 c1841-spservicesk9-mz.151-1.T1.bin
256491520 bytes total (219676672 bytes free)
R1#pwd
flash:
I then make a new directory called ‘test’
R1#mkdir test
Create directory filename [test]?
Created dir flash:test
R1#cd test
R1#pwd
flash:/test/
R1#dir
Directory of flash:/test/
No files in directory
256491520 bytes total (219672576 bytes free)
I then go back to root / flash directory to verify ‘test’ is in the flash directory
R1#cd
R1#dir
Directory of flash:/
2 drw- 0 Dec 25 2019 02:35:54 +00:00 test
1 -rw- 36814048 Jul 21 2010 22:05:30 +00:00 c1841-spservicesk9-mz.151-1.T1.bin
256491520 bytes total (219672576 bytes free)
R1#
Then for the heck of it I make a directory within a directory
R1#cd test
R1#mkdir test2
Create directory filename [/test/test2]?
Created dir flash:/test/test2
R1#pwd
flash:/test/
R1#dir
Directory of flash:/test/
3 drw- 0 Dec 25 2019 02:42:02 +00:00 test2
256491520 bytes total (219668480 bytes free)
R1#
There are a few things here that become apparent with these commands:
- “pwd” is to check what directory you are in so you don’t get lost in the file system
- “dir” shows the contents of the current working directory
- “cd in IOS brings you back to root / flash, “cd /” in Linux brings you to the root directory in Bash Shell
Now a quick demo in how this looks within Linux Bash:
“cd /” made the ~ disappear indicating I was now at the Linux file systems Root Directory, confirming with “pwd” showing just /, and from here I got a slap on the hand to use “sudo …” to perform an admin function but it only prompted me once to put in the password – After that it let me sudo away commands at will without needing a password!
Moving along on R1 I try to remove the directory test here:
R1#rm test
Remove directory filename [test]?
Delete flash:test? [confirm]
%Error Removing dir flash:test (Can’t delete a directory that has files in it)
R1#
But cannot because it contains files and Cisco IOS does not allow that, whereas this is almost the same within Linux, but with a little extra help you can force it to remove:
I wanted to demonstrate something here that by entering ‘cd’ it brought me back to the “Home” directory, where the directory ‘test’ is not a part of, I have to go back to the “Root Directory” using “cd /” to remove ‘test’ directory.
Then when trying to remove it with “rm test” it indicates that it cannot remove it because test is a directory (it contains files / sub-directories), however when using the modifier “-r” to the command which is a “recursive” deletion or removal, where Cisco has something very similar in IOS which is not a command in Linux:
R1#delete ?
/force Force delete
/recursive Recursive delete
flash: File to be deleted
nvram: File to be deleted
R1#delete /recursive ?
/force Force delete
flash: File to be deleted
nvram: File to be deleted
R1#delete /recursive flash:test
Delete filename [test]?
Examine files in directory flash:/test? [confirm]
Examine files in directory flash:/test/test2? [confirm]
Delete flash:/test/test2? [confirm]
Delete flash:/test? [confirm]
R1#
It really made me confirm that I wanted to delete a directory in Flash that contained other directories, 4 times to be exact, whereas Linux just one confirm and its gone.
Another Linux command would be the “touch” command to create a file:
In the “ll” output it shows the two backward directories of Home and Root, and after issuing “touch myfile” it now displays a file within this directory, which of course can be removed with “rm myfile” while in the working directory “../test/”
With that little bit of foundation to go on, I will end it here for tonight!
There are some interesting similarities between Linux and Cisco IOS that demonstrates that it does run on top of Linux (as does almost every open source application), and that is really what I am going for is not a full blown “Linux Administrator” knowledge but enough to navigate my way through Linux Bash to work with Network Automation.
Merry Christmas to all, and to all a good night! 🙂