The Command Line Interface
? Pexels

The Command Line Interface

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.

The 'ping ?'? command on a Huawei router in eNSP and the results.
Command prompt showing the 'ping /?'? command and the results

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

要查看或添加评论,请登录

Chidiadi Anyanwu的更多文章

  • Route Tables: Cloud & Networking

    Route Tables: Cloud & Networking

    One of the major mechanisms through which routing works is the route table. Route tables exist both in traditional…

  • How Domain Name System (DNS) Works

    How Domain Name System (DNS) Works

    DNS is something the internet lives and breathes on. It is one of the fundamental technologies that makes our present…

    1 条评论
  • Is HTTP A Networking Protocol (Pt 2) - The Evolution of HTTP

    Is HTTP A Networking Protocol (Pt 2) - The Evolution of HTTP

    In the last article, we introduced HTTP, talked about its working principle, methods and status codes. Now, we want to…

  • Is HTTP A Network Protocol?

    Is HTTP A Network Protocol?

    What is the difference between the web and the internet, or isn't it just two interchangeable names for the same thing?…

    9 条评论
  • The Point-to-Point Protocol

    The Point-to-Point Protocol

    The Point-to-Point Protocol (PPP) is one of many protocols used in Wide Area Network (WAN) connections. It is a…

    6 条评论
  • VPN Technologies - IPSec

    VPN Technologies - IPSec

    In my last article, we talked about GRE, its features and principles, its configuration and why it is usually used with…

  • VPN Technologies - Generic Routing Encapsulation (GRE)

    VPN Technologies - Generic Routing Encapsulation (GRE)

    Virtual Private Networks (VPN) are private networks built on top of public networks. These networks are called logical…

  • The Common, But Nameless Network Protocol

    The Common, But Nameless Network Protocol

    Unlike other protocols I’ve encountered in networking, there is one that people know but can't really tell you the…

    1 条评论
  • Virtual Local Area Network (VLAN)

    Virtual Local Area Network (VLAN)

    The concept of VLANs can be explained from two viewpoints; the viewpoint of scaling and that of isolation. I’ll explain.

  • The Dynamic Host Configuration Protocol (DHCP)

    The Dynamic Host Configuration Protocol (DHCP)

    Using the internet shouldn’t be so easy. You have to obtain an IP Address, configure it, configure your network…

    2 条评论

社区洞察

其他会员也浏览了