Skip to content
— CH. 1 · INTRODUCTION —

Command-line interface

15 min listen · Ch. 1 of 8
8 sections
  • A command-line interface, or CLI, is a way of controlling software by typing commands as lines of text. In Colossal Cave Adventure, a game released in 1975, a player explores an underground cave system. The whole interaction runs on just one or two typed words at a time. Decades before that game existed, people gave computers instructions in far more mechanical ways. Somewhere between those early machines and that cave sits a story of typewriters and time-sharing computers. It ends with a French engineer who gave this style of interaction a name still used today: the shell. This documentary follows how a typed line of text became one of computing's most durable interfaces. It never fully disappeared, even as graphical screens took over most computers.

  • The Whirlwind I computer at MIT started using typewriter-like inputs for direct control in 1951. That was a sharp break from batch processing, where an operator took a stack of punched cards and returned results hours later. By 1963, the Teletype Model 33 let an operator type a single command and receive a printed response straight from the computer.

    The Compatible Time-Sharing System, known as CTSS, was built at MIT in 1961 as computers grew powerful enough to serve multiple users at once. For the first time, a person could type a command like LOGIN or PRINT. A dedicated program called the supervisor would parse that text and carry out the matching function.

    In 1964, an MIT Computation Center staff member named Louis Pouzin built a tool called RUNCOM for running command scripts with argument substitution. Until then, command-line systems were often locked inside resident monitor programs that were hard to replace. Multics became the first time-sharing operating system where the shell was a replaceable component. Pouzin coined the word shell to describe this technique of treating commands like a programming language. He then wrote a paper explaining how to build the idea into Multics. He returned to his native France in 1965, and Glenda Schroeder finished building the first Multics shell.

    Ken Thompson wrote the first Unix shell, the V6 shell, at Bell Labs in 1971, closely modeled on Schroeder's design. The Bourne shell arrived in 1977 to replace it. It worked as both an interactive command interpreter and a full scripting language with the features needed for structured programs. It led directly to the KornShell, the Almquist shell, and eventually the Bourne-again shell, better known as Bash.

    The command line also powered early home computers like the Commodore PET, the Apple II, and the BBC Micro. These machines almost always ran a BASIC interpreter. Business-oriented microcomputers running CP/M, and later DOS machines such as the IBM PC, borrowed syntax and features from Unix shells, including globbing. A rival built entirely on pictures rather than typed words was only a few years from reaching ordinary desks.

  • The command line's first serious challenge came from PARC's graphical approach, adopted by the 1983 Apple Lisa and the 1984 Apple Macintosh. A handful of computer users tried early graphical alternatives such as GEOS and Windows 3.1. Most IBM PC users, though, kept their COMMAND.COM shell until Windows 95 arrived in 1995. Even after that shift, the command line survived as the tool of choice for system administrators and programmers handling system administration, coding, and batch processing.

    A command-line interface asks less of a computer's hardware than a graphical one does. Each option is typed in just a few characters instead of found through a menu. That efficiency let an experienced user reach the same result faster than clicking through icons. Line editing and history mechanisms simplify repetitive tasks, sometimes growing into a full scripting language that takes parameters and variable options. A kept command-line history lets someone review or repeat earlier commands at will.

    A command-line system often needs paper or online manuals for reference, even though a built-in help option often gives a quick summary. It also skips graphical touches like varied fonts or the extended edit windows found in a GUI. A new user can struggle to learn every command and option, compared with the icons and drop-down menus of a graphical interface.

    In November 2006, Microsoft released version 1.0 of Windows PowerShell, once codenamed Monad, blending traditional Unix shell features with its own object-oriented .NET Framework. Apple's macOS has run on the Unix-like Darwin operating system since 2001. Users can open a command-line interface through the Terminal program in the Utilities folder, or by logging in remotely with ssh. Z shell is macOS's default shell today, though Bash, tcsh, and the KornShell are also included. Before macOS Catalina, Bash held that default position instead. Underneath every one of those surviving shells sits a common grammar that GUIs never needed to have.

  • Strip a command line down to its basics and the pattern reads: a prompt, a command, then parameters running from param1 up to paramN. The prompt is output by the program to signal readiness for input, often ending in a cue symbol. The command itself falls into one of two classes. Internal commands are built directly into the interpreter, while external commands run separate executable files that the interpreter searches for by name. Whatever parameters follow depend entirely on the command, and they may work as arguments or as options.

    A command-line interface can be broken down into syntax and semantics. Syntax is the grammar every command must follow, and DOS and Unix each define their own separate set of rules. Embedded-systems vendors like Nortel, Juniper Networks, and Cisco Systems each define their own proprietary rule sets as well. Semantics, by contrast, define what operations are possible, on what data, and how the grammar represents them. Two different CLIs might share only syntax or only semantics, but users can move freely between them, and reuse scripts, only when both match.

    Unlike a button or a menu item, a typed command line states exactly what the user wants done, with no hidden steps. Most commands come loaded with defaults that a user can override to customize the result. A frequently used command can be saved under a shorter alias. Several commands can also be grouped into a single script, or command procedure. That could mean compiling, installing, and running a program as one step. The greater-than symbol in a command line redirects output to a named file instead of the screen, overwriting it. A double greater-than symbol appends to the file instead of overwriting it. A vertical bar creates a pipeline, feeding the output of one command directly into the next as its input.

    Commands generally take a verb-adverb-object shape, written as doSomething how toFiles. DoSomething acts as the verb, how as an adverb such as whether to run quietly or loudly, and toFiles as the object, typically a file. Before any of those words get typed, though, the prompt that invites them can look wildly different depending on the system.

  • A command prompt usually ends in one of six characters: a dollar sign, percent sign, pound sign, colon, greater-than sign, or hyphen. It often also displays extra context, such as the path of the current working directory and the hostname of the machine. On many Unix systems, an ordinary user gets a dollar or percent sign, while the superuser, known as root, gets a pound sign.

    End users can often reshape their own prompt, adding colors, special characters, or live variables like the time, the username, or the current working directory. In DOS's COMMAND.COM and in Windows NT's cmd.exe, a user changes the prompt with a PROMPT command or by editing the %PROMPT% environment variable directly. Typing PROMPT $P$G produces the familiar C:\> style seen on most modern systems. The plain PROMPT command alone once produced the older C> style on early DOS machines.

    Many Unix systems rely on a variable called $PS1 to define the prompt's look. In Bash, a command such as export PS1='\t \u@\H: \W $' builds a prompt showing the time, username, and working directory before the dollar sign. Zsh adds a second variable, $RPROMPT, that displays information on the right-hand side of the same line without changing where text entry actually happens.

    RISC OS marks its command prompt with a plain asterisk, which is why its operating-system commands are nicknamed star commands. A user can run those same commands from other command lines, such as the BBC BASIC command line, by placing a star before them. IBM's TSO system takes a different approach, calling its own prompt the READY prompt after the word READY that appears on the screen. Everything a user types after that prompt, from a single word to a long string of characters, is where the real instructions begin.

  • In Unix, typing rm file.s hands the program rm a single command-line argument, instructing it to remove the file named file.s. A command-line argument, more broadly, is any piece of information given to a program the moment it starts. Languages such as C, C++, and Java let a program read its arguments as string parameters inside the main function. Python instead exposes them through its sys module, most often via sys.argv.

    In Unix-like systems, a single hyphen used in place of a file name carries a special meaning. It tells a program to read from standard input or send data to standard output.

    On Unix-like systems, the older convention marks an option with a single hyphen followed by one letter, as in -c. A command-line option, sometimes called a flag or a switch, changes how a command behaves, an effect controlled entirely by that command's own program. The newer GNU convention instead favors two hyphens followed by a full word, as in --create. Two hyphens on their own, with no letters after them, tell the interpreter to stop treating anything that follows as an option. That matters if a file name itself happens to begin with a hyphen. The getopt function and program, along with the getopts command, are the usual tools for parsing these options.

    Multics allowed its command-line options and subsystem keywords to be shortened. The idea traces back to the PL/I programming language and its own short keywords, like STRG for STRINGRANGE and DCL for DECLARE. In the Multics forum subsystem, for instance, the parameter -long_subject could be typed simply as -lgsj. Other systems automated abbreviation entirely. A user could type just enough of a command's first letters to identify it uniquely, the way SU stands in for SUPERUSER. Some systems instead hardcoded specific shortcuts, such as MD for MKDIR in COMMAND.COM. Others let users define their own through batch scripts and aliases, as with alias md mkdir in tcsh. None of these shortcuts mattered, though, if a system had already decided which commands a user was allowed to run in the first place.

  • Renaming a favorite editor to EDIT is a simple trick some users apply on Unix-like systems or Windows. Which executable actually runs depends entirely on what is named along that system's PATH. The set of commands available to a user can be changed simply by editing that PATH environment variable, or its equivalent. On Unix-like systems, the file holding a command's executable or script also needs execute permission before it will run. Directories in the PATH are searched in the order they are listed, so reordering that path can quietly change which program actually runs.

    The Bourne shell and its relatives, including Bash, can run in a restricted mode that blocks a user from modifying the PATH variable at all. If PATH in that mode is set to include only directories holding permissible commands, the user can run nothing else. Windows' CMD.EXE offers a similar way to restrict which commands are available. Some shareware programs go further still, limiting the commands a user can reach. One printed a blunt refusal straight from the prompt: your administrator has disabled running batch files.

    Some CLIs, particularly on network routers, organize commands into a hierarchy of modes, with a different set of commands available inside each one. A router with separate interface and system modes offers one example. Typing the command interface unlocks its interface-specific commands, but commands from the system mode stay locked out until the user exits and switches modes. IBM's MVS operating systems take a related approach through the Authorised Program Facility, or APF. It lets certain authorized programs run with elevated privileges, comparable to UID zero on Unix-like systems. Under TSO/E, some commands can only be called by other authorized commands, programs, and services listed on an installation's own controlled list. That same instinct, deciding exactly who gets to type what, shows up again inside individual applications, far from any operating system at all.

  • An application program can offer up to three kinds of command-line interface. The first passes parameters in at launch. The second opens an interactive session for typing commands once the program has started. The third lets other running processes communicate with it through channels such as standard streams or named pipes. MATLAB, a numerical analysis program, makes every one of its features available through its CLI. Its graphical interface, by contrast, exposes only a subset of what the program can do.

    Emacs offers its own command-line interface through something called the minibuffer. Commands and arguments are typed there using Emacs's standard text-editing tools, with the output appearing in a separate buffer. A number of text-based games relied on the same principle, including Adventure and King's Quest 1-3. A player controls a character by typing commands like 'get ring' or 'look'. The Hitchhiker's Guide to the Galaxy, an interactive fiction title based on Douglas Adams's book, was built as a teletype-style command-line game.

    A web browser's URL bar can double as a command line, used to launch web apps, adjust browser settings, or run a search. Google has been called 'the command line of the internet.' It performs a domain-specific search whenever it detects search parameters in a known format. That works whether the search is typed into a browser field or entered directly on Google's own website. JavaScript libraries let developers build command-line applications that run entirely inside a browser, either standing alone or folded into larger web apps. The CLI interface to DuckDuckGo is one working example. Web-based SSH applications extend the same idea further, letting a user reach a server's command-line interface from inside a browser window.

    Many PC video games include their own command-line interface, usually called a console. Developers rely on it during development, and mod creators use it for debugging their own work. Ordinary players sometimes type into the same console just to cheat or skip past a difficult section. Command-line interfaces like diskpart and QBASIC still ship inside operating systems today, quietly waiting for anyone willing to type the first word.

