文章目录
- 获取完整的man(manpages)linux参考手册/中文man的下载和使用/获取buildin 命令的完整帮助文档
 
- 搜索manpages 相关package
 - 安装扩展man手册
 - references
 
- man:浏览器在线查阅vs本地终端查阅
 
- 临时查阅
 
- man 分类
 - 安装manpages-posix
 
- 默认安装的man(manpages)手册工具包
 - 查看各种manPage的description
 - 使用1posix section
 
- 指定1p section
 
- 安装中文man(manpages-zh)
 
- 检查安装
 - 利用man来检索内容中文man(manpages-zh)
 - 配置中文man别名
 
- 中文man的后续自动化配置
 - 为man着色
 - linux 命令选项分类
 
获取完整的man(manpages)linux参考手册/中文man的下载和使用/获取buildin 命令的完整帮助文档
- 默认安装的man(sudo apt install man)不能够涵盖所有命令
 - 为了获得完整的手册,(来支持一些shell内建命令/posix命令);我们需要进行额外的按需安装
 
搜索manpages 相关package
- 
apt search manpages | more - 
apt-cache search manpages 
安装扩展man手册
根据下方的配置,可以大致的感受到,man命令是一个读取各类符合某种规范的手册(文件)的一个工具
- 这些文件可以是自己下载指定的(当然安装man命令的时候已经有默认的数据下载下来)
 - 您可以自己额外的下载合适自己的手册文件版本
默认的手册目录是/usr/share/manman -M选线可以告诉man工具检索指定目录下的手册文件 
references
- How to install man pages on Ubuntu Linux - nixCraft (cyberciti.biz)
 - Linux man Command | Learn How to Use Man Command in Linux? (educba.com)
 - 在线可搜索文档Linux man pages online (man7.org)
 
- Linux manual pages: all pages, by section (man7.org)
 - Linux manual pages: alphabetic list of all pages (man7.org)
 
man:浏览器在线查阅vs本地终端查阅
- 使用浏览器来阅读会更加友好一些
 
