command option(s) filename(s)
There isn't a single set of rules for writing UNIX commands and arguments, but you can use these general rules in most cases:
Enter commands in lowercase.
Options modify the way in which a command works. Options are often single letters prefixed with a dash (-) and set off by any number of spaces or tabs. Multiple options in one command line can be set off individually (like -a -b), or, in some cases, you can combine them after a single dash (like -ab).
Some commands, including those on Linux systems, also have options made from complete words or phrases, like --delete or --confirm-delete. When you enter a command, you can use this option style, the single-letter options (which all start with a single dash), or both.
The argument filename is the name of a file that you want to use. If you don't enter a filename correctly, you may get the response "filename: no such file or directory" or "filename: cannot open."
Some commands, like telnet and who (shown earlier in this chapter), have arguments that aren't filenames.
You must type spaces between commands, options, and filenames.
Options come before filenames.
UNIX has a lot of commands! Don't try to memorize all of them. In fact, you'll probably need to know just a few commands and their options. As time goes on, you'll learn these commands and the best way to use them for your job. We cover some useful UNIX commands in later chapters.
a list of filenames will be displayed on the screen. But if you enter:
there will be an entire line of information for each file. The -l option (a dash and a lowercase letter "l") modifies the normal output of the ls command and lists files in the long format. You can also get information about a particular file by using its name as the second argument. For example, to find out about a file called chap1, enter:
ls -l chap1
Many UNIX commands have more than one option. For instance, ls has the -a (all) option for listing hidden files. You can use multiple options in either of these ways:
ls -a -l%
You must type one space between the command name and the dash that introduces the options. If you enter ls-al, the shell will say "ls-al: command not found."
The best way to get used to UNIX is to enter some commands. To run a command, type in the command and then press the [RETURN] key. Remember that almost all UNIX commands are typed in lowercase.
|Get today's date.||Enter |
|List logged-in users.||Enter |
|Obtain more information about users.|
|Find out who is at your terminal.||Enter |
|Enter two commands in the same line.||Enter |
|Mistype a command.||Enter |