Publishers of technology books, eBooks, and videos for creative people

Home > Articles

Getting Help and Using the Unix Manual

This chapter is from the book

There are four ways to get help when using Unix: from external documentation such as this book, Web sites, and other similar materials; from the extensive Unix reference manuals that come with every version of Unix, including Mac OS X; from the built-in help that comes with most commands; and from other people via online discussion systems, e-mail, user groups, and, yes, calling your friends on the telephone. You are already taking the first approach, so this chapter concentrates on the other three.

The Unix reference manual is a collection of files called man pages, which are specially formatted files intended to be viewed with the man command. Unix man pages are written for an audience of experienced programmers, not for novice users, so to understand Unix man pages, you need to understand the conventions used in them.

Mac OS X comes with almost 3000 Unix man pages. Most of these are copied from the FreeBSD version of Unix, the one used to create Mac OS X's Darwin layer. Some of these pages come from Apple itself, and some come from the software that Apple acquired when it bought NeXT. As of this writing (summer 2005), Apple has made progress updating the man pages to be Darwin specific, but the job is not yet done. Fortunately, most of the man pages do not require updating; unfortunately, there is no easy way to know which ones do require it.

Command-line programs almost always provide a minimal level of built-in help—usually just enough to show you the options and arguments the command expects. Still, that is often enough to remind you of the proper way to use the command.

Help from other people is the most valuable kind, and it's available from a variety of sources. At the end of this chapter is a list of the best places to look.

Using the Unix Manual

Every Unix command is supposed to have an associated man page that describes the command and the options available for using it. You read man pages using the man command.

Unix man pages are arranged into eight or nine sections, depending on which flavor of Unix you are using. Mac OS X uses the nine sections shown in Table 3.1. (These are the nine standard sections from BSD Unix, plus a section for the Tcl/Tk programming language.) Look in the various subdirectories of /usr/share/man to see all the man pages that come with Mac OS X.

Table 3.1. Sections of the Mac OS X/BSD Unix Manual

SECTION

CONTENTS

 

1

General Commands

Commands you use most frequently, such as man and grep.

2

System Calls

Commands (actually functions) provided by the operating system for use in programming, mostly in the C language, such as getlogin and setuid.

3

Library Functions

Tools for programmers that are available in a variety of languages (C, Perl, Tcl, and others), such as opendir and Text::Soundex.

4

Kernel Interfaces Manual

More-advanced tools for programmers, mostly in the C language, such as stdout and urandom.

5

System File Formats

Man pages for the most important system-configuration files, describing their use for system administration, such as appletalk.cfg and launchd.conf.

6

Games

This covers games, but Mac OS X comes with only one command-line game, banner. If you have a printer connected, try banner -w 80 "Unix" | lp.

7

Miscellaneous Information

Character-set definitions; file types; filesystem information, such as hier, which shows the filesystem hierarchy; and ascii, which describes the ASCII character set.

8

System Manager's Manual

Servers and system-administration commands, such as halt (to shut down the system) and httpd (the Apache Web server).

9

Kernel Developer's Manual Tcl and Tk Built-in Command

The Tcl/Tk programming language gets its own section of the Unix manual, describing all of the Tcl functions and libraries available, such as lindex and tk_messageBox. See man tclsh for an interactive Tcl shell.

Look in the various subdirectories of /usr/share/man to see all man pages that come with Mac OS X.

Wherever you see a Unix command name followed by a number in parentheses—for example, date(1)—the number refers to the section of the manual with which the command is associated. Thus, chown(2) refers to the chown documented in section 2 of the manual, while chown(8) refers to the chown documented in section 8 of the manual.

Throughout this book we use the Unix convention of referring to a manual entry by saying "see man entry. " entry is usually a command name—for example, we might say "see man ls" to look at the manual entry of the ls command. entry can also represent anything else the manual covers; some system-configuration files have manual entries.