- 某些浏览器插件可以帮助我们看到大纲,这对于某些很长的man页面来说横有用(譬如
 - 
man bash - 
man ps - 
man sed - …
 
- 通过搜索引擎(英):
linux man7 <keyWord> 
- (内容由man7.org提供)
 
临时查阅
临时查阅,用man 命令在终端内查阅比较方便
- 终端命令行中阅读使用的是
less这个阅读工具(命令行工具,导航/跳转/搜索功能也是有less命令提供的) 
- 当然,您可以为less 指定颜色
 - 还可以更换默认的阅读器(譬如使用most,自动高亮某些词)
 
man 分类
- 
apt-cache search manpages | egrep 'manpages-(dev|posix)' 
# cxxu_kali @ CxxuWin11 in ~ [16:05:29]
$ apt-cache search manpages | egrep 'manpages-(dev|posix)'
manpages-dev - Manual pages about using GNU/Linux for development
manpages-posix - Manual pages about using POSIX system
manpages-posix-dev - Manual pages about using a POSIX system for development安装manpages-posix
sudo apt update
#更新完源后,安装两个package:man-db 以及manpages-posix
sudo apt install man-db manpages-posix默认安装的man(manpages)手册工具包
# cxxu_kali @ CxxuWin11 in ~ [16:18:09]
$ apt info manpages
Package: manpages
Version: 5.10-1
Priority: standard
Section: doc
Maintainer: Dr. Tobias Quathamer <toddy@debian.org>
Installed-Size: 1,709 kB
Suggests: man-browser
Breaks: attr (<< 1:2.4.47-3), keyutils (<< 1.6-1), manpages-dev (<< 5.09-2)
Replaces: attr (<< 1:2.4.47-3), keyutils (<< 1.6-1), manpages-dev (<< 5.09-2)
Homepage: https://www.kernel.org/doc/man-pages/
Tag: made-of::man, role::documentation
Download-Size: 1,412 kB
APT-Manual-Installed: no
APT-Sources: http://mirrors.tuna.tsinghua.edu.cn/kali kali-rolling/main amd64 Packages
# 该工具包是linux系统的使用手册
Description: Manual pages about using a GNU/Linux system
 This package contains GNU/Linux manual pages for these sections:
  4 = Devices (e.g. hd, sd).
  5 = File formats and protocols, syntaxes of several system
      files (e.g. wtmp, /etc/passwd, nfs).
  7 = Conventions and standards, macro packages, etc.
      (e.g. nroff, ascii).
 .
 Sections 1, 6 and 8 are provided by the respective applications. This
 package only includes the intro man page describing the section.
 .
 The man pages describe syntaxes of several system files.查看各种manPage的description
- 
apt info <man version> 
例如:
- 
apt info manpages-posix - 如下描述可见,其适用范围比linux更广(可以用在满足posix标准规范的操作系统上(unix/linux/macOs))
 
...
Description: Manual pages about using POSIX system
 This package contains manual pages for POSIX utilities
 and keeps them in section 1 (with 1posix extension) of the
 on-line manual.
安装完扩展的manpages-posix后,apropos命令可以检索到新的section(1posix);
1posix缩写为1p
使用1posix section
# cxxu_kali @ CxxuWin11 in /mnt/c/Users/cxxu [18:36:34]
$ apropos jobs
bg (1posix)          - run jobs in the background
fg (1posix)          - run jobs in the foreground
jobs (1posix)        - display status of jobs in the current session
qdel (1posix)        - delete batch jobs
qhold (1posix)       - hold batch jobs
qmove (1posix)       - move batch jobs
qmsg (1posix)        - send message to batch jobs
qrerun (1posix)      - rerun batch jobs指定1p section
man 1p jobs
安装中文man(manpages-zh)
- 
sudo apt install manpages-zh 
检查安装
查看路径cd /usr/share/man/zh_CN
# cxxu_kali @ CxxuWin11 in ~ [16:30:06] C:130
$ cd /usr/share/man/zh_CN
# cxxu_kali @ CxxuWin11 in /usr/share/man/zh_CN [16:30:13]
$ ls
man1  man2  man3  man4  man5  man6  man7  man8
# cxxu_kali @ CxxuWin11 in /usr/share/man/zh_CN [16:30:15]
$利用man来检索内容中文man(manpages-zh)
- 
man -M /usr/share/man/zh_CN <keyword> 
- 譬如检索中文ls 文档
man -M /usr/share/man/zh_CN ls 
配置中文man别名
可以将中文man 配置别名cman或者自己喜欢的名字
# cxxu_kali @ CxxuWin11 in /usr/share/man/zh_CN [16:33:44]
$ alias cman=" man -M /usr/share/man/zh_CN "
#体验简写
# cxxu_kali @ CxxuWin11 in /usr/share/man/zh_CN [16:34:36]
$ cman ls中文man的后续自动化配置
Ubuntu/kali 安装中文man手册
 sudo apt-get install manpages-zh
 (注意,在linux命令行中,横杠’-‘用的比下滑线’‘来的多,这里是’-‘不是’’
 其中zh_开头的就是中文包的man手册,
- zh_CN简体中文
 
为了方便调用中文版的man命令,同时保留英文原版man命令,我们为其添加一个别名cman, 这样我们可以很方便的使用中文的man手册,在~/.bashrc中添加(如果想要全局(全部用户都生效,则用
 用管理员命令修改/etc下的bashrc文件(这里演示zsh(zshrc在zsh目录下一层

- 如果是zsh,需要更进一步:
 

 这里演示的是zsh的全局修改
sudo vim /etc/zsh/zshrc/
(如果是bash 写作 sudo vim /etc/bash.bashrc(还未证实))
末尾添加一行
alias cman='man -M /usr/share/man/zh_CN
这样man是英文的, 而cman则是一个中文的man手册
   man ls
   cman ls- 将得到不同的内容

 
为man着色
- How to Display man Pages in Color on Linux (howtogeek.com)
 - How to View Colored Man Pages in Linux (tecmint.com)
 
- 查看系统默认阅读器(pager):
 
- 
echo $PAGER 
# cxxu_kali @ CxxuWin11 in ~ [8:35:49]
$ echo $PAGER
less- 下载
most阅读工具,并且将默认阅读器修改为most 
- 
export PAGER="most" - 如果需要长期有效,那么可以将其写入配置文件(譬如 .bashrc)
 
- 修改颜色变量(仍然使用less作为默认阅读器)
 
- 关于颜色的参考
 
- terminal - Documentation on LESS_TERMCAP_* variables? - Unix & Linux Stack Exchange
 - 
man termcap - 
man terminfo - 
man terminal-colors.d - 
man dircolors 
man() {
    # LESS_TERMCAP_md=$'\e[01;31m' \
    # LESS_TERMCAP_me=$'\e[0m' \
    # LESS_TERMCAP_se=$'\e[0m' \
    # LESS_TERMCAP_so=$'\e[45;93m' \
    # LESS_TERMCAP_ue=$'\e[0m' \
    # LESS_TERMCAP_us=$'\e[01;32m' \
    export LESS_TERMCAP_mb=$'\e[1;32m'
    export LESS_TERMCAP_md=$'\e[01;31m'
    export LESS_TERMCAP_me=$'\e[0m'
    export LESS_TERMCAP_se=$'\e[0m'
    export LESS_TERMCAP_so=$'\e[45;93m'
    export LESS_TERMCAP_ue=$'\e[0m'
    export LESS_TERMCAP_us=$'\e[01;32m'
    command man "$@"
}
可以将上述参数别名写入配置文件(譬如.bashrc)来永久生效
linux 命令选项分类
several kinds of options:
       1   UNIX options, which may be grouped and must be preceded by a dash.(单横杠选项)
       2   BSD options, which may be grouped and must not be used with a dash.(无横杠选项)
       3   GNU long options, which are preceded by two dashes.(双横杠选项)                










