Introduction to CLI
CLI stands for Command Line Interface/Command Line User-Interface. This is basically an interface wherein the user can interact with the Operating System to perform some tasks not by a Graphical Interface but by entering some commands. The Command Language Interpreter then interprets these commands and appropriate action is performed by the system.
In earlier days when the Graphical User Interfaces (GUIs) were not well developed and the DOS operating system was used, all the actions to be performed were done using commands. The user used to write commands on the DOS-prompt, the interpreter would try to recognize that command and if it recognized the command as a valid one then the appropriate task was performed.
What is the purpose of CLI?
In the earlier generation of computers when the GUI-based operating systems were not developed, the computers used some command-based operating system like MS-DOS, Apple-DOS, Unix, etc. 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 that involved CLI were go to a directory, create a new one, create a file, write text to a file, delete a file, show files in a folder, etc.
However, even in the modern GUI world of Operating systems when 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 perform some system-related configurations on the server automatically based on the scenario such that they don’t need to actually 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 the 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.
4.6 (3,144 ratings)
However, in the configuration of the computer system, the CLI still finds a major use. CLI is mostly used these days by the software programmers or system administrator to perform some of their crucial tasks which otherwise 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 the wellbeing of each individual system. 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 OS level configurations of the system, 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 efforts with the use of CLI 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 to locate the icon and click it to open. 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 ideal way for the programmers to open an application or a path on their computers is to do 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 is widely used by programmers 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|
Note: All these commands are specific to Apple MAC OS. Their syntax may be different in other Operating System like Windows but their function remains the same.
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.
- 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 be executed without the knowledge of a user as well.
- 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 chances 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 then this age-old tool can still do wonders for you and help you save some precious time and also give you high reliability for performing some critical tasks.
This has been a guide to What is CLI. Here we discussed the basic concepts with Commands and also System Administrators of CLI. You can also go through our other suggested articles to learn more –