如何使`MANPATH =〜/ .nmap / doc man 1 nmap`寻找nmap.1?

时间:2015-06-01 12:53:18

标签: linux path gnu man system-paths

我最近决定,因为我经常尝试使用最新版本的nmap,所以最好在~/.nmap中保留其SVN结帐,而无需安装,只需运行svn up; make让它更新。我向~/.nmap添加了$PATH,我意识到通过此设置,我无法再运行man nmap了。我读了$MANPATH并意识到这对我来说似乎不起作用:

[14:51:28][~/.nmap]$ manpath                                          
manpath: warning: $MANPATH set, prepending /etc/man_db.conf
/home/d/virtualenv/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man:/usr/man:/home/d/.nmap/docs/man-xlate/:/home/d/.nmap/docs
[14:51:32][~/.nmap]$ strace  man 1 nmap 2>&1 | egrep 'nmap.1|write'
stat("/home/d/.nmap/docs/zenmap.1", {st_mode=S_IFREG|0664, st_size=5943, ...}) = 0
stat("/home/d/.nmap/docs/nmap.1", {st_mode=S_IFREG|0664, st_size=183621, ...}) = 0
access("/usr/share/man/man1/nmap.1.gz", R_OK) = -1 ENOENT (No such file or directory)
write(2, "No manual entry for nmap in sect"..., 38No manual entry for nmap in section 1

为什么会这样,我该如何解决?我注意到man也在index.db中查找名为~/.nmap/docs的文件但无法找到它,也许这是一个线索?

1 个答案:

答案 0 :(得分:1)

问题是docs目录没有man要求的目录结构(nmap.1应该在man1子目录中),与使用-M选项时相同:

    -M path, --manpath=path
          Specify an alternate manpath to use.  By default,  man  uses
          manpath  derived code to determine the path to search.  This
          option  overrides  the  $MANPATH  environment  variable  and
          causes option -m to be ignored.

          A  path  specified as a manpath must be the root of a manual
          page hierarchy structured into sections as described in  the
          man-db  manual  (under  "The  manual page system").  To view
          manual pages outside such hierarchies, see the -l option.

使用make install时,联机帮助页已安装到正确的类别子目录中。所以将MANPATH指向docs目录直接无法工作。