Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Command (computing)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|External instruction to a computer program}} {{redirect distinguish|System command|system call}} {{other uses|Command (disambiguation)#Computing{{!}}Command Β§ Computing}} {{refimprove|date=May 2008 }} In [[computing]], a '''command''' is an instruction received via an external [[Interface (computing)|interface]] that directs the behavior of a [[computer program]]. Commonly, commands are sent to a program via a [[command-line interface]], a [[scripting language|script]], a [[network protocol]], or as an event triggered in a [[graphical user interface]]. Many commands support arguments to specify input and to modify default behavior. Terminology and syntax varies but there are notable common approaches. Typically, an '''option''' or a '''flag''' is a name (without [[Whitespace character|whitespace]]) with a prefix such as [[dash]] or [[Slash (punctuation)|slash]] that modifies default behavior. An option might have a required value that follows it. Typically, flag refers to an option that does not have a following value. A '''parameter''' is an argument that specifies input to the command and its meaning is based on its position in the command line relative to other parameters; generally ignoring options. A parameter can specify anything, but often it specifies a [[file (computing)|file]] by [[filename|name]] or [[file path|path]]. The term ''command'' is sometimes also used for internal program instructions, but often other terms are more appropriate such as [[statement (programming)|statement]], [[Expression (computer science)|expression]], [[Function (computer programming)|function]], or [[Conditional (computer programming)|conditional]].<ref>Maurizio Gabbrielli, Simone Martini (2010). Programming Languages - Principles and Paradigms. Springer London, ''6.3.2 Conditional Commands'', p. 140</ref> For example, printing a message in Bash is via the ''command'' [[Printf (Unix)|printf]], while in Python it is via the ''function'' print().<ref>{{cite web | url = https://docs.python.org/3/library/functions.html#print | access-date = 23 October 2023 | title = Built-in Functions - print | publisher = python.org }}</ref> Further, some aspects of adjacent technology are conflated with commands. For example, conditional logic in Bash and Python is called an ''expression''<ref>{{cite web | url = https://docs.python.org/3/reference/expressions.html | access-date = 23 October 2023 | title = Conditional expressions | publisher = python.org }}</ref><ref>{{cite web | url = https://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html | access-date = 23 October 2023 | title = Bash Conditional expressions | publisher = gnu.org }}</ref> and ''statements'' in Java.<ref>{{cite web | url = https://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html | access-date = 23 October 2023 | title = The if-then and if-then-else Statements | publisher = oracle.com }}</ref> ==Examples== A notable context in which commands are prevalent is the [[operating system]] [[shell (computing)|shell]]. Commonly, the shell dispatches a command to a program that has a file name matching the first parameter. In a [[Unix shell]] (such as [[Bash (Unix shell)|bash]] and many related variants), the match must be exact including case. The following bash command changes the [[working directory]] to ''/home/pete'' by invoking the program ''[[Cd (command)|cd]]'': <syntaxhighlight lang="bash"> cd /home/pete </syntaxhighlight> The following bash command writes "Hello World" via program [[Echo (command)|echo]] to [[standard output]] {{endash}} typically the [[computer terminal|terminal]]. Quotes around the two words indicate that the phrase is treated as a single parameter. <syntaxhighlight lang="bash"> echo "Hello World" </syntaxhighlight> The following demonstrates how the default behavior of a command is modified with a switch. The switch {{code|-e}} causes the command to treat characters prefixed with a backslash as the associated control character. In this case {{code|\t}} results in a tab character. <syntaxhighlight lang="bash"> echo -e "Hello\tWorld" </syntaxhighlight> In shells such as [[Cmd.exe|command prompt]], [[DOS]], and [[OS/2]] some commands are built-in; are not implemented as a separate program. But, if a command is not built-in, then the shell dispatches to a program that has an executable extension (such as ''.exe'') and base name matching the first parameter ignoring case. The following command prompt command displays the content of file ''readme.txt'' via the built-in command ''[[TYPE (DOS command)|type]]''.<ref>{{cite web | url = https://ss64.com/nt/type.html | access-date = 14 March 2019 | title = Type - Display a text file - Windows CMD | publisher = SS64.com }}</ref> <syntaxhighlight lang="batch"> type readme.txt </syntaxhighlight> The following command prompt command lists the contents of the current directory via built-in command ''[[Dir (command)|dir]]''. The switch ''/Q'' modifies default behavior to include owner information.<ref>{{cite web | url = https://ss64.com/nt/dir.html | access-date = 14 March 2019 | title = DIR - list files and folders - Windows CMD | publisher = SS64.com }}</ref> <syntaxhighlight lang="batch"> dir /Q </syntaxhighlight> == See also == * [[Formal grammar]] * [[Gesture recognition]] * [[List of POSIX commands]] * [[List of DOS commands]] == References == {{Reflist}} == External links == {{Wikibooks|Guide to Windows commands}} *[http://foldoc.org/command command] from [[FOLDOC]] *[https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands Windows Commands | Microsoft Docs] {{Unix commands}} {{Windows commands}} [[Category:User interfaces]] [[Category:Computing terminology]] [[Category:Computing commands| ]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite web
(
edit
)
Template:Code
(
edit
)
Template:Endash
(
edit
)
Template:Other uses
(
edit
)
Template:Redirect distinguish
(
edit
)
Template:Refimprove
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Sister project
(
edit
)
Template:Unix commands
(
edit
)
Template:Wikibooks
(
edit
)
Template:Windows commands
(
edit
)