As I mentioned in the section on introduction to operating systems, the shell
is essentially a user’s interface to the
For many
years before the invention of graphical user interfaces, such as X-Windows (the
X Windowing System, for purists), the only way to input commands to the
operating system was through a
Most shells, be they under
Some commands need something else to get them to work: an
argument. Some commands, like
In many cases,
you can pass flags to commands to change their behavior. These flags are
generally referred to as options. For example, if you wanted to create
a series of sub-directories without creating every one individually, you could
run
In principle, anything added to the
Here we have a single argument which is the name of the directory to be created. Next, we add an option:
The
Generally, options are preceded by a dash (-), whereas arguments are not. I’ve
said it before and I will say it again, nothing is certain when it comes to
Linux or
Each program or utility has its own set of arguments and options,
so you will have to look at the man-pages for the individual commands. You can
call these up from the
where <command_name> is the name of the
command you want information about. Also, if you are not sure what the command
is, many Linux versions have the whatis command that will give you a brief
description. There is also the
Arguments (whether they are options or operands) which are enclosed in square brackets ([ ]) are optional. In some cases, there are optional components to the optional arguments, so you may end up having brackets within brackets.
An ellipsis (…) Indicates that the preceding arguments can be repeated. For example, the ls command can take multiple file or directory names as arguments as well as multiple options. Therefore, you might have a usage message that looks like this:
This tells us that no options are required, but if you wanted you could use multiple options. It also tells us that no file name is required, but if you wanted you could use multiple ones.
Words that appeared in angle brackets (< >) or possibly in italics in the printed form, indicate that the word is a place holder. Like in the example below:
Many commands require that an
option appear immediately after the command and before any arguments. Others
have options and arguments interspersed. Again, look at the
Often, you just need a quick reminder
as to what the available options are and what their syntax is. Rather than going
through the hassle of calling up the
To make things easier, the letter used for a particular option is often related to the function it
serves. For example, the
To make things easier, when using the short options, multiple options can either be placed separately, each preceded by a dash, or combined. For example, both of these commands are valid and have the exact same effect:
In both cases you get a long listing (
Newer versions of commands typically allow for both single letter options and
“long options” which use full words. For
example, the long equivalent of
Note that saying “newer” might be somewhat confusing. As of this writing (Dec 2006), I cannot think of any current distribution which has no commands that support long options. Therefore it would probably better to say, that with older distribution you may find that long options are not supported.
Although it doesn’t happen too often, you might end up with a situation where one of the
arguments to your command starts with a dash (-), for example a file name. This “normally”
doesn’t happen, but you can run into problems if it does. Since options
typically start with a dash, the shell cannot figure out that it is an argument and not
a long line of options. Let’s assume that some application created a file
named “
However, since the shell first tries to figure out what options are being used before it shows you the listing, it thinks that these are all options and gives you the error message:
You can solve this problem with some commands by using two dashes to tell the command that what follows is actually an argument. So to get the listing in the previous example, the command might look like this:
A frequently overlook aspect of working with the shell are resource limitations, which can prevent problems for improperly implemented programs.
One example, is the maximim number of files that a shell can have open at one time. This usually defaults to 1024, which can seem like a lot, but I have
run across applications were where even this was too few. To see the currently set values, simply run
One important aspect is that each of these values has both a