To display a man page:

  1. The short answer is: man command For example, man man shows you the man page for the man command. Figure 3.1 is a code listing showing the beginning of the Unix man page for the man command. It is probably rather confusing at this point, which is why we have this chapter to explain Unix man pages.

    Example 3.1. Typing man man lets you see the man page for the man command itself (this is partial output).

    [localhost:~] vanilla% man man
    
    man(1)                                                   man(1)
    
    
    
    NAME
           man - format and display the on-line manual pages
    
    SYNOPSIS
           
             man [-acdfFhkKtwW] [--path] [-m system] [-p string] [-C config_file]
           [-M pathlist] [-P pager] [-S section_list] [section] name ...
    
    
    DESCRIPTION
           
             man formats and displays the on-line manual pages. If you specify sec-
           
             tion, man only looks in that section of the manual. name is normally
           the name of the manual page, which is typically the name of a command,
           function, or file. However, if name contains a slash ( / ) then man
           interprets it as a file specification, so that you can do man ./foo.5
           or even man /cd/foo/bar.1.gz.
    
           See below for a description of where man looks for the manual page
           files.
    
    
    OPTIONS
           
             -C config_file
                Specify the configuration file to use; the default is
                /usr/share/misc/man.conf. (See man.conf (5).)
    
           -M path
                Specify the list of directories to search for man pages. Sepa-
                rate the directories with colons. An empty list is the same as
                not specifying -M at all. See SEARCH PATH FOR MANUAL PAGES.
    
           -P pager
                Specify which pager to use. This option overrides the MANPAGER
                environment variable, which in turn overrides the PAGER vari-
                able. By default, man uses /usr/bin/less -is.
  2. Here is a longer, more useful answer. The generalized syntax of how to display a Unix man page is this:
    man [-acdfFhkKtwW] [—path] [-m
    
                rightarrow.jpg
              system] [-p string] [-C config_file]
    
                rightarrow.jpg
              [-M pathlist] [-P pager] [-S
    
                rightarrow.jpg
              section_list] [section] name    ...
    What does that mean? It is the technical way in which Unix command syntax is described. This format, though daunting at first, is a concise and accurate way of showing how a command should be used, and you will see this format constantly in Unix documentation. The man pages for commands all begin with a synopsis of the command using the format shown above. It is well worth your time to learn this syntax. Figure 3.2 shows an element-by-element translation of the specification for the man command itself.
    03fig02.jpg

    Figure 3.2 The man pages for commands all begin with a synopsis of the command using this format.

    According to the specification, the only required argument to the man command is the name of the manual entry you want (it is the only argument not inside square brackets), but there are many available options. You must read the man page itself to learn what the options mean. Here are the meanings for the options you are most likely to use:

-a

Displays all the man pages that match the command name you supply (the final argument to the man command). Normally the man command shows only the first match (searching the manual starting from section 1).

-d

Displays debugging information instead of the actual manual page(s).

-k

Finds a list of the manual pages that contain the entry in their one-line description. (The entry is the final, and required, argument to the man command.) man -k string is the same as apropros string . See "To search for a man page," below.

-K

Similar to the -k (lowercase) option, but searches the full text of all man pages for the string. Can be slow but is very useful.

-h

Displays a help message for the man command.

-t

Produces PostScript output by passing the output of the man command through another program (called troff). If you use this option, you will almost certainly want to save the output in a file or pipe it to a program that understands PostScript. (See "Printing man Pages," later in this chapter, and "Redirecting stdout" and "Creating Pipelines of Commands," in Chapter 2, "Using the Command Line.")

-w

Shows the locations of the actual man page files instead of showing the pages themselves. Try combining this with -a.

-M

You must supply a list of one or more directories (separated by colons) right after this option. The directories are searched for man pages instead of the default locations (which are all in /usr/share/man).

Sometimes you may not be sure which command you want. The apropos command can be used to search the title lines of all the manual pages.

To search for a man page:

  1. apropos keyword For example, if you were looking for commands related to appletalk, you would try apropos appletalk Figure 3.3 shows the result (reformatted slightly for print). Each entry lists the name of a man page, the section it belongs to, and usually a one-line description of the man entry.

    Example 3.3. The apropos command can be used to search the title lines of all the manual pages.

    user-vc8f9gd:~ vanilla$ apropos appletalk
    appleping(1)     -    exercises the AppleTalk network by sending packets to a named host
    appletalk(8)     -    enables you to configure and display AppleTalk network interfaces
    at_cho_prn(8)    -    allows you to choose a default printer on the AppleTalk internet
    atlookup(1)      -    looks up network-visible entities (NVEs) registered on the
                          AppleTalk network system
    atprint(1)       -    transfer data to a printer using AppleTalk protocols
    atstatus(1)      -    displays status information from an AppleTalk device
    user-vc8f9gd:~ vanilla$

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email ask@peachpit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.peachpit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020