View the Most Wanted LQ Wiki articles.
LinuxQuestions.org > Linux Wiki > Command

From LQWiki

Jump to: navigation, search

A command, in the most general sense, is an executable file or a shell builtin. For example, cd, ls, echo and mozilla are commands.

Specifically for this section of the LQ Wiki, "commands" mean command line tools (or occasionally ncurses or other console utilities), rather than GUI tools which are covered in the Applications section.

The commands are presented by two means of organization: an alphabetical list of All commands to enable quick access to a known command, and a group of categorical topics to enable quick access to the appropriate command for a particular purpose or area of interest.

Additionally, there is a general usage section and sections on learning more.

The list is extensive, but probably always incomplete, and always growing. Additions are needed, with the caution that they shouldn't be simple copies-and-pastes of the man pages. These are intended to be more tutorial, howto, and 'real world usage' oriented, and not intended to assume the extensive knowledge of UNIX and Linux which man pages frequently presuppose.

Note: details of commands vary from version to version and available commands vary from distribution to distribution.


Alphabetical list of commands

Categorical lists of commands



General notes on commands

Commands may be invoked as simple commands. In these examples, the $ that starts each line is a shell prompt and not meant to be typed

$ ls

Or they may be invoked as complex commands.

$ ls -l /bin

Here "-l /bin" are a pair of arguments (separated from each other and the command by whitespace) and "-l" is specifically an option, since it modifies the behavior of ls (it produces a long listing), while "/bin" simply specifies a target for ls to act on.

They may also be invoked in multiples where the semi-colon is a command separator.

$ cd /bin; ls

That's two commands on one line. You may also execute one long command on two lines by escaping the carriage return with a backslash. (See scripting for further details on metacharacters and escaping and quoting.)

$ cd really long command line \
that we would like to finish here

Another way to invoke multiple commands is conditionally, where (in bash) "&&" means to execute the second command only if the first returns with an exit code of 0 (i.e., it succeeds).

$ cd /bin && ls

With the semicolon command separator, had the change of directory failed, ls would still have been invoked and simply listed the contents of the current directory. With the conditional operator, ls would not be invoked if cd had failed.

Similarly, "||" means to execute the second command only if the first returns a non-zero exit code (i.e., it fails).

$ cd /bing 2>/dev/null || echo 'I kinna do it, Cap'\''n!'

This will cd to the directory named "bing" if it in fact exists and the command will exit. Since it probably doesn't, being a typo, the second command will execute and print a somewhat more entertaining error message than is usual.

Learning about commands with local documentation

A Linux system should have documentation in the form of man pages and possibly GNU info pages (see also texinfo). In a manner similar to this page's alphabetical list, if you know the command you wish to learn more about,

$ man command

will show you the manual page of command.

If you do not know the command but would like to see commands relevant to a topic, use

$ apropos subject

or

$ man -k subject

to find suitable commands.

Unfortunately, while most man pages will be informative and complete, many GNU utilities distribute very sketchy man pages whose primary purpose is to redirect the user to the info system. In that case,

$ info command

will invoke that system of documentation.

Many commands have an "-h", "-H", "-help", "--help" option or some combination thereof. Unfortunately, some commands understand other things by "-h" or "-H" so unexpected and possibly unpleasant results may occur.

There are also extensive miscellaneous files usually found in /usr/doc, /usr/local/doc, /usr/src/linux/Documentation (kernel docs), and elsewhere.

External links


Personal tools