Tuesday, December 22, 2009

Lesson05:Finding Help

Getting Help

Don’t try to memorize everything. Instead, learn to use the resources at your disposal. You have many levels of help available:
• The whatis command
• The man command
• The info command
• The --help command option (for command-specific help)
• The /usr/share/doc directory
• Red Hat documentation
The command-line interface has many advantages, but also has a disadvantage. The disadvantage is the sheer number of commands and arguments that the user must take advantage of to use it well. A common mistake by people new to the command-line is to assume they have to commit every little argument to memory.
To be proficient, you don’t need to become a walking database of Linux arcana (though that does tend to come with time). In fact, although committing regularly used commands and arguments to memory is always helpful, the key to effectively using a command-line operating system is the ability to use the available resources to quickly look up arguments and techniques that you do not know by heart. The following slides will discuss several such resources.


The whatis Command

The whatis command has the following functionality:
• Displays short descriptions of commands
• Uses a database that is updated nightly
• Often is not available immediately after install
In day-to-day usage of Red Hat Enterprise Linux, you will periodically encounter a command that looks interesting but whose function is unknown to you. One way to find out what a command does is to run it, but this can be risky. The whatis command provides an easier and safer way of getting a quick explanation of what another command’s function is.
The usage of the whatis command is as follows:
whatis command
For example:


==================


The whatis command accepts the name of another command as its only argument and then searches for the given command name in a database of short descriptions. If it finds a match, the description is printed to your screen. Along with the description, whatis prints the command’s name and a number in parenthesis. This number represents the "chapter" of the Linux Manual where more thorough documentation can be found. Later screens will explain the Linux Manual and the associated man command in more detail.


The --help Option


==========================

In order to use a command effectively, not only do you need to know what a command does, you also need to know what options and arguments the command accepts and what order it expects them in (the syntax of the command).
One good way to determine the syntax or usage of a command is by using the --help command option.
Syntax for the --help option is as follows:
command --help
Most commands have a --help option. The --help option displays a usage summary and a listing of the available arguments. It works with most, but not all, commands.
At first glance, usage statements may seem complicated and difficult to read. However, they become much simpler to understand once you are familiar with a few basic conventions:
• Anything in braces ([]) is optional
• Anything followed by an ellipsis (...) represents an arbitrary-length list of that thing
• Multiple options separated by pipes () means that you can use any one of them
• Text in angle brackets (<>) represents variable data. So means “insert the file name you wish to use here.” Sometimes, as in the example in the slide, such variables are simply just written in uppercase.
So, look at the first usage statement for the date command:
date [OPTION]... [+FORMAT]
You see that date can take an optional list of options ([OPTION]...) followed by an optional format string prefixed with a plus sign, which defines what you want the date to look like ([+FORMAT]). Since both of these are optional, date will work even if it is not given options or arguments (it will print the current date and time using its default format).


Reading Usage Summaries


Reading Usage Summaries
Usage summaries are printed by the --help, man, and other commands and are used to describe the syntax of a command.

[] Arguments in braces ([]) are optional
<> or CAPS Arguments in angle brackets (<>) or uppercase are variables
…Text followed by an ellipsis (…) represents a list
xyz Means x,y or z
-abc Means any mix of –a , -b , or –c


The man Command
Just about every command, most configuration files, and several developers’ libraries on a Red Hat Enterprise Linux system has an associated man page. The man page provides more thorough documentation than the --help option does.
To access the man page for a command, use the following syntax:
man [section/chapter] command
For example:
man ls
Manual pages normally contain sections discussing aspects of a command’s usage.
These sections include:
• The NAME of the command and a short description of what it does
• A SYNOPSIS of its usage, including available switches
• A longer DESCRIPTION of the command’s functionality
• A switch-by-switch listing of its OPTIONS
• Any FILES associated with the command
• Any known BUGS in the command
• EXAMPLES, showing how to use the command
• A SEE ALSO section for further reference
All man pages on a system are collectively called the Linux Manual. The Linux Manual is also divided into sections, each of which covers a particular topic. Every man page is associated with one of these sections.

1 comments:

Anand at July 21, 2011 at 10:04 AM said...

material is good.... but y only 5 chapters?

 
Home | About | Link | Link
Simple Proff Blogger Template Created By Herro | Inspiring By Busy Bee Woo Themes