input license here

What is CLI? And Why Use CLI Instead of GUI






CLI what? CLI stands for command lother interface (command line interface). It is simply a program that allows the user to type text commands to instruct the computer to perform specific tasks.


Although very powerful, the use of CLI is not always well received. Beginners don't want to use it, because they think it's only for advanced users. But this is not true.


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


Origin of CLI


During the 1960s, CLI was heavily used.


Before that, humans had only a keyboard as an input device and computer monitors could only display textual information Operating systems such as MS-DOS used CLI as standard user interface.


Windows CLI Interface: Command Line Interface


That is, the user must type commands on the CLI to perform tasks, since this is the only way to communicate with the computer.


After entering the command, the result the user receives will be textual information or a specific action performed by the computer. Typing the command correctly is key.


If the user mistypes the command, they will most likely delete the wrong file or accidentally close the program before saving. These are what people see as the main downside to using the CLI.


After years of using only the keyboard and taking the risk of easily misusing the command line, The mouse was invented.


The invention of the mouse marked the beginning of the point-and-click method, as a new way to interact with computers.


This method is safer for the average user, so they don't need the CLI anymore. But, in the following, we will discuss which CLI is better to use. Please continue to read our article.


In addition, operating systems began to develop more attractive ways of programming, using GUIs (Graphical Uto be Interaction). The GUI itself is phenomenal because it uses buttons and menus to represent specific commands. This approach has proven to be very intuitive.


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


cal command on cli


Shell – The Platform Behind CLI


If we take a deeper CLI look at the operating system, we will find the shell.


Shell is a computer program responsible for processing all commands entered on the CLI. It reads and interprets commands and instructs the operating system to perform the required tasks.


In other words, the shell is the user interface for managing the CLI and acts as a middle man, connecting the user with the operating system. It is called a shell because it is the outer shell of the operating system where the user interacts first.


In fact, there are many things that the shell can handle, such as:



  • Working with files and folders

  • Open and end the program

  • Computer Process Management

  • Performing repetitive tasks


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


Windows Shell


The default shell in Windows is CMD.exe or Command Prompt. In fact, Microsoft used the Command Prompt from the past, where MS-DOS is the main operating system.


To open Command Prompt, you can click Start -> All Programs -> Accessories -> Command Prompt. Or, you can simply press Windows + R, then enter CMD and press enter.


Depending on what you need, enter one command or a combination. You can also enter commands that run in a sequence (one command is executed after another).


Command Prompt is so powerful that it can manage many things in the operating system Windows:



  • Change directory, directory listing, content, etc.

  • Treat network like IP network settings display

  • File management like renaming, moving, etc.

  • Media management like formatting and renaming volumes


Now, let's learn how to use some syntax in the command prompt:



To navigate to specific directory or folder in command prompt, use CD [path]. Make sure you add spacing before the projected path. Eg:


CD C:Program Files


To rename files in a specific directory, use REN [drive:][path] [source] [target]. If you mention the location, it means that the renamed file will be saved in the same folder. Eg:


REN d:untitled.txt untitled1.txt


To delete files in command prompt, use OF [filename]. If you want more options like forced deletion, you can add it before the filename. Eg:


DEL /F untitled.txt


To edit the name of a specific drive, use LABEL [drive:][new volume name]. Remember that you can use up to 32 characters for NTFS volumes and 11 for FAT volumes. Eg:


D: > LABEL d:MyData

Bash


Bash stands for Bourne Again Shell and developed by Free Software Foundation.


Bash is a type of shell used in MacOS and many distributions Linux. However, you can also install bash Linux on Windows 10.


In Linux, the Bash shell is one of many shells that Linux users can use. Other types are Tchs shell, Ksh shell and Zsh shell.


In most Linux distributions, the shell is located under the menu Utilities. If you use desktop Gnome, it will be named Terminal, but if you use WHERE, then the name is Consoles.


Whereas in MacOS, the program would be Terminal.app. To run this program, go to Application -> Utilities -> Terminal. Or, you can just type terminal using Spotlight search.


Once the terminal program opens, you can start typing commands. Basically, most commands include: command, argument, and option.


