Linux Whatis and Whatis database usage and query methods (man usages) _linux shell

Source: Internet
Author: User

Find the help process through the man:

[Chengmo@centos5 ~]$ Man-h
...
F:same as Whatis (1)
...

#觉得比较奇怪, what is Whatis?

[Chengmo@centos5 ~]$ Mans Whatis
#查询得到是:
#whatis-search The Whatis database for complete words.
#它是查询whatis数据库的工具

#The Whatis database is created using the Command/usr/sbin/makewhatis.
#里面还说, the Whatis database was built through/usr/bin/makewhatis.

Harvest: Whatis database, and has Makewhatis created, Whatis script is used as a query

How does Makewhatis work?

[Chengmo@centos5 ~]$ Mans Makewhatis

#得到:

Makewhatis reads the manual pages contained in given sections of Manpath or the preformatted pages con-tained in t  He given sections of Catpath.  For each page, it writes the Whatis database; Each line consists of the name of the page and a short description, separated by a dash. The description is extracted using the content of the ' NAME section of the ' manual page.

#大概意思是: Makewhatis The path and scope from the man page, gathers all the man page index information, each man page joins a row in the database, which includes the name of the man page and a simple description.

Harvest: Know that the database is built to be indexed, and each database is written in a row (a line), will this database is a text file? Now here, we do not know where the database is saved, nor do we know its structure, only look at the Whatis command to see if it has source information
How to get Whatis program source code?

[Chengmo@centos5 ~]$ type Whatis
Whatis Is/usr/bin/whatis

#告诉路径我们看看内容


[Chengmo@centos5 ~]$ Vi/usr/bin/whatis

1 #!/bin/sh
2 #
3 # Apropos-Search the Whatis database for keywords.
4 # Whatis-idem, but match only commands (as whole words).

......

#它是个sh脚本,

#得到:

#grep "Key Words"/var/cache/man/whatis

#它实际在查找这个文件,/var/cache/man/whatis is the Whatis database.

[Chengmo@centos5 ~]$ Head/var/cache/man/whatis
$notes _name [Module::build::notes] (3pm)-Configuration for $module _name
*_unlocked [Unlocked_stdio] (3)-non-locking stdio functions

#whatis数据库就是一个文本文件记录手册页的索引信息

When was the Whatis database created?

[Chengmo@centos5 ~]$ Ls-al/var/cache/man/whatis
-rw-r--r--1 root root 1057156 10-27 04:06/var/cache/man/whatis

#发现创建时间是凌晨4点左右, look at this is the system created, then the cron suspect

[Chengmo@centos5 ~]$ Cat/etc/crontab
Shell=/bin/bash
Path=/sbin:/bin:/usr/sbin:/usr/bin
Mailto=root
home=/

# Run-parts
* * * * Root run-parts/etc/cron.hourly
4 * * * Root run-parts/etc/cron.daily
4 * * 0 root run-parts/etc/cron.weekly
4 1 * * Root run-parts/etc/cron.monthly

There are run-parts scripts to run the files under the/etc/cron.daily directory

[Chengmo@centos5 ~]$ cd/etc/cron.daily/

[Chengmo@centos5 cron.daily]$ Cat Makewhatis.cron
#!/bin/bash

Lockfile=/var/lock/makewhatis.lock

Makewhatis-u-W

......

This is the script that runs this.

The above is a process of finding help information through the Man command, and there is a problem, first of all, to analyze the help is a good choice.

Author: Chengmo qq:8292669

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.