Linux基础.man中文手册离线安装教程

一. 进入man手册之后,该如何使用man手册? – 例子:mkdir

  1. 如何说,我们想查询mkdir命令怎么用? --> mkdir --> 命令 --> 1手册 --> man 1 mkdir

NAME: 对查询的内容简单描述
mkdir - make directories --> 创建目录

SYNOPSIS: 使用格式
mkdir [OPTION]… DIRECTORY…

[]: 如何出现中括号,说明该项是可以省略!
携带选项: mkdir 选项1 参数1 选项2 参数2 ... 目录1路径 目录2路径 ...
不携带选项: mkdir 目录1路径 目录2路径 ...

DESCRIPTION: 功能/参数详细描述
功能: Create the DIRECTORY(ies), if they do not already exist.
//可以同时创建多个不存在的目录

参数:
      -m, --mode=MODE
          set file mode (as in chmod), not a=rwx - umask   //给新建目录设置一个起始权限,不受到umask影响。

例子:
gec@ubuntu:~$ mkdir -m 666 diraaa
gec@ubuntu:~$ mkdir --mode=666 diraaa
以上两个命令是等价的!

结果:
drw-rw-rw- 2 gec gec 4096 Mar 11 18:38 diraaa

      -p, --parents   //没有等号,该选项后面不需要添加参数
          no error if existing, make parent directories as needed  //如果文件存在不报错,可以同时创建多级目录

//如果文件存在不报错
gec@ubuntu:~$ mkdir diraaa
mkdir: cannot create directory `diraaa’: File exists
gec@ubuntu:~$ mkdir diraaa -p
gec@ubuntu:~$

//可以同时创建多级目录
gec@ubuntu:~$ mkdir a/b/c/d
mkdir: cannot create directory `a/b/c/d’: No such file or directory
gec@ubuntu:~$ mkdir -p a/b/c/d
gec@ubuntu:~$

  1. 如果现在是mkdir函数不会用,怎么办? --> 函数 --> 2/3 —> man -f mkdir --> man 2 mkdir

NAME: 对查询的内容简单描述
mkdir - create a directory

SYNOPSIS: 使用格式
//头文件
#include <sys/stat.h>
#include <sys/types.h> --> 只要在工程中使用了mkdir(),就一定要包含这些头文件。

//函数原型
   int mkdir(const char *pathname, mode_t mode);

参数个数:只要不是变参函数,参数的个数就等于逗号个数+1  //2
每一个参数对应的类型:const char *  --> 字符串首地址    mode_t  --> 八进制权限
返回值类型:int
参数:pathname: 目录的路径
      mode:八进制权限  (mode & ~umask & 0777)

DESCRIPTION:功能/参数详细描述
参数1描述:
mkdir() attempts to create a directory named pathname.

参数2:描述:
The  argument mode specifies the permissions to use.  It is modified by
    the process's umask in the usual way: the permissions  of  the  created
    directory  are  (mode & ~umask & 0777). 

RETURN VALUE: 函数返回值
mkdir() returns zero on success, or -1 if an error occurred

成功:0
失败:-1

例子:
#include <sys/stat.h>
#include <sys/types.h>

int main()
{
umask(0000); //设置为0之后,就不会受到umask的影响
mkdir("./dir",0777); //当前目录下出现权限为777的dir目录
return 0;
}

结果:
drwxrwxrwx 2 gec gec 4096 Mar 11 19:05 dir

二. 安装中文man手册
资源: manpages-zh-1.5.1.tar.gz
记住安装软件到linux步骤: 配置,编译,安装。

  1. 把manpages-zh-1.5.1.tar.gz放置Linux系统中(共享目录)

  2. 解压到家目录下

    tar zxvf manpages-zh-1.5.1.tar.gz -C /home/gec/

  3. 切换到家目录下可以看到manpages-zh-1.5.1/

  4. 为中文手册创建一个新的安装目录包

    sudo mkdir /usr/local/zhman --> 起始权限与超级用户的umask是有关的!
    sudo chmod 777 /usr/local/zhman --> 给写/执行权限

  5. 切换到解压之后的目录下

    cd ~/manpages-zh-1.5.1/
    ls --> 看到configure

  6. 查看该配置文件对应的参数有些?

    ./configure -h

结果:

  1. 使用格式:
    Usage: ./configure [OPTION]… [VAR=VALUE]…
    ./configure [选项]… [变量=值]…

  2. 参数:
    指定安装路径:
    –prefix=PREFIX install architecture-independent files in PREFIX
    [/usr/local]
    禁用繁体字:
    –disable-zhtw do not generate manpages for zh_TW

  3. 进行配置

    ./configure --prefix=/usr/local/zhman --disable-zhtw

配置过程:
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… /bin/mkdir -p


manpages-zh configure summary

UTF-8 : true
zh_CN : true
zh_TW : false

  1. 编译
    make

编译过程:
Making all in DOCS
make[1]: Entering directory /home/gec/manpages-zh-1.5.1/DOCS' make[1]: Nothing to be done forall’.



make[1]: Entering directory /home/gec/manpages-zh-1.5.1' make[1]: Nothing to be done forall-am’.
make[1]: Leaving directory `/home/gec/manpages-zh-1.5.1’

  1. 安装
    make install

安装过程:
Making install in DOCS
make[1]: Entering directory /home/gec/manpages-zh-1.5.1/DOCS' make[2]: Entering directory/home/gec/manpages-zh-1.5.1/DOCS’

make[2]: Nothing to be done for install-data-am'. make[2]: Leaving directory/home/gec/manpages-zh-1.5.1’
make[1]: Leaving directory `/home/gec/manpages-zh-1.5.1’

安装结果: /usr/local/zhman/share/man/zh_CN
man1 man2 man3 man4 man5 man6 man7 man8 --> 该中文手册分开8个手册进行管理!

例子: 想查看ls中文手册([-M path])

  1. 查看英文手册: man ls

  2. 查看中文手册: man -M /usr/local/zhman/share/man/zh_CN ls

    练习1: 安装中文手册到Ubuntu
    练习2: "cman ls"就可以查询中文ls --> 提示: alias

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值