In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes, and development of both hardware and software. Computing has scientific, ...
, a command is a directive to a computer program to perform a specific task. It may be issued via a
command-line interface, such as a
shell
Shell may refer to:
Architecture and design
* Shell (structure), a thin structure
** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses
** Thin-shell structure
Science Biology
* Seashell, a hard o ...
, or as input to a network service as part of a
network protocol
A communication protocol is a system of rules that allows two or more entities of a communications system to transmit information via any kind of variation of a physical quantity. The protocol defines the rules, syntax, semantics and synchroni ...
, or as an event in a
graphical user interface
The GUI ( "UI" by itself is still usually pronounced . or ), graphical user interface, is a form of user interface that allows User (computing), users to Human–computer interaction, interact with electronic devices through graphical icon (comp ...
triggered by the user selecting an option in a
menu
In a restaurant, the menu is a list of food and beverages offered to customers and the prices. A menu may be à la carte – which presents a list of options from which customers choose – or table d'hôte, in which case a pre-established seque ...
.
Specifically, the term ''command'' is used in
imperative computer language
A computer language is a formal language used to communicate with a computer. Types of computer languages include:
* Construction language – all forms of communication by which a human can specify an executable problem solution to a compu ...
s. The name arises because
statements
Statement or statements may refer to: Common uses
* Statement (computer science), the smallest standalone element of an imperative programming language
*Statement (logic), declarative sentence that is either true or false
*Statement, a declarativ ...
in these languages are usually written in a manner similar to the
imperative mood
The imperative mood is a grammatical mood that forms a command or request.
The imperative mood is used to demand or require that an action be performed. It is usually found only in the present tense, second person. To form the imperative mood, ...
used in many
natural language
In neuropsychology, linguistics, and philosophy of language, a natural language or ordinary language is any language that has evolved naturally in humans through use and repetition without conscious planning or premeditation. Natural languag ...
s. If one views a statement in an
imperative language
In computer science, imperative programming is a programming paradigm of software that uses statements that change a program's state. In much the same way that the imperative mood in natural languages expresses commands, an imperative program co ...
as being like a sentence in a natural language, then a command is generally like a verb in such a language.
Many programs allow specially formatted arguments, known as flags or options, which modify the default behaviour of the program, while further
arguments
An argument is a statement or group of statements called premises intended to determine the degree of truth or acceptability of another statement called conclusion. Arguments can be studied from three main perspectives: the logical, the dialectic ...
may provide objects, such as files, to act on. As an analogy to a natural language, the flags are adverbs, while the other arguments are
object
Object may refer to:
General meanings
* Object (philosophy), a thing, being, or concept
** Object (abstract), an object which does not exist at any particular time or place
** Physical object, an identifiable collection of matter
* Goal, an ai ...
s.
Examples
Here are some commands given to a
command-line interpreter
A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive command (computing), commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invokin ...
(
Unix shell
A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating system t ...
).
The following command changes the user's working position in the
directory tree
In computing, a directory is a file system cataloging structure which contains references to other computer files, and possibly other directories. On many computers, directories are known as folders, or drawers, analogous to a workbench or the tr ...
to the directory ''/home/pete''. The utility program is ''
cd'' and the argument is ''/home/pete'':
cd /home/pete
The following command prints the text ''Hello World'' on the
standard output
In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin ...
stream, which, in this case, just prints the text on the screen. The program name is
echo
In audio signal processing and acoustics, an echo is a reflection of sound that arrives at the listener with a delay after the direct sound. The delay is directly proportional to the distance of the reflecting surface from the source and the li ...
and the argument is "Hello World". The quotes are used to prevent ''Hello'' and ''World'' being treated as separate tokens:
echo "Hello World"
The following commands are equivalent. They list files in the directory ''/bin''. The program is ''
ls'', having three flags (''l'', ''t'', ''r''), and the argument is the directory ''
/bin'':
ls -l -t -r /bin
ls -ltr /bin
The following command displays the contents of the files ''ch1.txt'' and ''ch2.txt''. The program name is ''
cat
The cat (''Felis catus'') is a domestic species of small carnivorous mammal. It is the only domesticated species in the family Felidae and is commonly referred to as the domestic cat or house cat to distinguish it from the wild members of ...
'', having two file name arguments:
cat ch1.txt ch2.txt
Here are some commands for the
DOS
DOS is shorthand for the MS-DOS and IBM PC DOS family of operating systems.
DOS may also refer to:
Computing
* Data over signalling (DoS), multiplexing data onto a signalling channel
* Denial-of-service attack (DoS), an attack on a communicat ...
,
OS/2
OS/2 (Operating System/2) is a series of computer operating systems, initially created by Microsoft and IBM under the leadership of IBM software designer Ed Iacobucci. As a result of a feud between the two companies over how to position OS/2 ...
and
Microsoft Windows command prompt
Command Prompt, also known as cmd.exe or cmd, is the default command-line interpreter for the OS/2, eComStation, ArcaOS, Microsoft Windows ( Windows NT family and Windows CE family), and ReactOS operating systems. On Windows CE .NET 4.2, Wi ...
processor. The following command displays the contents of the file ''readme.txt''. The program name is ''
type
Type may refer to:
Science and technology Computing
* Typing, producing text via a keyboard, typewriter, etc.
* Data type, collection of values used for computations.
* File type
* TYPE (DOS command), a command to display contents of a file.
* Ty ...
'' and the argument is ''readme.txt''.
type readme.txt
The following command lists the contents of the current directory. The program name is ''
dir'', and ''Q'' is a flag requesting that the owner of each file also be listed.
dir /Q
See also
*
Gesture recognition
Gesture recognition is a topic in computer science and language technology with the goal of interpreting human gestures via mathematical algorithms. It is a subdiscipline of computer vision. Gestures can originate from any bodily motion or sta ...
*
List of Unix commands
This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems.
List
See also
* List of G ...
*
List of DOS commands
This article presents a list of commands used by DOS operating systems, especially as used on x86-based IBM PC compatibles (PCs). Other DOS operating systems are not part of the scope of this list.
In DOS, many standard system commands were p ...
*
Formal grammar
In formal language theory, a grammar (when the context is not given, often called a formal grammar for clarity) describes how to form strings from a language's alphabet that are valid according to the language's syntax. A grammar does not describe ...
References
External links
commandfrom
FOLDOC
The Free On-line Dictionary of Computing (FOLDOC) is an online, searchable, encyclopedic dictionary of computing subjects.
History
FOLDOC was founded in 1985 by Denis Howe and was hosted by Imperial College London. In May 2015, the site was ...
Windows Commands , Microsoft Docs
{{Windows commands
User interfaces
Computing terminology