While command contains the command we want to execute, the argument tells where the command should work, and the option asks to modify the output.


Now is the time to learn how to use the shell.


To get started, you need to know the syntax for handling shells. It is also known as shell scripting – the way of using scripts in the CLI to run certain tasks.


While there are many commands that you can use with the CLI, they all fall under the two types:



  • Processing commands steps



  • Processing commands files


To understand command syntax in MacOS, learn from the following examples:



  • List all files in a directory


To know what files are in a specific directory, use ls.


The default command will exclude hidden files. To show all files, you can add -a. Eg:


ls -a

list all files in directory using CLI



To move to a specific folder, use cd destination. Eg:


cd ~/Desktop


To rename files in a specific directory, use mv source destination. Remember, you need to be sure of the file's name and extension. Eg:


mv ~/Desktop/untitled.rtf ~/Desktop/untitled1.rtf


To delete files in specific directory, use filename rm. To avoid deleting the wrong file, make sure you move to the correct destination folder first. Eg:


rm untitled.rtf

Again, it's important to type the command correctly. That is, you should pay attention to each character you use, including spaces. Not only that, make sure you type the right case.


If for certain reasons you want to stop the ongoing process on Command Prompt or Bash, just press Control+C.


Why should you use CLI rather than GUI?


As mentioned earlier, the GUI was developed in the operating system as soon as the mouse became the new input device to operate the computer.


We should admit that GUI visually appealing and easy to understand. But, for some mission critical tasks, CLI is much more powerful.


Here, we want to pick up a few points to explain why you should use CLI over GUI. However, we let you choose depending on the type of work.



  1. Consumes less resources
    It's no secret, this is a text-based program that requires very little computer resources. That is, with CLI, you can perform similar tasks with minimal resources.

  2. High precision
    You can use a specific command, aiming precisely with ease. As long as you don't type the wrong command it should work as you expect. Once you learn the basics, writing syntax isn't as difficult as you might think.

  3. Friendly repetitive tasks
    The GUI has evolved well over the years. But, this operating system may not give you all the menus and buttons to do all the tasks. One of the reasons is for safety. If you have to do such repetitive tasks, CLI can overwhelm you. For example, when you have to deal with hundreds of files in a directory, CLI allows you to use a single command for easy auto-repeat.

  4. Strong
    Most operating systems these days prevent you from tampering with the system's core processes. Windows has system protection and MacOS has SIP (System Integrity Protection). You will not be able to perform some system-protected tasks. With CLI, however, you'll have full control over your system.


To make it easier for you to visualize, we will compare the transfer process PSD sang HTML in web programming.


In the PSD to HTML issue, the process begins with creating a mockup in Photoshop. The Photoshop Document (PSD) will then be converted to HTML.


Converting PSD to HTML involves programming by hand. Web developer make sure the code used in the conversion will be neat. This is very important to achieve W3C . Principles.


W3C guidelines help the website to have good code so that it can be compatible with all browsers.


So knowing the code is very important to understand how the computer will run.


Same goes for CLI in the operating system. While the GUI looks appealing, the CLI is light, powerful, and simple.


Conclude


Although there was a long debate about CLI being only for experts, now you know it can also be for end users


The fact that most operating systems still provide CLI along with the GUI proves that CLI is very important. Also, using CLI brings more positive points than GUI because:



  • It needs less resources



  • It guarantees high precision



  • It handle repetitive work with ease



Now, you completely understand what CLI is, right? Get the job done using the CLI!





Author






Hai G. is an expert in managing and operating website services. He has many years of experience in VPS, Hosting, technical SEO, CMS. Especially love WordPress and have been using it for over 5 years now. His hobbies are reading, blogging, traveling and mentoring young people to start a business.





Related Posts
Diệp Quân
Nguyen Manh Cuong is the author and founder of the vmwareplayerfree blog. With over 14 years of experience in Online Marketing, he now runs a number of successful websites, and occasionally shares his experience & knowledge on this blog.
SHARE

Related Posts

Subscribe to get free updates

Post a Comment

Sticky