Katana VentraIP

Command-line interface

A command-line interface (CLI) is a means of interacting with a computer program by inputting lines of text called command-lines. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user-friendly alternative to the non-interactive interface available with punched cards.

Today, most computer users rely on graphical user interfaces ("GUIs") instead of CLIs. However, many programs and operating system utilities lack GUIs, and are intended to be used through CLIs.


Knowledge of CLIs is also useful for writing scripts. Programs that have CLIs are generally easy to automate via scripting, since command-lines, being mere lines of text, are easy to specify in code.


CLIs are made possible by command-line interpreters or command-line processors, which are programs that read command-lines and carry out the commands.


Alternatives to CLIs include GUIs (most notably desktop metaphors with a mouse pointer, such as Microsoft Windows), text-based user interface menus (such as DOS Shell and IBM AIX SMIT), and keyboard shortcuts.

Parameters: Most command-line interfaces support a means to pass additional information to a program when it is launched.

Interactive command-line sessions: After launch, a program may provide an operator with an independent means to enter commands.

Inter-process communication: Most operating systems support means of (for example, standard streams or named pipes). Command lines from client processes may be redirected to a CLI program by one of these methods.

inter-process communication

— generated by the program to provide context for the user.

Prompt

Command — provided by the user. Commands are usually one of three classes:

  1. Internal commands are recognized and processed by the command line interpreter.
  2. Included commands run separate executables.
  3. External commands run executable files that may be included by other parties.

param1 …paramN — parameters provided by the user. The format and meaning of the parameters depends upon the command. In the case of Included or External commands, the values of the parameters are delivered to the program as it is launched by the OS. Parameters may be either or options.

arguments

The default VAX/VMS command shell, using the 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.

DCL

is the command-line interpreter of MS-DOS, IBM PC DOS, and clones such as DR-DOS, SISNE plus, PTS-DOS, ROM-DOS, and FreeDOS.

COMMAND.COM

Windows and Windows Services for UNIX include Korn and the Bourne shells along with a Perl interpreter (Services for UNIX contains ActiveState ActivePerl in later versions and Interix for versions 1 and 2 and a shell compiled by Microsoft)

Resource Kit

IBM OS/2 (and derivatives such as and ArcaOS) has the cmd.exe processor. This copies the COMMAND.COM commands, with extensions to REXX.

eComStation

cmd.exe is part of the stream of operating systems.

Windows NT

Yet another cmd.exe is a stripped-down shell for 3.0.

Windows CE

An MS-DOS type interpreter called 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.

PocketDOS

Windows users might use the interface to alternate programs, from command-line. 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,[31] 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

CScript

Implementations of have a shell for interactive use called php-cli.

PHP

Standard has two interactive shells, Tclsh and Wish, the latter being the GUI version.

Tcl/Tk

Ruby, Lua, XLNT, and other interpreters also have command shells for interactive use.

Python

uses tcsh as its default interactive shell for the superuser, and ash as default scripting shell.

FreeBSD

Many have the Bash implementation of the Unix shell.

Linux distributions

Apple and some Linux distributions use zsh. Previously, macOS used tcsh and Bash.

macOS

(and other embedded Unix-like) devices often use the Ash implementation of the Unix shell, as part of Busybox.

Embedded Linux

uses the mksh shell,[32][33] which replaces a shell derived from ash[34] that was used in older Android versions, supplemented with commands from the separate toolbox[35] binary.

Android

Routers with ,[36] Junos[37] and many others are commonly configured from the command line.

Cisco IOS

The operating system uses the rc shell which is similar in design to the Bourne shell.

Plan 9

Scripting[edit]

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.) They will interpret scripts (variously termed shell scripts or batch files) written in the language that they interpret. 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.


Conversely, scripting programming languages, in particular those with an eval function (such as REXX, Perl, Python, Ruby or Jython), can be used to implement command-line interpreters and filters. For a few operating systems, most notably DOS, such a command interpreter provides a more flexible command-line interface than the one supplied. 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[edit]

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.


Programs like BASIC, diskpart, Edlin, and QBASIC all provide command-line interfaces, some of which use the system shell. 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.


There are a number of text mode games, like Adventure or King's Quest 1-3, which relied on the user typing commands at the bottom of the screen. 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 text adventure The Hitchhiker's Guide to the Galaxy, a piece of interactive fiction based on Douglas Adam's book of the same name, is a teletype-style command-line game.


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, devices are files 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.


Programs like the OS/2 E editor and some other IBM editors, can process command-lines normally meant for the shell, the output being placed directly in the document window.


A web browser's URL input field can be used as a command line. It can be used to "launch" web apps, access browser configuration, as well as perform a search. 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.[38] This functionality is present whether the search is triggered from a browser field or on Google's website.


There are JavaScript libraries that allow to write command line applications in browser as standalone Web apps or as part of bigger application.[39] An example of such a website is the CLI interface to DuckDuckGo.[40] There are also Web-based SSH applications, that allow to give access to server command line interface from a browser.


Many PC video games 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

Console application

Interpreter directive

Read-eval-print loop

Shell script

Run command

Graphical user interface § Comparison to other interfaces

In the Beginning... Was the Command Line

David Hunter, Softalk for the IBM Personal Computer March 1983. Archived at Patersontech.com since 2000.

The Roots of DOS

: Microsoft TechNet Database "Command-Line Reference"

Command-Line Reference