Chinaunix首页 | 论坛 | 博客
  • 博客访问: 232143
  • 博文数量: 81
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1782
  • 用 户 组: 普通用户
  • 注册时间: 2013-01-24 16:18
  • 认证徽章:
个人简介

为啥不能追求自己的爱好一辈子呢

文章分类

全部博文(81)

文章存档

2017年(1)

2015年(2)

2014年(18)

2013年(60)

分类: LINUX

2013-08-20 12:45:27

Man Page Sections
There are nine categories, or sections, of man pages in common use. (You may also, at times, see other more specialized sections.) 

Section Number Description
1 Executable user programs and shell commands.
2 Kernel functions or system calls.
3 Library calls that are provided by program libraries.
4 Information on device files. (Mostly, this will cover files found in the /dev directory.
5 Descriptions of file formats. (This can include Message of the Day files, configuration files, keymap files, etc.
6 Games. (Of course, most newer games come with built-in help as part of the graphical interface.)
7 Miscellaneous topics. (Macro packages, conventions, regex, etc.)
8 System administration utilities. (Most of these will require root privileges. Examples: fsck, fdisk, mount, renice, rpm, dpkg.)
9 Linux kernel documentation.

Some topics will have man pages in more than one section. If you enter the "man" command without also entering a section number, you'll see the page in the lowest-number section. To illustrate, let's take a look at the man pages for "passwd". 

If you don't enter a section number, you'll get the man page for the "passwd" command. 

man passwd
PASSWD(1) User utilities PASSWD(1)
NAME
passwd - update a user’s authentication tokens(s)
SYNOPSIS
passwd [-k] [-l] [-u [-f]] [-d] [-n mindays] [-x maxdays] [-w warndays] [-i inactive-
days] [-S] [--stdin] [username] 

DESCRIPTION
Passwd is used to update a user’s authentication token(s).
. . .
. . .
 

There's also another "passwd" man page in the file format section. 

man 5 passwd
PASSWD(5) Linux Programmer’s Manual PASSWD(5)
NAME
passwd - password file


DESCRIPTION
Passwd is a text file, that contains a list of the system’s accounts, giving for each
account some useful information like user ID, group ID, home directory, shell, etc.
Often, it also contains the encrypted passwords for each account. It should have gen-
eral read permission (many utilities, like ls(1) use it to map user IDs to user names),
but write access only for the superuser.
. . .
. . .
 

To see all of the man pages for a particular topic, use the "-a" option. You'll see the lowest-number man page first. When you exit that page, the next man page will appear. 

man -a passwd 

The "-aw" option will show you a list of all available man pages for a given topic. Here's an example that includes two of the specialized sections that we mentioned earlier. (i.e., the "3p" section and the "lp" section.) 

[donnie@localhost ~]$ man -aw printf
/usr/share/man/man1/printf.1.gz
/usr/share/man/man3p/printf.3p.gz
/usr/share/man/man3/printf.3.gz
/usr/share/man/man1p/printf.1p.gz
[donnie@localhost ~]$
 

You can view a specialized man page in the same manner that you'd view a regular man page. 

man lp printf 

By default, the "man" utility on modern Linux distros will pipe its output through the "less" utility. This way, you can page through the display and use all of the "less" search functions. 

"less" Search Functions
/ Forward search
? Backward search
n Repeat previous search

Other options are available for more complex searches. See the "less" man page for more information. 

Search Commands
These search commands will help you find which man page you need to look at for a particular topic. 

"whatis" or "man -f"
These two commands are equivalent. Both will search for the name that you specify, and return the information from the "Name" portion of all of the appropriate man pages. 

[donnie@localhost ~]$ whatis man
man (1) - format and display the on-line manual pages
man (1p) - display system documentation
man (7) - macros to format man pages
man [manpath] (1) - format and display the on-line manual pages
man.conf [man] (5) - configuration data for man 

[donnie@localhost ~]$ man -f man
man (1) - format and display the on-line manual pages
man (1p) - display system documentation
man (7) - macros to format man pages
man [manpath] (1) - format and display the on-line manual pages
man.conf [man] (5) - configuration data for man
[donnie@localhost ~]$
 

Most Linux systems store information for these commands in a database file. This makes searches much faster than they would otherwise be. To update the database on a Red Hat-type system, use the "makewhatis" utility. 

[donnie@localhost ~]$ sudo makewhatis
Password:
[donnie@localhost ~]$
 

On a Debian/Ubuntu system, use the "mandb" command. 

donnie@donnie-dual866:~$ sudo mandb
Purging old database entries in /usr/share/man...
Processing manual pages under /usr/share/man...
Purging old database entries in /usr/local/man...
mandb: can't update index cache /var/cache/man/oldlocal/index.db: No such file or directory
Processing manual pages under /usr/local/man...
Purging old database entries in /usr/local/share/man...
mandb: can't update index cache /var/cache/man/local/index.db: No such file or directory
Processing manual pages under /usr/local/share/man...
0 man subdirectories contained newer manual pages.
0 manual pages were added.
0 stray cats were added.
0 old database entries were purged.
donnie@donnie-dual866:~$
 

Note, though, that some Linux distros don't use a "whatis" database, and won't have a "makewhatis" or "mandb" utility, either. 

"apropos" or "man -k"
These commands are also equivalent. They search through both the "Name" and "Description" sections of the man page database, making for a more thorough search than "whatis" and "man -f" can do. 

These can be tricky to use, since a poorly-defined search can yield way more information than you can use. For example, if you enter. . . 

apropos man
or
man -k man 

. . .you'll see man page listings for any man page that contains the string "man" in its name section. So, you'll see results for "management", "command", "manipulate", etc. You may need to combine these utilities with other tools, such as "grep", to help narrow your searches. The use of regular expressions can also help narrow your search. (The topic of regular expressions is rather complex, however, and is beyond the scope of this learning objective.) 

阅读(343) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册