What is CLI?

What is CLI? Simply put, CLI stands for Command Line Interface. It is a program that allows users to write text commands instructing the computer to perform specific tasks.

Despite being so powerful, the use of CLI has not always been well received. Beginners are reluctant to use it, thinking that it is only for advanced users. But that’s not true.

In this article, you will learn everything you need to know about CLI.

CLI Roots

In the 1960s, CLI was used intensively.

Back then, people only had a keyboard as an input device, and the computer screen could only display text information. Operating systems like MS-DOS used the CLI as the standard user interface.

Basically, users had to type a command into the CLI to perform tasks, since this was the only way to communicate with the computer.

After typing a command, the output users get is text information or a specific action performed by the computer. That said, the key is to type the correct command.

If users type the wrong command, they are likely to end up deleting the wrong files or accidentally closing the program before saving their work. This is what people consider to be the main drawback of using CLI.

Then, after years of just using a keyboard and risking command line misuse, the mouse was invented.

The invention of a mouse ushered in the point-and-click method as a new way of interacting with the computer.

This method is much safer for average users, so I moved them away from the CLI. But, later on, we will see that using CLI is better.

In addition, operating systems began to develop an attractive way of computing, using GUI (Graphical User Interaction). The GUI itself was phenomenal due to the use of buttons and menus to represent specific commands. This approach has been shown to be very intuitive.

Today, the GUI has become a common way of computing. However, most operating systems still offer a combination of CLI and GUI. For example, Mac users can type “cal” in the Terminal or click on the Calendar app and get the same results.

Shell: the basis behind the CLI

If we dive from CLI into the deepest part of an operating system, we will find a shell.

See also  How to block IP addresses using IP Manager or .htaccess

Shell is a user interface responsible for processing all commands typed in CLI. It reads and interprets the commands and tells the operating system to perform the requested tasks.

In other words, a shell is a user interface that manages the CLI and acts as the middle man, connecting users to the operating system.

In practice, there are many things that a shell can process, such as:

  • Work with files and directories
  • Open and close a program
  • IT process management
  • Performing repetitive tasks

Among many shell types, the most popular are Windows shell (for Windows) and bash (for Linux and MacOS).

Windows Shell

The default shell on Windows is CMD.exe or the command prompt (symbol of the system). In fact, you’ve used the command prompt since the old days, when MS-DOS It was the main operating system.

To open the command prompt, you can click Start -> All Programs -> Accessories -> Command Prompt. Or, you can just press Windows+Rthen write cmd and press Enter.

Depending on what you need, type a single command or a combination. You can also write commands that are executed within a sequence (one command is executed after another).

The command prompt is so robust that it can manage many things within the operating system:

  • Change directories, list directories, content, etc.
  • Network management, such as displaying IP network configurations.
  • Manage files, such as renaming, moving, etc.
  • Manage media, such as formatting and renaming volumes.

Now, let’s learn how to use the Command Prompt syntax:

Bash

Bash is an acronym for Bourne Again Shell and was developed by Free Software Foundation.

It is a type of shell that is used in and by many distributions of the . However, you can also install bash Linux on Windows 10.

On Linux, the Bash shell is one of many shells that Linux users can use. The other types are shell Tchs, shell ksh Y Zsh shell.

On most Linux distributions, the shell is found in the menu Utilities. If you use the desktop gnomesthe name is Terminalbut if you use KDEthe name is Konsole.

Meanwhile, on MacOS, the program is Terminal.app. To run this program, go to Application -> Utilities -> Terminal. Or you can just write terminal using Spotlight search.

See also  How to create a WordPress theme? 5 step guide using code

Once the terminal opens, you can start typing a command. Basically, most commands consist of: the command itself, the argument, and the option.

Although the command contains the instruction that we want to perform, the argument indicates where the command should operate, and the option requests that the output be modified.

Now it’s time to learn how to use the shell.

To get started, you need to know the syntax for working with the shell. This is also known as shell scripting, these are ways to use the script in the CLI to execute certain tasks.

While there are many commands you can use with the CLI, they all fall into two categories:

  • The commands that manage the processes
  • The commands that handle the files

To understand command syntax in MacOS, let’s learn from these examples:

Once again, it is important to type the correct command. That means you have to pay attention to every character you use, including the space. Not only that, make sure you type the correct file name.

If for certain reasons you want to stop the ongoing process in Command Prompt or Bash, simply press Ctrl+C.

Why would you use CLI instead of GUI?

As we mentioned before, the GUI developed within the operating system as soon as the mouse became a new input device for operating the computer.

We must admit that the GUI is visually appealing and easy to understand. But for some vital tasks, the CLI is much more powerful.

Below we would like to highlight a few points why you would use CLI instead of GUI. However, you can choose based on your type of work.

  1. Fewer resources
    It is not a secret that the text-based program needs very few resources from your computer. This means that with CLI you can perform similar tasks with minimal resources.
  2. High accuracy
    You can use a specific command to target specific destinations with ease. As long as you don’t type the wrong command, it will work like a charm. Once you learn the basics, writing syntax isn’t as hard as you might think.
  3. Friendly with repetitive tasks
    The GUI has developed well over the years. However, the operating system may not provide you with all the menus and buttons to perform all the tasks. One reason is security. This will leave you overwhelmed if you have to do repetitive tasks. For example, when you have hundreds of files to handle within a folder, CLI allows you to use a single command to easily automate iteration.
  4. Powerful
    Most current operating systems prevent you from crashing the core system process. Windows has system protection and MacOS has SIP (System Integrity Protection). You will not be able to perform certain tasks that are protected by the system. However, with CLI, you will have full control over your system.
See also  What is a Curl command and how to use it?

To give you an illustration, there is a method called PSD to HTML in website development.

In PSD to HTML, the process begins with creating a mockup in . Then the Photoshop document (PSD) is converted to HTML.

PSD to HTML conversion involves hand coding work. The developer will make sure that the code used in the conversion is clean. This is important to pass the .

W3C compliance will ensure that the website has good code to make it cross-browser compatible.

Therefore, understanding the code is vital to understanding the core process.

The same goes for CLI in the operating system. While the GUI may look attractive, the CLI is lightweight, powerful, and simple.

conclusion

Despite a long debate that CLI is only for experts, you have now learned that it is also for average users.

The fact that most operating systems still provide CLI along with GUI shows that CLI is crucial. Also, using CLI gives more positive points than GUI because:

  • Needs to fewer resources
  • secures high accuracy
  • Handle repetitive tasks easily
  • It is powerful

Now, you can start working with CLI.

Deyi is a digital marketing enthusiast, with a background in web design, content creation, copywriting, and SEO. She is part of ‘s SEO & Localization team. In her free time, she likes to develop projects, read a book or watch a good movie.

Loading Facebook Comments ...
Loading Disqus Comments ...