Introduction to CLI
CLI can be expanded as ‘Command-Line Interface’, which is nothing but a user interface that allows performing any functional operations on the system by accepting the inputs in the form of commands, instead of click and type form of inputs. It is common in traditional Disk Operating Systems (DOS), where the commands were entered in the DOS’s command prompt interface. Lately, this CLI is applied by the software or system administrators for configuring the computer systems, as similar actions in a graphical user interface (GUI) can take up a lot of time and manual actions.
What is the purpose of CLI?
When the GUI-based operating systems were not developed in the earlier generation of computers, the computers used some command-based operating systems like MS-DOS, Apple-DOS, Unix, etc. Thus, any human interaction with these OS was through some commands that were later interpreted by an interpreter that acted as a middleware between the human commands and the OS machine language.
Some of the most common day-to-day tasks involving CLI were going to a directory, creating a new one, creating a file, writing text to a file, delete a file, showing files in a folder, etc.
However, even in the modern GUI world of Operating systems, we have the most interactive and easy ways of interacting with the Operating System by performing clicks using the mouse, visit websites, etc. CLI is still used in many places to perform some basic tasks. The most common and frequent use of CLI is done by the programmers who use this tool to add/install components to their applications. They also use the CLI to automatically perform some system-related configurations on the server based on the scenario such that they don’t need actually to work on the server. They generally save a command file or a PowerShell script that would run the CLI commands on the server and perform the required operations/configurations.
Why we use it?
Nowadays, as we are all aware, computers have moved a long way from the command line tools to the more advanced and sophisticated Graphic User Interface, which are very simple and easy to use functions for any user to work with the computer and get the work done.
However, in the configuration of the computer system, the CLI still finds a major use. CLI is mostly used these days by software programmers or system administrators to perform some of their crucial tasks, which will consume a lot of time and effort if done with the GUI.
To understand this better and in some more details, let us see the use of CLI for programmers and system administrators separately.
CLI use by System Administrators
System Administrators here would refer to the person/team who looks after the Infrastructure in the IT world. The administrator can be a whole team of a big organization that looks after all the computer systems running in the organization and maintains each individual system’s wellbeing. A system Admin can also refer to an individual who works as a technical engineer to fix system related issues for the users that a normal user isn’t able to resolve by itself. These system admins use CLI widely to check the system’s OS level configurations and perform some tasks directly at the OS level that would otherwise require additional software to be downloaded for the GUI.
Apart from such tasks, a system admin in a large organization also needs to monitor all the systems regarding the latest software or OS updates being installed on the computer, perform some task periodically on each system by automation hence eliminating the need to run those tasks manually on a day-to-day basis. Another major use is that a configuration can be changed remotely just by running some commands on the computer without having the need to be physically present at the same location as the computer and do that task manually.
All of this reduces a lot of time and effort with CLI use, and it also ensures that security risk can be tracked and avoided even in large organizational structures with minimal human work.
CLI use by Application Developers/Programmers
The application developers also use CLI tools for their day-to-day work very extensively. If a normal user opens an application by the GUI, it will take him very less time to navigate to the Icon and click on it.
Now imagine a developer who has to open 1 application multiple times during the day, and each time he has to spend that much amount of time locating the icon and clicking it to open it. Still, one can argue that the application shortcut can be placed on the Desktop and can be easily accessed. Now again imagine, the same programmer has to open multiple such applications multiple times during the day.
Creating a shortcut for each of such program will make the desktop clumsy, and again finding the correct icon will consume time. Hence, the programmers’ ideal way to open an application or a path on their computers is to do it via command lines or the CLI. Programmers mostly remember the exact commands to open the applications they use frequently and also prefer opening the directory paths directly via commands.
Another major use for programmers is while writing the code for the application that they are developing. Most of the times, the programmers are required to add references to certain 3rd party libraries to their application to interact with the outside world that can include a printer connected to the same computer, a database where the application data is stored or even a file server that is located anywhere in the world and has some files that are used by the application.
Now the developer has an option to add these references/libraries by the GUI that will again consume some time. Also, when you search for a library in the GUI, you are provided with multiple options based on the search-engine behavior. At times this can cause the developer to install an incorrect reference.
However, if the user knows the exact library/reference they want, they can use the CLI to install that specific library in a single command. One of the most common and powerful Command Line Interpreter used by the programmers for this task is the Nu-get Package Manager (NPM) that programmers widely use across the world to do this task very efficiently.
Some of the most common CLI commands that even a normal user can find useful in their work have been listed below:
|cd||Change directory to the directory specified with the command||cd Desktop/|
|cd…||To move up one directory from the current directory||cd…|
|ls||List all the files and directories in the working directory||ls|
|mkdir||Create a new directory with the specified name inside the working directory||mkdir Personal|
|cp||Copy a file in the working directory to the specified directory||cp learning.txt Personal/|
|clear||Clear the current CLI Window||clear|
|exit||Exit from the CLI window||exit|
|help||Get help regarding all the commands and their usage||Help|
|help||You can also specify the command for which the help is required to get a detailed description||help cd|
Advantages and disadvantages of CLI
As with any other tool/technology in the world of computers, CLI also comes with its own advantages as well as some disadvantages.
Below are the advantages:
- If a user knows or can remember the commands, then the task can be performed very quickly as compared to a GUI.
- History of the last executed commands can be maintained for monitoring.
- Commands can be combined to create a script that can be run to perform a series of operations and can be scheduled
- so that it can run periodically without any further human efforts.
- A command run on CLI utilizes very less RAM memory and CPU cycle for completion.
- A CLI command can be deployed on a system remotely and executed without the knowledge of a user.
Below are the disadvantages:
- Remembering the exact syntax of the commands can be complicated. However, the modern-day CLI tools provide auto-completion to complete the basic commands in case the user forgets.
- It is not always evident what the command will do just by looking at a written command. Hence, no changes can be taken, and the user needs to ensure he knows the result of that command before executing.
- For a new user, getting used to CLI can be challenging and confusing.
- The user may need to learn a large number of commands to perform the tasks. However, people mostly remember only the commands that they frequently require in their work.
Through this article, we were able to know a lot about the CLI, what it is, what and how it is used, where is it used more frequently and most importantly, why is CLI still used in the modern world of appealing Graphics in computers. To summarize it all, although the User Interface in computers and OS have come a long way from CLI to GUI, it needs to be seen that the CLI still finds a lot of use and application in the OS level configurations and monitoring.
It can also reduce some of your precious time if you are doing some repeated task with the GUI that you can automate with the help of commands. Overall, CLI does require you to remember some commands and can be a little confusing at the start. But if you are patient and keen enough, this age-old tool can still do wonders for you and help you save some precious time and give you high reliability for performing some critical tasks.
This has been a guide to What is CLI. Here we discuss the detail concepts with commands and also System Administrators of CLI. You can also go through our other suggested articles to learn more –