Common questions

What is a command-line interface used for?

A command-line interface lets a person control software by typing commands formatted as lines of text instead of using icons or menus. It is common in operating systems, programming language environments, and many applications. It is especially popular among programmers, system administrators, and people with visual disabilities who use refreshable Braille displays.

When was the first command-line interpreter created?

The first true command-line interpreter appeared with the Compatible Time-Sharing System, or CTSS, developed at MIT in 1961. It let a user type a command such as LOGIN or PRINT for a program called the supervisor to parse and execute.

Who coined the term shell for a command-line interpreter?

Louis Pouzin coined the term shell in 1964 while working at the MIT Computation Center on the Multics operating system. He built a tool called RUNCOM for running command scripts with argument substitution. He then returned to France in 1965, after which Glenda Schroeder completed the first Multics shell.

Why did graphical user interfaces replace the command-line interface?

Graphical user interfaces largely replaced the command-line interface because they let users act through icons and drop-down menus instead of memorizing commands. The shift began with the PARC approach used in the 1983 Apple Lisa and 1984 Apple Macintosh. Most IBM PC users, though, did not give up their COMMAND.COM shell until Windows 95 arrived in 1995.

What is the difference between internal and external commands in a command-line interface?

Internal commands, also called built-in commands, are recognized and processed directly by the command-line interpreter. External commands run separate executable files that the interpreter searches for by matching names.

