1.2 Syntax of UNIX Command LinesUNIX command lines can be simple, one-word entries like the date command. They can also be more complex: you may need to type more than the command name. A UNIX command may or may not have arguments . An argument can be an option or a filename. The general format for UNIX commands is:
There isn't a single set of rules for writing UNIX commands and arguments, but you can use these general rules in most cases:
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. Let's look at a sample UNIX command. The ls command displays a list of files. It can be used with or without options and arguments. If you enter: % 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: % 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: % 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." 1.2.1 Exercise: Entering a few commandsThe 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.
|
|