linux whatis与whatis database 使用及查询方法(man使用实例)_linux shell

通过man查找帮助过程:

[chengmo@centos5 ~]$ man -h
...
 f:same as whatis(1)
...

#觉得比较奇怪,whatis是什么呢?

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

#The whatis database is created using the command /usr/sbin/makewhatis.
#里面还说,whatis数据库 是通过/usr/bin/makewhatis建立的

收获:whatis数据库,并且有makewhatis创建,whatis脚本是用作查询的
 

makewhatis是怎么样工作的呢?

[chengmo@centos5 ~]$ man makewhatis

#得到:

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.

#大概意思是:makewhatis 从手册页配置的路径以及领域范围,搜集所有手册页索引信息,每个手册页在数据库加入一行,这行会包括手册页里面name,以及简单描述。

收获:知道这个数据库是建立是索引,并且每个数据库写入一行(a line) ,会不会这个数据库就是文本文件呢?现在到这里,我们不知道数据库保存地方,也不知道它结构,只有看看whatis命令,看它是不是有源码信息
怎么得到whatis程序源码?

[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 “关键词“ /var/cache/man/whatis

#它实际在查找这个文件,/var/cache/man/whatis就是上面说的whatis 数据库

[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数据库就是一个文本文件记录手册页的索引信息

 

whatis数据库是什么时候创建的呢?

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

#发现创建时间是凌晨4点左右,看了这个是系统创建的,那么少不了cron怀疑了

 

[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

 

有run-parts脚本运行/etc/cron.daily目录下面的文件

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

[chengmo@centos5 cron.daily]$ cat makewhatis.cron
#!/bin/bash

LOCKFILE=/var/lock/makewhatis.lock

makewhatis -u -w

……

找到了这个是由这个脚本运行的

以上是通过man命令查找帮助信息的一个过程,有问题,首先分析帮助是个不错的选择。

作者:chengmo QQ:8292669

时间: 2024-08-01 07:06:56

linux whatis与whatis database 使用及查询方法(man使用实例)_linux shell的相关文章

linux下使用ssh远程执行命令批量导出数据库到本地_linux shell

前天正在跟前端的同事调试功能.服务器开好,模拟的玩家登录好,就在倒计时.这时突然运营的同事跑过来说要统计几个服务器玩家的一些情况,也就是需要从几个服的数据库导出部分玩家的数据.好吧,我看了一下时间,11:47.心想,跟前端调试完,去吃个饭再午休一下那就下午再给吧.没想对方来一句"就导个数据库而已,要这么久么?",而且还是直接跟我上司说的.我嚓,好吧,我导.可问题来了,平时的统计是由php做的,批量部署这些是由运维做的.服务端完全没有对应的工具.而且服务器是在阿里云上的,数据库的用户是限

linux多线程编程详解教程(线程通过信号量实现通信代码)_linux shell

线程分类 线程按照其调度者可以分为用户级线程和核心级线程两种. (1)用户级线程 用户级线程主要解决的是上下文切换的问题,它的调度算法和调度过程全部由用户自行选择决定,在运行时不需要特定的内核支持.在这里,操作系统往往会提供一个用户空间的线程库,该线程库提供了线程的创建.调度.撤销等功能,而内核仍然仅对进程进行管理.如果一个进程中的某一个线程调用了一个阻塞的系统调用,那么该进程包括该进程中的其他所有线程也同时被阻塞.这种用户级线程的主要缺点是在一个进程中的多个线程的调度中无法发挥多处理器的优势.

linux 查找过滤及用户和组管理命令的一些实例_Linux

1.列出当前系统上所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可. ~]# who | cut -d' ' -f1 | sort | uniq 2.列出最后登录到当前系统的用户的相关信息. ~]# last | head -1 3.列出当前系统上被用户当作其默认shell的最多的那个shell. ~]# cut -d: -f7 /etc/passwd | uniq -c | sort -n | tail -1 4.将/etc/passwd中的第三个字段数值最大的后10个用

在Linux下如何修改Mysql的用户(root)的密码_linux shell

下面给大家分享下在Linux下如何修改Mysql的用户(root)的密码,分两种情况:第一种当拥有原来的mysql的root密码,第二种情况忘记原来的mysql的root的密码. 修改的用户都以root为列. 一.拥有原来的mysql的root的密码: 方法一: 在mysql系统外,使用mysqladmin 复制代码 代码如下: # mysqladmin -u root -p password "test123" Enter password: [输入原来的密码] 方法二: 通过登录m

linux awk高级应用实例_linux shell

今天看到unix shell 范例精解上有道awk的题目 做了以后拿来和大家分享下 处理前的文档:  Mike Harrington:(510) 548-1278:250:100:175  Christian Dobbins:(408) 538-2358:155:90:201  Susan Dalsass:(206) 654-6279:250:60:50  Archie McNichol:(206) 548-1348:250:100:175  Jody Savage:(206) 548-1278

Shell脚本注册到Linux系统服务实例_linux shell

注册一个系统服务,开机自启动. 1 脚本编写 #vim test.sh 复制代码 代码如下: #!/bin/bash    #description: hello.sh  #chkconfig: 2345 20 81    EXEC_PATH=/usr/local/  EXEC=hello.sh  DAEMON=/usr/local/hello.sh  PID_FILE=/var/run/hello.sh.pid    . /etc/rc.d/init.d/functions    if [ !

linux bash shell中case语句的实例_linux shell

bash case语句的例子. 分享一段bash shell代码,对于学习bash的同学理解case语句的用法,会有帮助. 例子: 复制代码 代码如下: #!/bin/bash### Program:# File operation# 1.) Open file 2.) Display file 3.) Edit file 4.) Delete file# site: WWW.JB51.NETPATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/u

linux中编写自己的并发队列类(Queue 并发阻塞队列)_linux shell

设计并发队列 复制代码 代码如下: #include <pthread.h>#include <list>using namespace std; template <typename T>class Queue { public:     Queue( )     {         pthread_mutex_init(&_lock, NULL);     }     ~Queue( )     {         pthread_mutex_destroy

linux使用管道命令执行ps获取cpu与内存占用率_linux shell

复制代码 代码如下: #include <stdio.h>#include <unistd.h>int main(){    char caStdOutLine[1024]; // ps 命令的标准输出中的一行信息    char* pcTmp = NULL;      // 指向以空格拆分后的字符串     char caSelfPID[10];      // 自身进程的PID字符串    char caPSCmd[24];        // "ps aux | g