A command line interface (CLI) is a type of human-computer interface (i.e., a way for humans to interact with computers) that relies solely on textual input and output. That is, the entire display screen, or the currently active portion of it, shows only characters (and no images), and input is usually performed entirely with a keyboard.
The CLI gets its name from the fact that it is an interface which contains command lines. A command line is a space on the display screen in which commands (i.e., instructions telling a computer to do something) are typed in by the user. Pressing the ENTER key after typing in a command causes that command to be passed to the shell. A shell, also referred to as a command interpreter, is a program that provides the CLI as well as reads commands that are typed on a keyboard and then executes (i.e., runs) them. The results of executing many, but not all, commands are also shown on the command line.
CLIs stand in sharp contrast to graphical user interfaces (GUIs), the other main type of human-computer interface. GUIs feature the use of graphic images, including windows, icons and menus. These objects are manipulated by a mouse (and can usually be manipulated to a limited extent by a keyboard as well).
A console is the display mode for which the entire monitor screen is occupied by a CLI. CLIs are also provided by terminal windows, which are text-only windows that can be opened in a GUI and which emulate a console.
The most familiar example of a CLI to many people is MS-DOS. However, CLIs are provided by most operating systems, although many people, particularly less skilled users, rarely, if ever, access them and may not even be aware that they exist. In the case of Linux and other Unix-like operating systems, the GUI is just an external wrapper on the CLI. But this is not necessarily true for other types of operating systems, such as the newer versions of Microsoft Windows and the Macintosh prior to OS X.
Early electronic computers used printers, punched cards and/or small lamps to interface with humans. The development of the CLI was made possible through the application to computers of teletype keyboards for input and cathode ray tubes (CRT) for output. This represented a major advance in the computer field because it made control far more flexible and efficient.
The development of the UNIX operating system beginning in 1969 represented another major breakthrough in CLIs. This is because it incorporated a number of new features that made them easier to use and more powerful, including an elegant simplicity, regular expressions (which provide powerful text searching and manipulation capabilities) and pipes (which allow multiple programs to be linked with great ease). Moreover, the ability of UNIX to be used on almost any computer with sufficient power largely eliminated the previous requirement of having to learn a new CLI for each brand or model of computer.
Both CLIs and GUIs each have advantages and disadvantages. There are situations in which a user will find a CLI is the most convenient and others in which the same user may prefer a GUI. Thus, the best operating systems offer users a choice of both CLIs and GUIs, thereby providing the maximum flexibility to use each where it is most advantageous or convenient.
Possibly the biggest advantage of the CLI as compared with the GUI on Unix-like operating systems is that it is more powerful and flexible. That is, it can be used to easily do things that are difficult or even impossible to do with a GUI. For example, CLI programs often provide more options than do their GUI counterparts, thereby providing greater flexibility of use. Also, multiple CLI commands can be combined using pipes to perform tasks that would be much more cumbersome, if not impossible, to perform with GUI programs. In addition, the command line version of a program can often to be used to perform a task when its GUI counterpart malfunctions or is not available.
Another advantage of CLIs is that they are typically self-documenting. That is, they state exactly what the user wants to do, and the more sophisticated CLIs keep a record of the commands that have been issued. This record can be accessed with the history command on Linux and other Unix-like operating systems.
One of the biggest advantages of GUIs is that they can facilitate working with images, including photos and page layouts (such as are used in desktop publishing). However, although CLIs themselves cannot show images, there are also command line programs (i.e., programs that operate from the command line) that can be used to manipulate images.
It is often said that GUIs are more intuitive that CLIs, and this is undoubtedly true in many situations. For example, it is much easier for a new user to move a file from one directory to another by dragging its icon with the mouse than by having to remember and type seemingly arcane commands to accomplish the same task.
GUIs also have the advantage of providing the user with immediate visual feedback in most cases, whereas there is often no feedback, or at least no obvious feedback, in the case of CLIs. For example, in a GUI the user can see immediately that a file is successfully moved from one directory to another, whereas in a CLI one or more additional commands will have to be issued to confirm this.
In addition, GUIs allow users to take full advantage of the powerful multitasking (the ability for multiple programs and/or multiple instances of single programs to run simultaneously) capabilities of modern operating systems by allowing such multiple programs and/or instances of a program to be displayed simultaneously. The result is a large increase in the flexibility of computer use and a consequent rise in user productivity.
However, some computer experts believe that it is best to first teach beginning computer users, particularly those who are students in schools, how to use the CLI, at least on operating systems that have a well designed CLI. Among the advantages of this approach are providing students with a better understanding of what is really happening in the computer and making it easier for them to learn simple programming.
One of the great attractions of Linux and other Unix-like operating systems is that they have maintained their CLI capabilities while continuing to improve their GUIs, thereby allowing advanced users to harness the full power of the computer while simultaneously making it easier for beginning and intermediate users. In contrast, the newer versions of Microsoft Windows (such as 2000 and XP) have downgraded their CLIs to marginal roles.
Not all CLIs are created equal. The contrast is particularly stark when comparing the two main CLIs, that of Unix-like operating systems and MS-DOS. Whereas the former is extremely sophisticated and powerful, the latter is primitive by comparison. This reflects the fact that UNIX was designed from the beginning by some of the greatest minds in computer history to provide the maximum power, flexibility, ease of use for computer specialists and economy of computer resources. However, MS-DOS was developed based loosely on an early version of UNIX but with many of its features (and thus much of its power, flexibility and elegance) stripped out in order to make it suitable for use on cheaper and less powerful computers and to allow ease of use by people with relatively elementary computer skills.
Created May 4, 2007.
Copyright © 2007 The Linux Information Project. All Rights Reserved.