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 interfaces, console 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. Show
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:
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:
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:
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:
Commands and syntax for CLIs tend to be very stable over time, in part to enable backward compatibility for scripts. Prompts and commandsDepending on the operating system and the CLI, there may be hundreds or even thousands of different executable commands available. The set of commands may vary dramatically between operating systems or applications. For example, Microsoft defines hundreds of cmdlets as "lightweight commands" to be used in PowerShell; PowerShell functions are lists of cmdlets that can be run at the command line.
Some commands run at the command line by themselves, such as the dir command: C:\> dir Commands can also be used with arguments (sometimes referred to as parameters) that modify how the command should be run. Arguments follow the command and provide additional details or specifics. The cd "change directory" command in many CLIs is used to change the current working directory when the desired new directory path is included as an argument -- but in some cases (as in MS-DOS or the Windows command prompt) the command by itself returns the current working directory. This command resets the current working directory: cd \documents\user\working Arguments enable command-line users to get very specific results that are sometimes not available through a graphical interface. Modern CLIs provide pipes, or mechanisms for taking the output of one command and sending it as input to another command. The vertical bar, or "|" symbol, is often used for this purpose. The following "one-liner" uses pipes to string together several PowerShell commands to retrieve detailed network configuration information from a Windows machine: Get-NetIPAddress | Sort InterfaceIndex | FT InterfaceIndex, InterfaceAlias, AddressFamily, IPAddress Even though this string is entered at the command line as if it were a single command, it includes the following consecutive commands:
Backward compatibility is often a goal when new CLIs are introduced to replace existing CLIs, as when Microsoft replaced MS-DOS with the Windows Command Prompt. Though some MS-DOS commands are no longer supported, most will still work in PowerShell as originally intended. Common MS-DOS commands include the following:
CLI versus GUIThe graphical user interface is the most popular user interface today. A GUI uses windows, menus and icons to execute commands. Using a mouse is the most common way to navigate through a GUI, although many GUIs allow some navigation and program execution via a keyboard. Microsoft Word is an example of a GUI-based application. A user can change options for page layouts and styles by selecting the corresponding icon or pull-down menu with a mouse or keyboard. One advantage of a GUI is the interface can visually display available functions. However, because it relies on graphical display, a GUI may not have the same level of functionality and granular control as a command-line interface. For example, it can require numerous clicks and movement through several dialog boxes in a GUI to accomplish the same result as a single command line. In addition, GUIs do not readily support scripting or automation. For common tasks, a user must repeat each click or navigate each dialog within the GUI manually. System administrators who may need to manage hundreds -- or hundreds of thousands -- of systems and configurations will find a GUI far less efficient than a CLI. A simple CLI command can easily adjust configurations for a large group of systems at once. Commands and arguments can also be combined and saved, then executed as a script each time that specific action -- or comprehensive set of actions -- is required. The CLI is the preferred tool for many enterprise-wide systems management tasks. Windows 11 GUI: The Start menuCLI advantages and disadvantagesThe following are advantages of a command-line interface:
The disadvantages of a command-line interface are the following:
The command line is a great place to become an expert at using a computer. Once you're ready, it's also the only place to learn how to write shell scripts. This was last updated in December 2021 Continue Reading About command-line interface (CLI)
Dig Deeper on IT operations and infrastructure management
Which command is used to register a system without using graphical environment?Which task(s) can be performed with Red Hat Subscription Management tools? Enable repositories. ... . Which command is used to register a system without using a graphical environment? subscription-manager.. Which GUI tool is used to register and subscribe a system? Red Hat Subscription Manager.. Which tasks can be performed with Red Hat subscription management tools?Red Hat Subscription Management can perform many of the tasks of the on-premise tools including:. Registering systems.. Attaching and renewing subscriptions.. Retrieving system facts, contract information, and UUID.. What Linux command can you use to switch users without actually logging off your system?The su command is used to run a function as a different user. It is the easiest way to switch or change to the administrative account in the current logged in session. Some versions of Linux, like Ubuntu, disable the root user account by default making the system more secure.
Which command is used to return to the current user's home directory assuming?To change directories, use the cd command. This command by itself will always return you to your home directory; moving to any other directory requires a pathname.
|