Personal tools
You are here: Home Documentation Unix Basics The Structure of a UNIX Command

The Structure of a UNIX Command


The general structure of a UNIX command is

cmd [options] [parameters]

cmd is the command name (case sensitive, like everything in UNIX, that means cmd and Cmd are regarded as being different). Options consist of single letters and are introduced by a '-', like

ls -l

The ls command lists the files in the current directory. The option -l tells ls to use a long format. If you want to specify several options (let's say a, b and c) you may use

cmd -a -b -c

or

cmd -abc

Caution: Some (ancient) commands insist on only one of the forms above; you'll learn that from the appropriate man-page. In some cases even the '-' may (or must) be dropped.

Most commands allow or require parameters, e.g.

cp file1 file2

will copy file1 to file2.

Finally, some options (if you specify them) require an 'option-parameter'. If, for example, you want to print the file file1 at the printer 'xy', use

lpr -Pxy file1

In this case there must be no space between the option 'P' and the option-parameter xy. For other commands a space may be required. Consult the man-page.

A hint: Many commands understand the -h option and show you a brief 'usage' text.

 

Next :  Filesystem

Document Actions