Jump to bottom
This guideline is a part of the English Wikipedia's Manual of Style. Use common sense in applying it; it will have occasional exceptions. Please ensure that any edits to this page reflect consensus. Shortcut:
WP:MOSCOMM

Command-line examples are used to specify the syntax of shell commands or programs as a user would type them into a terminal or command prompt on a computer. This page is intended to function as a style guide for writers and editors of articles related to computer science on Wikipedia.

General guidelines

When providing command-line examples, it is necessary to maintain clarity and simplicity. Not only does this result in a more professional look, but it prevents the reader from becoming confused. The following guidelines are given to help establish what defines clear and simple examples.

(prompt) command parameter-name
(prompt) command parameterName
(prompt) command parameter_name
(prompt) command parametername
(prompt) command parameter0 [.. parameterN]
(prompt) command [parameter ...]

Platform-specific guidelines

DOS, Microsoft Windows, and OS/2

The most common operating system in use today is Microsoft Windows, whose command-line syntax is based on that of MS-DOS. As such, examples that might be specific to MS-DOS or Windows do not need to indicate this. However, if the examples are specific to a certain version of the operating system, then they should be indicated as such. If equivalents in other DOSes differ and are known, they should be provided.

The following additional guidelines should be followed for DOS command-line examples:

Unix-like systems

Providing sample output

It may often be prudent to provide a sample of the output that a command is expected to generate. In these cases, the full command and all arguments as they were typed are given. The output of the command will therefore be specific to environment and other variables. The tags <pre><nowiki> (in that order) will insure the proper formatting of the output.

Examples of usage

DOS

> DIR [options] [pattern ...]
> MOVE.EXE source target

General Unix

$ ls [options] [file ...]
# mkfs [-t fstype] [fs-options] device
$ wget [options] "URI"

Shell-specific

$ if command ; then command ; ... ; fi

and csh/tcsh:

% if (expression) then command ; ... ; endif

Sample output

$ df -P
Filesystem          512-blocks      Used Available Capacity Mounted on
/dev/hda2             39331760   7398904  29834768      20% /