MikroTik RouterOS CLI Principles

In the last part of this chapter, I would like to speak more about the RouterOS Command Line Interface (CLI). I just would like to show you the principles of the CLI just in case you were in a situation that you couldn’t use Winbox, and you only had access to the CLI of the router. Let’s start the LAB right away.

LAB: Basic Command Line Syntax on RouterOS

Again, we are still on the same LAB scenario. I will go to the Terminal on the router and click on “Tab” on the keyboard

As you see, once pressing on “Tab” you will have commands with a blue color and some with purple color.

[mepr-show rules=”319″ unauth=”message”]

The ones with blue color means that the command is not finished, and you need to write another syntax(es) after that command to finish it.

For example, you can see “system” command. This one we used it when we were changing the router name in the previous LAB. This command doesn’t finish, and you need to write some syntaxes after it to have a complete command.

While the purple ones are commands that don’t need syntax(es) after them to have a complete command. You can write “quit” and press enter, then the command will be taken, while if you write system and click enter then the command is not complete.

Sometimes you are in a hurry, and you don’t want to write the full command. For example, you want to change the router name. If you write “sys” and you press on “Tab” then the command will be taken as “system”. Let me show you.

I just wrote “sys”. Now I will press on “Tab” on the keyboard, and will get the following:

As you see, the command has been taken. That’s a much faster way to use the “Tab” when you want to go fast with writing commands.

If for example you wrote “system” and you forgot what command should come after it, then you can press “Tab” again and it will show you all possible commands that you can write after “system”:

Now you can see the list of commands after “system” and if you want to change the name of the router, then the next command after “system” should be “identity”.

In case you want to know what each of those commands can do, you can press on “F1” after “system” (instead of “Tab”) then the same commands will show up but this type they will come with a description. Let me show you this:

You have already noticed that those are the same list of command that we have seen when we pressed on “Tab” after system, but this time they have some description next to them.

Another thing that I like to show you is that whenever you go to the Terminal then you are on the root mode. And from the root you can go to folders. For example, if you write “system” and click enter then you are in “system” folder as the following:

Then if you write “identity” then you go also into the “identity” folder which is under the “system” folder.

Now let’s make “Tab” to see what commands come after that.

You see, we have only 5 commands possible in the “identity” folder.

What if I am on that folder and I remembered that I should do a ping to an IP address. Would the ping command work from that folder? Let’s try:

Unfortunately, not. And the reason is because “ping” is not listed as a command in the “identity” folder as to what we have seen. But is there any way to get over this problem so I remain in the “identity” folder, and I make the ping working? The answer is yes.

The ping always runs from the “root” level. So, we have 1 of the 3 options to use ping:

  • Option 1: quit the “identity” folder and go back to the root level and do the ping command from there. However, this is not what we want. The mission is to do ping without exiting the “identity” folder.
  • Option 2: use the “slash” (/) before the ping command. When you do (/) then you are saying to the router that you want to use the following command from the root level without you go back to the root level. Let me show you how this can be done:

  • Option 3: use “dot dot” (..) twice then the ping command after it. One “dot dot” takes you one level back. We are into 2 folder levels which are “system” and “identity”, then we should use “dot dot” twice as the following:

You see that I did the ping will I am still on the “identity” folder.

Now I will do ping again. The ping will keep running until you press “Ctrl + C”. On RouterOS, “Ctrl + C” doesn’t mean copy but this will stop a process happening on the CLI like ping.

Once I have clicked on “Ctrl + C”, the ping that was ongoing has stopped directly.

So now we know that using the “slash” will take me back to the root mode and using “dot dot” will take me one level back.

Let’s go to the root mode now. I will use the “slash” for this.

Excellent!!! I am on the root mode. Now If I click one “Tab” I should see what commands I can use from that root level as we already know:

What if I use another time the “Tab”? What will happen then?

Once I have pressed on the “Tab” another time, I have some other commands shown. Actually, those are programming syntaxes that you can use in case you want to run scripts on the MikroTik router. As being based on Linux kernel, we can run scripts on the MikroTik RouterOS to achieve some tasks. For example, we can run a script that the bandwidth speed changes during the night to a faster one than the one allocated to the daytime. We can run a script for failover, for routing, for anything we want. Of course, scripting is out of scope of this course, and it is not part of the MTCNA certification exam.

The last step that I want to do in this LAB, is to close the Terminal without using the mouse. We can do that using “Ctrl+D”. Once you do it, you will see that the Terminal has closed.

This is all what I wanted to explain in this chapter. I hope you enjoyed it and see you in the upcoming one.

[/mepr-show]

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

Please Login to Reply or add a comment!

About