How do you customize the prompt in a command-line interface?

In Bash and other Unix shells, the prompt is controlled through a variable called $PS1, and zsh adds a right-side prompt with $RPROMPT. In DOS and Windows, a user can change the prompt with the PROMPT command or by editing the %PROMPT% environment variable. Typing PROMPT $P$G produces the standard C:\> style.

All sources

55 references cited across the entry

  1. 7BookMac OS X Internals: A Systems ApproachAmit Singh — Addison-Wesley Professional — 2006-06-19
  2. 11pathJasonGerend — 2023-02-03
  3. 13BookLearning the bash ShellO'Reilly Media — January 1998
  4. 14Windows Terminal command line argumentsnguyen-dows — 2024-05-29
  5. 19The Command Line GUIde: Graphical Interfaces from Man Pages via AISaketh Ram Kasibatla et al. — University of California San Diego — 2025-10-01
  6. 20openharmony/third_party_toyboxOpenHarmony — 2021-10-14
  7. 27MULTICS - The First Seven YearsStanford Computer Science Department — Fall 2004
  8. 28Evolution of shells in LinuxIBM — 2011-12-06
  9. 32BookRISC OS 3 User GuideAcorn Computers Limited — 1992-03-01
  10. 34Command shell overviewMicrosoft — 2005-01-21
  11. 35Command-Line Syntax KeyMicrosoft — 2010-01-25
  12. 36BookThe UNIX Programming EnvironmentPrentice-Hall — 1984
  13. 47Book4DOS 8.00 online help2002-02-27
  14. 50BookFreeKEYB - Advanced international DOS keyboard and console driver2006-01-16
  15. 53BookCCI Multiuser DOS 7.22 GOLD Online DocumentationConcurrent Controls, Inc. (CCI) — 1997-02-10
  16. 54fd-dev mkeyb2002-05-13
  17. 55BookSID Users GuideDigital Research — 1978
  18. 56BookSID-86 User's Guide for CP/M-86Digital Research — August 1982