Command-Line Interface

Command-Line Interface

What is a command-line interface?

A command-line interface (CLI) is a text-based user interface (UI) used to run programs, manage computer files and interact with the computer. Command-line interfaces are also called command-line user interfacesconsole user interfaces and character user interfaces. CLIs accept as input commands that are entered by keyboard; the commands invoked at the command prompt are then run by the computer.

Today, most vendors offer the graphical user interface (GUI) as the default for operating systems (OSes) such as Windows, Linux and macOS. Most current Unix-based systems offer both a command-line interface and a graphical user interface.

The MS-DOS operating system and the command shell in the Windows operating system are examples of command-line interfaces. In addition, programming language development platforms such as Python can support command-line interfaces.

The command line dropped in popularity following the introduction of GUI-based personal computer OSes like Microsoft Windows and Apple's "classic" Mac OS in the 1980s. The command line remains an important tool for IT professionals, software developers, sys admins, network administrators and many others who prefer a more precise and reproduceable interface to their systems.

What is a shell?

In computing, a shell program provides access to an operating system's components. The shell gives users (or other programs) a way to get "inside" the system to run programs or manage configurations. The shell defines the boundary between inside and outside.

The following are the two types of operating system shells:

  • CLI-based shells offer users a concise and efficient mode of interacting with the OS, without requiring the overhead of a graphical user interface.
  • GUI-based shells are considered easier for beginners to use, but they also include a CLI-based shell for system administrators or power users who prefer to interact at a command prompt.

Bash is the most commonly used command-line shell for Unix-based OSes including Linux.

The software that handles the command-line interface is commonly referred to as a command language interpreter, a command processor or command interpreter. Two well-known CLI shells are PowerShell for Windows and Bash for Linux and macOS.

Shells are the outermost layer of the OS and are often separated from the underlying OS kernel. A shell operates like an application and can be replaced as needed. An OS may have more than one shell available, as in the following examples:

  • Microsoft Windows includes the Command Prompt app as well as the PowerShell application, both of which can be used to interact directly with the computer. The Windows Subsystem for Linux also provides a CLI with access to the underlying system.
  • Linux and other Unix-based operating systems usually provide the Bourne-Again Shell (bash) as the default shell. Other shells, including the C shell, Z shell and others, can be configured as the default system shell.

Because the shell is only one layer above the OS, users can perform operations that are not available in other interface types, such as moving files within system folders and deleting locked files.

To get the greatest benefit from using a CLI shell, users should learn a scripting language. Most command line shells can save sequences of commands in a script or batch file which may be fully programmable. Shell scripting is the foundation of basic systems management automation.

How do CLIs work?

Once a computer system is running, its CLI opens on a blank screen with a command prompt and commands can be entered.

Types of CLI commands include the following:

  • system commands that are encoded as part of the operating system interface;
  • executable programs that, when successfully invoked, run text-based or graphical applications; and
  • batch programs (or batch files or shell scripts) which are text files listing a sequence of commands. When successfully invoked, a batch program runs its commands which may include both system commands and executable programs.

CLI is more than a simple command/response system, as most have additional features that make one preferable to another. Some features include the following:

  • Scripting capability enables users to write programs that can be run on the system from the command line.
  • Command pipes enable users to direct the output of one program to be the input for another program ("piping" the flow of data).
  • System variables can be set at the command line, or the values of those variables displayed.
  • Command history features enable the user to recall previous commands issued. Some save command history for the session (like PowerShell), others can be configured to store session history for longer (like bash).

To view or add a comment, sign in

More articles by NISHI KUMARI

  • Streamlit

    Streamlit

    Streamlit is an open-source framework designed to create beautiful web applications for data science and machine…

  • What Is an iOS Developer?

    What Is an iOS Developer?

    An iOS developer produces applications for the iPhone, iPad and other mobile devices that use the iPhone operating…

  • What is a Non Banking Financial Company (NBFC)?

    What is a Non Banking Financial Company (NBFC)?

    A Non Banking Financial Company (NBFC) is a company registered under the Companies Act, 2013 of India, engaged in the…

  • Who is the Product Operations Manager?

    Who is the Product Operations Manager?

    In a nutshell, the product operations manager supports the product team. They enable product managers to focus on the…

  • What is Ad Hoc Analysis?

    What is Ad Hoc Analysis?

    Ad hoc analysis is a dynamic process that involves exploring data to answer specific questions or address immediate…

  • What is User Experience (UX) Design?

    What is User Experience (UX) Design?

    User Experience (UX) Design is all about creating products that provide meaningful and enjoyable experiences for users.…

  • Legacy Software

    Legacy Software

    The older programs which are developed decades ago that are still in use by performing modifications in order to meet…

  • Technical Support

    Technical Support

    Technical support can sometimes be a complex and confusing topic, especially for those who may need to become more…

  • Difference Between GitLab and GitHub

    Difference Between GitLab and GitHub

    GitLab GitLab is a repository hosting manager tool developed by GitLab Inc and used for the software development…

  • Convolutional Neural Networks

    Convolutional Neural Networks

    Convolutional Neural Networks (CNNs) are a specialized class of neural networks designed to process grid-like data…

Insights from the community

Others also viewed

Explore topics