Chapter 5 - Getting Help
Chapter 5 - Getting Help
/usr/share/doc
On most systems, there is a directory where additional documentation is found. This will
often be a place where vendors who create additional (third party) software can store
documentation files. Typical locations include /usr/share/doc and /usr/doc.
Section 5.4.2
info
The info command also provides documentation on operating system commands and
features. The goal of this command is slightly different from man pages: to provide a
documentation resource that provides a logical organizational structure, making reading
documentation easier.
Section 5.3
locate
To find any file or directory, you can use the "locate" command. This command will search a
database of all files and directories that were on the system when the database was
created.
Section 5.5.2
man
To view a man page for a command, execute man command in a terminal window. For
example, the command man cal will display the man page for the cal command
Section 5.2.1
man pages
Man pages are used to describe the features of commands. They will provide you with a
basic description of the purpose of the command, as well as provide details regarding the
options of the command.
Section 5.2
5.1 Introduction
If you ask users what feature of the Linux Operating System they most enjoy, many will answer
"the power provided by the command line environment". This is because there are literally
thousands of commands available with many options, making them powerful tools.
However, with this power comes complexity. Complexity, in turn, can create confusion. As a
result, knowing how to find help while working in Linux is an essential skill for any user. Referring
to help allows you to be reminded of how a command works, as well as being an information
resource when learning new commands.
5.2 man Pages
As previously mentioned, UNIX was the operating system from which the Linux foundation was
built. The developers of UNIX created help documents called man pages (man stands for
manual).
Man pages are used to describe the features of commands. They will provide you with a basic
description of the purpose of the command, as well as provide details regarding the options of
the command.
NAME
cal, ncal -- displays a calendar and the date of Easter
SYNOPSIS
cal [-3hjy] [-A number] [-B number] [[month] year]
cal [-3hj] [-A number] [-B number] -m month [year]
ncal [-3bhjJpwySM] [-A number] [-B number] [-s country_code] [[month]
year]
ncal [-3bhJeoSM] [-A number] [-B number] [year]
ncal [-CN] [-H yyyy-mm-dd] [-d yyyy-mm]
DESCRIPTION
The cal utility displays a simple calendar in traditional format and
ncal offers an alternative layout, more options and the date of
Easter. The new format is a little cramped but it makes a year fit on
a 25x80 terminal. If arguments are not specified, the current month
is displayed.
If you want to view the various movement commands that are available, you can type the letter h
while viewing a man page. This will display a help page:
Note: If you are working on a Linux distribution that uses the more command as a pager,
your output will be different than the example shown here.
MOVING
If your distribution uses the less command, you might be a bit overwhelmed with the large
number of "commands" that are available. The following table provides a summary of the more
useful commands:
Command Function
1G Go to beginning
G Go to end
h Display help
The following table describes some of the more common sections that you will find in man pages:
Section
name Purpose
NAME Provides the name of the command and a very brief description.
SYNOPSI Provides examples of how the command is executed. See below for more
S information.
OPTIONS Lists the options for the command as well as a description of how they are used.
Often this information will be found in the DESCRIPTIONsection and not in a
separate OPTIONS section.
FILES Lists the files that are associated with the command as well as a description of
how they are used. These files may be used to configure the command's more
advanced features. Often this information will be found in the DESCRIPTION
section and not in a separate OPTIONS section.
AUTHOR The name of the person who created the man page and (sometimes) how to
contact the person.
SEE Provides you with an idea of where you can find additional information. This also
ALSO will often include other commands that are related to this command.
SYNOPSIS
cal [-3hjy] [-A number] [-B number] [[[day] month] year]
The square brackets [ ] are used to indicate that this feature is not required to run the
command. For example, [-3hjy]means you can use the options -h, -j, -y, 1 or 3, but none of
al command to function properly.
these options are required for the c
The second set of square brackets in the cal SYNOPSIS ([[[day] month] year])
demonstrates another feature; it means that you can specify a year by itself, but if you specify a
month you must also specify a year. Additionally, if you specify a day then you also need to
specify a month and a year.
Another component of the SYNOPSIS that might cause some confusion can be seen in the
SYNOPSIS of the date command:
SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
In this SYNOPSIS there are two syntaxes for the date command. The first one is used to display
the date on the system while the second is used to set the date.
The ellipses following [OPTION],..., indicate that one or more of the items before it may be
used.
Additionally the [-u|--utc|--universal] notation means that you can either use the -u
option or the --utc option or the --universal option. Typically this means that all three
options really do the same thing, but sometimes this format (use of the | character) is used to
indicate that the options can't be used in combination, like a logical “or".
If the term is not found, or you have reached the end of the matches, then the program will report
Pattern not found (press Return). If a match is found and you want to move to the next
match of the term, press n. To return to a previous match of the term, press N.
Additionally, there are several different types of commands (user commands, system commands,
and administration commands) as well as other features that require documentation, such as
libraries and Kernel components.
As a result, there are thousands of man pages on a typical Linux distribution. To organize all of
these man pages, the pages are categorized by sections, much like each individual man page is
broken into sections.
Consider This:
When you use the man command, it searches each of these sections in order until it finds the first
"match". For example, if you execute the command man cal, the first section (Executable
programs or shell commands) is searched for a man page called cal. If not found, then the
second section is searched. If no man page is found after searching all sections, you will receive
an error message:
For example, there is a command called passwdthat allows you to change your password. There
is also a file called passwdthat stores account information. Both the command and the file have
a man page.
The passwd command is a "user" command, so the command man passwd will display the man
page for the passwdcommand by default:
The -f option to the man command will display man pages that match, or partially match, a
specific name and provide a brief description of each man page:
Note that on most Linux distributions, the whatis command does the same thing as man -f. On
those distributions, both will produce the same output.
For example, what if you knew you wanted a man page that displays how to change your
password, but you didn't remember the exact name? You could run the command man -k
password:
sysadmin@localhost:~$ man -k passwd
chgpasswd (8) - update group passwords in batch mode
chpasswd (8) - update passwords in batch mode
fgetpwent_r (3) - get passwd file entry reentrantly
getpwent_r (3) - get passwd file entry reentrantly
gpasswd (1) - administer /etc/group and /etc/gshadow
pam_localuser (8) - require users to be listed in /etc/passwd
passwd (1) - change user password
passwd (1ssl) - compute password hashes
passwd (5) - the password file
passwd2des (3) - RFS password encryption
update-passwd (8) - safely update /etc/passwd, /etc/shadow and
/etc/group
sysadmin@localhost:~$
When you use this option, you may end up with a large amount of output. The preceding
command, for example, provided over 60 results.
Recall that there are thousands of man pages, so when you search for a keyword, be as specific
as possible. Using a generic word, such as "the" could result in hundreds or even thousands of
results.
Note that on most Linux distributions, the apropos command does the same thing as man -k.
On those distributions, both will produce the same output.
The info command also provides documentation on operating system commands and features.
The goal of this command is slightly different from man pages: to provide a documentation
resource that provides a logical organizational structure, making reading documentation easier.
Within info documents, information is broken down into categories that work much like a table of
contents that you would find in a book. Hyperlinks are provided to pages with information on
individual topics for a specific command or feature. In fact, all of the documentation is merged
into a single "book" in which you can go to the top level of documentation and view the table of
contents representing all of the documentation available.
Another advantage of info over man pages is that the writing style of info documents is typically
more conducive to learning a topic. Consider man pages to be more of a reference resource and
info documents to be more of a learning guide.
The `ls' program lists information about files (of any type, including
directories). Options and file arguments can be intermixed arbitrarily,
as usual.
Notice that the first line provides some information that tells you where you are in the info
documentation. This documentation is broken up into nodes and in the example above you are
currently in the ls invocation node. If you went to the next node (like going to the next
chapter in a book), you would be in the dir invocation node. If you went up one level you
would be in the Directory listing node.
Note that if you want to close the help screen, you type the letter l. This brings you back to your
document and allows you to continue reading. To quit entirely, you type the letter q.
Command Function
[ Go to previous node
] Go to next node
u Go up one level
HOME Go to beginning
END Go to end
h Display help
L Quit help page
If you scroll through the document, you will eventually see the menu for the ls command:
* Menu:
The items under the menu are hyperlinks that can take you to nodes that describe more about
s command. For example, if you placed your cursor on the line "* Sorting the
the l
output::" and pressed the Enter key, you would be taken to a node that describes sorting the
s command:
output of the l
`-c'
`--time=ctime'
`--time=status'
If the long listing format (e.g., `-l', `-o') is being used, print
the status change time (the `ctime' in the inode) instead of the
modification time. When explicitly sorting by time (`--sort=time'
or `-t') or when not using a long listing format, sort according
to the status change time.
`-f'
Primarily, like `-U'--do not sort; list the files in whatever
order they are stored in the directory. But also enable `-a' (lis
--zz-Info: (coreutils.info.gz)Sorting the output, 68 lines --Top--------
Note that by going into the node about sorting, you essentially went into a sub-node of the one in
which you originally started. To go back to your previous node, you can use the u key. While u
will take you to the start of the node one level up, you could also use the l key to return you
exactly to the previous location that you were before entering the sorting node.
File: dir, Node: Top This is the top of the INFO tree
This (the Directory node) gives a menu of major topics.
Typing "q" exits, "?" lists all Info commands, "d" returns here,
"h" gives a primer for first-timers,
"mEmacslt<Return>" visits the Emacs manual, etc.
In Emacs, you can click mouse button 2 on a menu item or cross referen
ce to select it.
* Menu:
Basics
* Common options: (coreutils)Common options.
* Coreutils: (coreutils). Core GNU (file, text, shell) utilities.
* Date input formats: (coreutils)Date input formats.
* File permissions: (coreutils)File permissions.
Access modes.
* Finding files: (find). Operating on files matching certain criteria.
C++ libraries
* autosprintf: (autosprintf). Support for printf format strings in C+
-----Info: (dir)Top, 211 lines --Top------------------------------------
Welcome to Info version 5.2. Type h for help, m for menu item.
sysadmin@localhost:~$ ps --help
********* simple selection ********* ********* selection by list
*********
-A all processes -C by command name
-N negate selection -G by real group ID (supports names)
-a all w/ tty except session leaders -U by real user ID (supports names)
-d all except session leaders -g by session OR by effective group
name
-e all processes -p by process ID
T all processes on this terminal -s processes in the sessions given
a all w/ tty, including other users -t by tty
g OBSOLETE -- DO NOT USE -u by effective user ID (supports
names)
r only running processes U processes for specified users
x processes w/o controlling ttys t by tty
*********** output format ********** *********** long options ***********
-o,o user-defined -f full --Group --User --pid --cols --ppid
-j,j job control s signal --group --user --sid --rows --info
-O,O preloaded -o v virtual memory --cumulative --format --deselect
-l,l long u user-oriented --sort --tty --forest --version
-F extra full X registers --heading --no-headi
********* misc options *********
-V,V show version L list format codes f ASCII art forest
-m,m,-L,-T,H threads S children in sum -y change -l format
-M,Z security data c true command name -c scheduling class
-w,w wide output n numeric WCHAN,UID -H process hierarchy
sysadmin@localhost:~$
5.4.2 Additional System Documentation
On most systems, there is a directory where additional documentation is found. This will often be
a place where vendors who create additional (third party) software can store documentation files.
Typically, this will be a place where system administrators will go to learn how to set up more
complex software services. However, sometimes regular users will also find this documentation
to be useful.
These documentation files are often called "readme" files, since the files typically have names
such as README or readme.txt. The location of these files can vary depending on the
distribution that you are using. Typical locations include /usr/share/doc and /usr/doc.
sysadmin@localhost:~$ whatis ls
ls (1) - list directory contents
ls (lp) - list directory contents
sysadmin@localhost:~$
Based on this output, there are two commands that list directory contents. The simple answer to
why there are two lscommands is that UNIX had two main variants, which resulted in some
commands being developed "in parallel". This resulted in some commands behaving differently
on different variants of UNIX. Many modern distributions of Linux include commands from both
UNIX variants.
This does, however, pose a bit of a problem: when you run the ls command, which command is
executed? The focus of the next few sections will be to answer this question as well as to provide
you with the tools to find where these files reside on the system.
sysadmin@localhost:~$ whereis ls
ls: /bin/ls /usr/share/man/man1p/ls.1.gz /usr/share/man/man1/ls.1.gz
sysadmin@localhost:~$
Man pages are normally easily distinguished between commands as they are normally
compressed with a command called gzip, resulting in a filename that ends in .gz.
The interesting note is that you see there are two man pages listed, but only one command
(/bin/ls). This is because the lscommand can be used with the options/features that are
described by either man page. So, when you are learning what you can do with the l s command,
you can explore both man pages. Fortunately, this is more of an exception as most commands
only have one man page.
To find any file or directory, you can use the locate command. This command will search a
database of all files and directories that were on the system when the database was created.
Typically, the command to generate this database is run nightly.
Any files that you created today will not normally be searchable with the locate command. If you
have access to the system as the root user (the system administrator account), you can
manually update the l ocate database by running the u pdatedbcommand. Regular users cannot
update the database file.
Also note that when you use the locate command as a regular user, your output may be limited
due to file permissions. Essentially, if you don't have access to a file or directory on the
filesystem due to permissions, the l ocate command won't return those names. This is a security
feature designed to keep users from "exploring" the filesystem by using the l ocatedatabase.
The root user can search for any file in the l
ocate database.
In many cases, you may want to start by listing how many files will match. You can do this by
using the -c option to the locate command:
As you can see from the previous output, there will still be many results when you use the -b
option. To limit the output even further, you place a \character in front of the search term. This
character limits the output to filenames that exactly match the term: