The Command Line Interface
Chidiadi Anyanwu
OCI Certified Architect Associate | AZ-900 | HCIA-Datacom | BEng Electrical Engineering, University of Port Harcourt | Polymath
The average computer user clicks buttons and scrolls though a properly organized graphical user interface (GUI) to carry out tasks. An IT professional, however, would have to use command line interfaces (CLI) most of the time or at some point in time to interact with the computer. The same goes for anyone in networking. So, what is a command line interface, and how does it work?
In a graphical user interface, users interact with a computer program (or any electronic device) using graphical icons. Clicking an icon sends a command to the program. In a CLI, users rather send commands to computer programs using text. An example is the Command Prompt on Windows or the terminal on Linux.
To use a CLI, you have to know the commands for what you want to do. In a GUI, you don't need to know the command. Only the app developer does, and he programs your click (on a graphical element in a certain state) to send that command. You may wonder why anyone still uses CLIs when there are GUIs. First, you have to realise that CLIs are the default user interface of computers, and GUIs only came later. Even at that, you cannot access the full potential of your computer through GUIs.
On network devices, however, CLIs are used because they don't require much memory to run, and so would not impact on device performance or require more expensive hardware. There may be some other reasons I don't know, but CLIs are better when you have hardware with limited storage and there are no graphical tasks to be performed by the device.
Commands in CLIs differ by the program it interfaces with. In the case of network devices, that program is the operating system (OS). In networking, there are many OSes. There is Cisco's Inter-network Operating System (IOS), Huawei's Versatile Routing Platform (VRP), Juniper's JunosOS, Arista's Extensible Operating System (EOS), MikroTik's RouterOS and many others including free and open source ones like VyOS and OpenWRT. The OSes of network devices differ by manufacturers, so also their commands.?
No matter the differences, there are still some things all CLIs have in common, and those are important to know when dealing with CLIs.
THE HELP COMMAND
If you want to perform an operation on an OS you're not familiar with, you may not know the exact command used for that operation. You may not even know the commands the system recognizes, but you need to know them. That's where you need this feature. The help feature tells the system to display the in-built commands and their descriptions. That way, you can navigate the system without having to remember every single command.
You can do that by typing a question mark '?' on some OSes or 'help' on some other OSes.?
Some commands also have options (or option flags). They are additional parameters that modify the behavior of the command. They are written in the format '[command] -[option]'. For example, 'netstat -a'. They have long forms and short forms. For the long forms, you usually start with two hyphens and for the short forms, just one. For example '--version' is the same as '-v'.?Options can also be written together, for example '-v' and '-a' can be written as '-va'. You can also use the help command to display the options or commands associated with a command. Let's use the most popular command in networking as an example. The 'ping' command.
领英推荐
You can see from the images that the Huawei router uses the 'ping ?' command to show the options for the ping command. On Windows, however, you need to add an escape before the question mark 'ping /?'. On some other OSes, you may need to type 'help ping' or 'info ping' to get the options and descriptions.
THE ENTER KEY
In the CLI, the ENTER key is not used to create another paragraph. It is used to execute commands. Once you hit the enter key, the command on the present line is executed and you have a fresh line to type on.?
TAB COMPLETION
With command line completion, you can also be able to enter long commands without having to type them in full. Just like the help command, it doesn't work exactly the same way in all operating systems. Sometimes, you will have to type the first word before using the TAB key to cycle through the valid words. For some others, you can just type the first few characters and complete with the TAB key.
COMMAND HISTORY
The command line interpreters usually store the commands you used, so you can scroll back through the history and use a command you just used without having to type it again. The easiest way to do this is to simply use your up arrow key. With your up and down arrow keys, you can scroll through your previous commands and reuse them; but they won't be there if you close and reopen your terminal.
I believe this is enough information for a novice to begin exploring command line interfaces. If I got anything wrong, please correct me. If I forgot something or you would like to add something, please leave a comment.
If you enjoyed this article, don’t forget to like and share it and subscribe to my newsletter to read more articles like this.
I have learnt a lot following your newsletter just for few days