LPI Linux Certification in a Nutshell
--all :
$ ls -l --all
    These double-dash, full-word options are frequently found in
     programs from the GNU project. They cannot be combined like the
     single-dash options can. Both types of options can be freely
     intermixed. Although the longer GNU-style options require more typing,
     they are easier to remember and easier to read in scripts than the
     single-letter options.
    Adding an argument further refines the
     command’s behavior:
$ ls -l *.c
    Now the command will give a detailed listing only of C program
     source files, if any exist in the current working directory.
    Note
    Using the asterisk in *.c allows any file
     to match as long as it ends with a .c extension. This is known as file globbing . More
     information on file globbing and using wildcards can be found later
     in this chapter.
    Sometimes, options and arguments can be mixed in any
     order:
$ ls --all *.c -l
    In this case, ls was able to determine that -l is an option and not another file descriptor .
    Some commands, such as tar and ps , don’t require the dash
     preceding an option because at least one option is expected or
     required. To be specific, ps doesn’t require a
     dash when it is working like BSD’s version of ps .
     Since the Linux version of ps is designed to be
     as compatible as possible with various other versions of ps , it sometimes does need a dash to distinguish
     between conflicting options. As an example, try ps
     -e and ps e . The first version invokes
     a Linux-specific option that shows everyone’s processes, not just your
     own. The second version invokes the original BSD option that shows the
     environment variables available to each of your commands.
    Also, an option often instructs the command that the subsequent
     item on the command line is a specific argument. For example:
$ sort name_list $ sort –k 2 name_list
    These commands invoke the sort command to sort the lines in
     the file
name_list
. The first
     command just sorts beginning with the first character of each line,
     whereas the second version adds the options
-k 2
. The
-k
option tells the command to break each
     line into fields (based on whitespace) and to sort the lines on a
     particular field. This option requires a following option to indicate
     which field to sort on. In this case, we have told sort to sort on the second field, which is useful
     if
name_list
contains people’s
     names in a “Joe Smith” format.
    Just as any natural language contains exceptions and variations,
     so does the syntax used for GNU and Unix commands. You should have no
     trouble learning the essential syntax for the commands you need to use often. The capabilities of the
     command set offered on Linux are extensive, making it highly unlikely
     that you’ll memorize all of the command syntax you’ll ever need. Most
     system administrators are constantly learning about features they’ve
     never used in commands they use regularly. It is standard practice to
     regularly refer to the documentation on commands you’re using, so feel
     free to explore and learn as you go.
    Entering commands not in the PATH
    Occasionally, you will need to execute a command that is not in
     your path and not built into your shell. If this need arises often, it
     may be best to simply add the directory that contains the command to
     your path. However, there’s nothing wrong with explicitly specifying a
     command’s location and name completely. For example, the ls command is located in /bin . This directory is most certainly in your
PATH
vari able (if not, it should be!), which
     allows you to enter the ls command by itself on
     the command line:
$ ls
    The shell looks for an executable file named ls in each successive directory listed in your
PATH
variable and will execute the
     first one it finds. Specifying the literal pathname for the command
     eliminates the directory search and yields identical results:
$ /bin/ls
    Any executable file on your system may be started in this way.
     However,

Similar Books

B000FC0U8A EBOK

Anthony Doerr

Lair of the Lion

authors_sort

Shimmer: A Novel

John Passarella

The Stolen Bride

Brenda Joyce

Finding Her Son

Robin Perini