DEV Community

Cover image for A Beginner-Friendly Guide to Understanding the CLI and its Fundamentals
Aysha Muhammed
Aysha Muhammed

Posted on

A Beginner-Friendly Guide to Understanding the CLI and its Fundamentals

Have you seen a movie where the computer genius or a hacker is typing for a few seconds, and suddenly, a cascade of information unfolds on the computer non-stop? I bet you have seen them and wondered what magic is happening.

These scenes entertain you and show how computers are part of the greatest invention of all time. Nonetheless, behind the sleek user interfaces and vibrant graphics is a complex system awaiting instructions and exploration.

A cat pressing the keyboard to denote typing

Instructions are orders or precise commands given to computers to execute a task or perform an action — an example is deleting a file on the computer. Providing specific instructions to computers allows you to interact with them, explore the complex system, and harness the power that it provides.

Imagine for a second that you are the computer genius or the hacker behind a computer, you need it to execute some task and perform some action. You pull out your keyboard and type a couple of commands, giving instructions to the computer, and your task gets executed. This system of interaction with the computer is achieved using the Command line interface (CLI).

In this article, you will delve into understanding the CLI, its fundamentals, and how it differs from the Graphical user interface (GUI).

Understanding the Command Line Interface (CLI)

Before we dive into the explanation, let’s understand what an interface is. An interface is how a user interacts with the computer system or software. It creates a way for the user to send commands and instructions to the computer to get a response or task executed.

There are two methods of interacting with computer systems or software, they include:

- Graphical User Interface (GUI): The graphical user interface (sometimes pronounced as Goowi) is a graphical-based system of communicating with the computer system. It uses graphical components such as icons, menus, and buttons for communication. You can perform tasks or send commands by clicking and manipulating icons, buttons, and any other graphical element by pointing and clicking a mouse.

- Command Line Interface (CLI): The command line interface ( sometimes pronounced as cee-el-hi) is a text-based system of communicating with the computer system. It communicates using text typed as a command into the command line interpreter. It communicates using specific commands typed using a keyboard, and the computer system responds with a textual output. You can also perform tasks with these commands.

A CLI to list all files using Power Shell on Windows Operating System.

While some commands are the same across all Operating systems, most vary based on the type of operating system, software specificity, or application type. For example, the command ls lists all the folders in a particular directory on the computer system. This particular command is used across all operating systems. Unlike commands like git add, which can only work when you have Git installed on your computer system.

However, most users interact with the computer system by using the GUI because of its convenience for everyday tasks. Users who are developers, programmers, and system administrators prefer using the CLI. You may be wondering, why subject yourself to the torture of typing a myriad of commands you may need to memorize when you could just click-click and get the work done?

Why??!!

Just as the GUI provides convenience for everyday tasks, certain benefits come with interacting with the computer system using the CLI.

Advantages of Command Line Interface (CLI)

  1. Task Automation: The CLI can automate tasks. Instead of doing repetitive tasks by clicking your mouse and remaining focused on a single activity, the CLI allows you to type commands that help you automate tasks, freeing up your time to focus on other vital tasks, which increases efficiency and productivity.
  2. Fast Response time: The CLI executes tasks and commands quickly. Unlike a GUI, it takes less time when the user is already familiar with commands.
  3. Fewer Resources: In situations where you have limited resources, using the CLI can be convenient and help you execute your tasks without relying on other resources to navigate or click on icons, buttons, and menus to get the work done.
  4. Expert Feeling: Working with the CLI gives you a sense of expertise because professionals such as developers, system administrators, and programmers are some of the people who work with the CLI.

Disadvantages of Command Line Interface (CLI)

  1. Command Accuracy: it is essential to type commands accurately to get the desired output. A mismatch in commands, a missed alphabet, or a missed character can yield unexpected results or trigger an error.
  2. Unlimited Commands: As mentioned earlier, commands may differ across all operating systems or software. Intending users may need to familiarize themselves with different types and numbers of commands. This can be overwhelming to memorize and cause confusion while using the CLI, reducing efficiency.
  3. Not Beginner Friendly: It can be confusing for a user who is new to programming. They have to take their time to familiarize themselves with using the CLI and knowing the commands, unlike the GUI, where users can click and get tasks done.

Types of Command Line Interface (CLI)

  1. Shell CLI: This is the most common type of CLI. It takes a command from the keyboard and uses this command to interact with the operating system. An example is Bash for the Unix/Linux Operating system and Powershell/Command Prompt for the Windows Operating system.
  2. Development CLI: Software development frameworks and tools often come with their own CLI, which requires installation on your computer system. These CLIs are specifically designed to provide developers with framework-specific commands, making it convenient to compile code, run tests, manage dependencies, and perform various development-related tasks effortlessly. Examples include NPM, GIT, AsncApi CLI, and so on.
  3. Database CLI: This CLI provides specific commands that allow users to execute SQL queries, perform data manipulation operations, and control the database structure. Some examples include MySQL CLI, SQLite CLI, and MongoDB CLI.
  4. Terminal Emulator CLI: This CLI enables users to connect to a remote computer or server over a network connection. It simulates a terminal interface, displaying a command prompt and allowing users to execute commands on the remote machine. SSH clients such as PuTTY and OpenSSH are some of their examples.

Conclusion

As a beginner, there is much to learn regarding technologies, especially if you are following the path of programming, cloud engineering, or System Administration. As you advance, you may need to do a lot of installations and work with different development tools and even frameworks that may require you to use the CLI.

An adequate understanding of the CLI will help you get acquainted and make it easy to use without confusion. I hope this helps to unravel the command line interface.

Resources

You can check the resources below for further reading.

  1. What is a Command Line Interpreter?
  2. How to use the command line interface for Beginners

Top comments (0)