A command-line interface (CLI) processes commands to a computer program in the form of lines of text.
The program which handles the interface is called a command-line interpreter or command-line processor.
Operating systems implement a command-line interface in a shell for interactive access to operating system functions or services.
Such access was primarily provided to users by computer terminals starting in the mid-1960s, and continued to be used throughout the 1970s and 1980s on VAX/VMS, Unix systems and personal computer systems including DOS, CP/M and Apple DOS.
Today, many users rely upon graphical user interfaces and menu-driven interactions.
However, some programming and maintenance tasks may not have a graphical user interface and may still use a command line.
Alternatives to the command line interface include text-based user interface menus (for example, IBM AIX SMIT), keyboard shortcuts, and various desktop metaphors centered on the pointer (usually controlled with a mouse).
Examples of this include the Microsoft Windows, DOS Shell, and Mouse Systems PowerPanel.
Command-line interfaces are often implemented in terminal devices that are also capable of screen-oriented text-based user interfaces that use cursor addressing to place symbols on a display screen.
Programs with command-line interfaces are generally easier to automate via scripting.
Many software systems implement command-line interfaces for control and operation.
This includes programming environments and utility programs.
Comparison to graphical user interfaces
Compared with a graphical user interface, a command-line interface requires fewer system resources to implement.
Since options to commands are given in a few characters in each command line, an experienced user may often find the options easier to access.
Automation of repetitive tasks is simplified by line editing and history mechanisms for storing frequently used sequences; this may extend to a scripting language that can take parameters and variable options.
A command-line history can be kept, allowing review or repetition of commands.
A command-line system may require paper or online manuals for the user's reference, although often a "help" option provides a concise review of the options of a command.
It may be difficult for a new user to become familiar with all the commands and options available, compared with the icons and drop-down menus of a graphical user interface, without repeated reference to manuals.
Operating system command-line interfaces
Operating system (OS) command-line interfaces are usually distinct programs supplied with the operating system.
A program that implements such a text interface is often called a command-line interpreter, command processor or shell.
Examples of command-line interpreters include DEC's DIGITAL Command Language (DCL) in OpenVMS and RSX-11, the various Unix shells (sh, ksh, csh, tcsh, zsh, bash, etc.), CP/M's CCP, DOS' COMMAND.COM, as well as the OS/2 and the Windows CMD.EXE programs, the latter groups being based heavily on DEC's RSX-11 and RSTS CLIs.
Although the term 'shell' is often used to describe a command-line interpreter, strictly speaking, a 'shell' can be any program that constitutes the user-interface, including fully graphically oriented ones.
For example, the default Windows GUI is a shell program named EXPLORER.EXE, as defined in the SHELL=EXPLORER.EXE line in the WIN.INI configuration file.
These programs are shells, but not CLIs.
Application command-line interfaces
Application programs (as opposed to operating systems) may also have command-line interfaces.
An application program may support none, any, or all of these three major types of command-line interface mechanisms:
- Parameters: Most operating systems support a means to pass additional information to a program when it is launched. When a program is launched from an OS command-line shell, additional text provided along with the program name is passed to the launched program.
- Interactive command-line sessions: After launch, a program may provide an operator with an independent means to enter commands in the form of text.
- Inter-process communication: Most operating systems support means of inter-process communication (for example, standard streams or named pipes). Command lines from client processes may be redirected to a CLI program by one of these methods.
Some applications support only a CLI, presenting a CLI prompt to the user and acting upon command lines as they are entered.
Other programs support both a CLI and a GUI.
In some cases, a GUI is simply a wrapper around a separate CLI .
In other cases, a program may provide a CLI as an optional alternative to its GUI.
CLIs and GUIs often support different functionality.
The early Sierra games, such as the first three King's Quest games (1984–1986), used commands from an internal command line to move the character around in the graphic window.
The command-line interface evolved from a form of dialog once conducted by humans over teleprinter (TTY) machines, in which human operators remotely exchanged information, usually one line of text at a time.
Early computer systems often used teleprinter machines as the means of interaction with a human operator.
The computer became one end of the human-to-human teleprinter model.
So instead of a human communicating with another human over a teleprinter, a human communicated with a computer.
The mechanical teleprinter was replaced by a "glass tty", a keyboard and screen emulating the teleprinter.
"Smart" terminals permitted additional functions, such as cursor movement over the entire screen, or local editing of data on the terminal for transmission to the computer.
As the microcomputer revolution replaced the traditional – minicomputer + terminals – time sharing architecture, hardware terminals were replaced by terminal emulators — PC software that interpreted terminal signals sent through the PC's serial ports.
These were typically used to interface an organization's new PC's with their existing mini- or mainframe computers, or to connect PC to PC.
Some of these PCs were running Bulletin Board System software.
Early operating system CLIs were implemented as part of resident monitor programs, and could not easily be replaced.
Pouzin returned to his native France in 1965, and the first Multics shell was developed by Glenda Schroeder.
The Bourne shell was introduced in 1977 as a replacement for the V6 shell.
Although it is used as an interactive command interpreter, it was also intended as a scripting language and contains most of the features that are commonly considered to produce structured programs.
During the 1980s and 1990s, the introduction of the Apple Macintosh and of Microsoft Windows on PCs saw the command line interface as the primary user interface replaced by the Graphical User Interface.
The command line remained available as an alternative user interface, often used by system administrators and other advanced users for system administration, computer programming and batch processing.
In November 2006, Microsoft released version 1.0 of Windows PowerShell (formerly codenamed Monad), which combined features of traditional Unix shells with their proprietary object-oriented .NET Framework.
On these computers, users can access a Unix-like command-line interface by running the terminal emulator program called Terminal, which is found in the Utilities sub-folder of the Applications folder, or by remotely logging into the machine using ssh.
Before macOS Catalina, bash was the default.
Anatomy of a shell CLI
See also: List of command-line interpreters
Command-line interpreters allow users to issue various commands in a very efficient (and often terse) way.
This requires the user to know the names of the commands and their parameters, and the syntax of the language that is interpreted.
The Unix #!
mechanism and OS/2 EXTPROC command facilitate the passing of batch files to external processors.
One can use these mechanisms to write specific command processors for dedicated uses, and process external data files which reside in batch files.
Many graphical interfaces, such as the OS/2 Presentation Manager and early versions of Microsoft Windows use command-lines to call helper programs to open documents and programs.
The commands are stored in the graphical shell or in files like the registry or the OS/2 OS2USER.INI file.
This was adequate for batch systems that ran one program at a time, often with the programmer acting as operator.
This also had the advantage of low overhead, since lights and switches could be tested and set with one machine instruction.
Later a single system console was added to allow the operator to communicate with the system.
From the 1960s onwards, user interaction with computers was primarily by means of command-line interfaces, initially on machines like the Teletype Model 33 ASR, but then on early CRT-based computer terminals such as the VT52.
All of these devices were purely text based, with no ability to display graphic or pictures.
Unix also had the capability to save and re-run strings of commands as "shell scripts" which acted like custom commands.
When more powerful business oriented microcomputers arrived with CP/M and later DOS computers such as the IBM PC, the command-line began to borrow some of the syntax and features of the Unix shells such as globbing and piping of output.
Modern usage as an operating system shell
While most non-expert computer users now use a GUI almost exclusively, more advanced users have access to powerful command-line environments:
- The default VAX/VMS command shell, using the DCL language, has been ported to Windows systems at least three times, including PC-DCL and Acceler8 DCL Lite. Unix command shells have been ported to VMS and DOS/Windows 95 and Windows NT types of operating systems. COMMAND.COM and Windows NT cmd.exe have been ported to Windows CE and presumably works on Microsoft Windows NT Embedded 4.0
- Windows Resource Kit and Windows Services for Unix include Korn and the Bourne shells along with a Perl interpreter (Services of Unix contains Active State ActivePerl in later versions and Interix for versions 1 and 2 and a shell compiled by Microsoft)
- IBM OS/2 (and derivatives such as eComStation and ArcaOS) has the cmd.exe processor. This copies the COMMAND.COM commands, with extensions to REXX.
- cmd.exe and COMMAND.COM are part of the Windows NT stream of operating systems.
- Yet another cmd.exe is a stripped-down shell for Windows CE 3.0.
- An MS-DOS type interpreter called PocketDOS has been ported to Windows CE machines; the most recent release is almost identical to MS-DOS 6.22 and can also run Windows 1, 2, and 3.0, QBasic and other development tools, 4NT and 4DOS. The latest release includes several shells, namely MS-DOS 6.22, PC DOS 7, DR DOS 3.xx, and others.
- Windows users have a CLI environment named Windows Command Prompt, which might use the CScript interface to alternate programs. PowerShell provides a command-line interface, but its applets are not written in Shell script. Implementations of the Unix shell are also available as part of the POSIX sub-system, Cygwin, MKS Toolkit, UWIN, Hamilton C shell and other software packages. Available shells for these interoperability tools include csh, ksh, sh, bash, rsh, tclsh and less commonly zsh, psh
- COMMAND.COM (4DOS), Windows NT cmd.exe (4NT, TCC), and OS/2 cmd.exe (4OS2) and others based on them are enhanced shells which can be a replacement for the native shell or a means of enhancement of the default shell.
- Implementations of PHP have a shell for interactive use called php-cli.
- Standard Tcl/Tk has two interactive shells, Tclsh and Wish, the latter being the GUI version.
- Python, Ruby, Lua, XLNT, and other interpreters also have command shells for interactive use.
- FreeBSD uses tcsh as its default interactive shell for the superuser, and ash as default scripting shell.
- Apple macOS and many Linux distributions have the Bash implementation of the Unix shell. Early versions of macOS used tcsh as the default shell.
- Embedded Linux (and other embedded Unix-like) devices often use the Ash implementation of the Unix shell, as part of Busybox.
- Android uses the mksh shell, which replaces a shell derived from ash that was used in older Android versions, supplemented with commands from the separate toolbox binary.
- Routers with Cisco IOS, Junos and many others are commonly configured from the command line.
Most command-line interpreters support scripting, to various extents.
(They are, after all, interpreters of an interpreted programming language, albeit in many cases the language is unique to the particular command-line interpreter.)
Some command-line interpreters also incorporate the interpreter engines of other languages, such as REXX, in addition to their own, allowing the executing of scripts, in those languages, directly within the command-line interpreter itself.
In other cases, such a command interpreter can present a highly customised user interface employing the user interface and input/output facilities of the language.
Other command-line interfaces
The command line provides an interface between programs as well as the user.
In this sense, a command line is an alternative to a dialog box.
Editors and databases present a command line, in which alternate command processors might run.
On the other hand, one might have options on the command line, which opens a dialog box.
The latest version of 'Take Command' has this feature.
DBase used a dialog box to construct command lines, which could be further edited before use.
Basic is modeled on the default interface for 8-bit Intel computers.
Calculators can be run as command-line or dialog interfaces.
Emacs provides a command-line interface in the form of its minibuffer.
Commands and arguments can be entered using Emacs standard text editing support, and output is displayed in another buffer.
One controls the character by typing commands like 'get ring' or 'look'.
The program returns a text which describes how the character sees it, or makes the action happen.
The most notable of these interfaces is the standard streams interface, which allows the output of one command to be passed to the input of another.
Text files can serve either purpose as well.
This provides the interfaces of piping, filters and redirection.
Under Unix, too, so the normal type of file for the shell used for stdin,stdout and stderr is a tty device file.
Another command-line interface allows a shell program to launch helper programs, either to launch documents or start a program.
The command is processed internally by the shell, and then passed on to another program to launch the document.
The graphical interface of Windows and OS/2 rely heavily on command-lines passed through to other programs – console or graphical, which then usually process the command line without presenting a user-console.
A web browser's URL input field can be used as a command line.
Google, which has been called "the command line of the internet" will perform a domain-specific search when it detects search parameters in a known format.
This functionality is present whether the search is triggered from a browser field or on Google's website.
Many video games on the PC feature a command line interface often referred to as a console.
It is typically used by the game developers during development and by mod developers for debugging purposes as well as for cheating or skipping parts of the game.
- Comparison of command shells
- List of command-line interpreters
- Batch processing
- Console application
- Interpreter directive
- Read-eval-print loop
- Shell (computing)
- Scripting language
- Shell script
- Computer terminal
- Terminal emulator
- Run command
- Graphical user interface § Comparison to other interfaces
- In the Beginning… Was the Command Line
Credits to the contents of this page go to the authors of the corresponding Wikipedia page: en.wikipedia.org/wiki/Command-line interface.