Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use linux whatis and whatis database

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to use linux whatis and whatis database". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to use linux whatis and whatis database.

Find the help process through man:

[chengmo@centos5] $man-h

...

F:same as whatis (1)

...

# find it strange, what is whatis?

[chengmo@centos5 ~] $man whatis

# the query is as follows:

# whatis-search the whatis database for complete words.

# it is a tool for querying whatis database

# The whatis database is created using the command / usr/sbin/makewhatis.

# it also says that the whatis database is established through / usr/bin/makewhatis

Harvest: whatis database, and created by makewhatis, whatis script is used as a query

How does makewhatis work?

[chengmo@centos5 ~] $man makewhatis

# get:

Makewhatis reads all the manual pages contained in the given sections of manpath or the preformatted pages con-tained in the given sections of catpath. For each page, it writes a line in 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.

# roughly means: makewhatis collects all man page index information from the man page configuration path and domain scope, and each man page adds a row to the database, which will include the name in the man page, as well as a simple description.

Harvest: knowing that the database is indexed and each database writes a line, will the database be a text file? So far, we don't know where the database is stored or its structure, just look at the whatis command to see if it has source information.

How to get the source code of whatis program?

[chengmo@centos5 ~] $type whatis

Whatis is / usr/bin/whatis

# tell the path let's take a look at the content

[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).

……

# it's a sh script

# get:

# grep "keywords" / var/cache/man/whatis

# it's actually looking for this file, / var/cache/man/whatis is the whatis database mentioned above

[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 database is a text file that records the index information of the manual page

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

# found that the creation time is around 4: 00 in the morning. If you see that this is created by the system, then cron is suspicious.

[chengmo@centos5 ~] $cat / etc/crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/

# run-parts

01 * root run-parts / etc/cron.hourly

02 4 * root run-parts / etc/cron.daily

22 4 * 0 root run-parts / etc/cron.weekly

42 4 1 * * root run-parts / etc/cron.monthly

There are files under the / etc/cron.daily directory where the run-parts script is run

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

[chengmo@centos5 cron.daily] $cat makewhatis.cron

#! / bin/bash

LOCKFILE=/var/lock/makewhatis.lock

Makewhatis-u-w

……

Found this. It was run by this script.

The above is a process of finding help information through the man command. If there is a problem, it is a good choice to analyze the help first.

Thank you for your reading, the above is the content of "how to use linux whatis and whatis database", after the study of this article, I believe you have a deeper understanding of how to use linux whatis and whatis database, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report