Operating System Design/Command line interfaces

From Wikibooks, open books for an open world
Jump to navigation Jump to search

A command line interface or CLI is a method of interacting with a computer by giving it lines of textual commands (that is, a sequence of characters) either from keyboard input or from a script. They were originally developed for interfacing with computers over teletype machines in the 1950s. It is occasionally also referred to as a CLUE, for Command Line User Environment. Some argue that the CLI is not actually a user interface at all, but a programming language, entered one line at a time, and has very little utility for users compared to developers. Indeed, command lines are most often used in scientific or engineering environments for programming.

In its simplest form, the computer displays a prompt, the user types a command on the keyboard and terminates the command with a keyboard key (usually the Enter key) and the computer executes the command. The computer then carries out the command given. The term is usually used in contrast to a graphical user interface (GUI) in which commands are typically issued by moving a pointer (via a pointing device) to a zone of the screen and pressing a button mounted on the pointing device (clicking).

Programs that implement these interfaces are often called command line interpreters. Examples of such programs include the various different Unix shells, VMS' DCL (Digital Command Language), and related designs like CP/M and DOS's command.com, both based heavily on DEC's RSX and RSTS operating system interfaces (which were also command line interfaces). Microsoft claims their next major operating system, Windows Vista, will include an enhanced command line interface named MSH (Microsoft Shell, codename Monad), which combines the features of traditional Unix shells with the object-oriented .NET framework.

Some applications provide command lines as well. The CAD program AutoCAD is a prominent example. Another excellent example is the engineering/scientific numerical computation package Matlab, in which practically no GUI exists and/or is unnecessary for performing most of the calculations. In some computing environments like the Oberon or Smalltalk user interface, most of the text which appears on the screen may be used for giving commands. The commands given on a command line interface are often of the form

[doSomething] [how] [toAFile]


[doSomething] [how] < [inputFile] > [outputFile]

doSomething corresponds to a verb, how to an adverb (it describes how the command should be performed in this instance — for example, should it be particularly "verbose", or particularly "quiet") and toAFile to an object (often one or more files) against which the command should be run. The standalone '>' in the second example is a redirection character, telling the operating system (i.e., usually a command shell interpreter) to send the output of the previous commands (that is, those on the left of '>') to some other place (that is, the file named to the right of the '>'). Another common and important redirection character is the pipe ('|'), which tells the CLI to treat the output of this command as the input of another; this can be a very powerful mechanism for the user, as explained under pipeline (Unix) and pipes and filters.