• Linux 命令


    man 命令是 Linux 中最常用的命令,碰到任何让你疑惑的命令,都可以 man 一下来查看详情。不只是 shell 命令,C 语言库函数和系统调用等内容也可以通过 man 命令查看。

    man 命令默认查看的是 shell 命令的文档,可以指定参数 2 查看系统调用,3 查看 C 库函数(需要提前安装)。可以在 Linux 中直接输入 man man 查看 man 命令的帮助文档,最常用的就是查看 shell 命令、系统调用和库函数,例如:

    man printf
    man 2 open
    man 3 printf
    

    man 文档:

    NAME
           man - an interface to the on-line reference manuals
    
    SYNOPSIS
           man  [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-m system[,...]] [-M path] [-S list] [-e extension] [-i|-I] [--regex|--wildcard]
           [--names-only] [-a] [-u] [--no-subpages] [-P pager] [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justification]  [-p  string]  [-t]  [-T[device]]
           [-H[browser]] [-X[dpi]] [-Z] [[section] page[.section] ...] ...
           man -k [apropos options] regexp ...
           man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...
           man -f [whatis options] page ...
           man  -l  [-C  file]  [-d]  [-D]  [--warnings[=warnings]]  [-R  encoding] [-L locale] [-P pager] [-r prompt] [-7] [-E encoding] [-p string] [-t] [-T[device]]
           [-H[browser]] [-X[dpi]] [-Z] file ...
           man -w|-W [-C file] [-d] [-D] page ...
           man -c [-C file] [-d] [-D] page ...
           man [-?V]
    
    DESCRIPTION
           man is the system's manual pager.  Each page argument given to man is normally the name of a program, utility or function.  The manual page associated  with
           each  of  these  arguments  is  then  found and displayed.  A section, if provided, will direct man to look only in that section of the manual.  The default
           action is to search in all of the available sections following a pre-defined order ("1 n l 8 3 2 3posix 3pm 3perl 3am 5 4 9 6 7" by default, unless overrid‐
           den by the SECTION directive in /etc/manpath.config), and to show only the first page found, even if page exists in several sections.
    
           The table below shows the section numbers of the manual followed by the types of pages they contain.
    
           1   Executable programs or shell commands
           2   System calls (functions provided by the kernel)
           3   Library calls (functions within program libraries)
           4   Special files (usually found in /dev)
           5   File formats and conventions eg /etc/passwd
           6   Games
           7   Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
           8   System administration commands (usually only for root)
           9   Kernel routines [Non standard]
    
           A manual page consists of several sections.
    

    安装 man 手册

    各大 Linux 发行版默认带了 shell 命令的 man 文档,其他文档需要自己下载。

    安装最新版本的 man 手册

    官方下载链接:https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/ 。在 man-pages-posix 文件夹下,有 POSIX 的 man 手册。

    wget https://www.kernel.org/pub/linux/docs/man-pages/man-pages-4.16.tar.gz
    tar -xvzf man-pages-4.16.tar.gz
    cd man-pages-4.16
    make install
    

    当然也可以用 Linux 发行版自带的仓库安装,例如 Ubuntu:

    apt-get install manpages
    

    安装 C 库函数手册

    首先执行下面的命令,如果报错找不到文档,则说明没有安装:

    man 3 printf
    

    Ubuntu 下需要一个个单独安装,或用通配符一次安装:

    apt-get install manpages-dev
    apt-get install manpages*
    

    CentOS 则可以一次安装:

    yum install man-pages
    

    Linux 下 C 库函数的 man 手册的说明

    • manpages:Linux 的基本命令的用法,针对 Linux 用户
    • manpages-dev:Linux 及 C 标准库的 API,针对 Linux 开发者
    • manpages-posix:POSIX 标准接口
    • manpages-posix-dev:POSIX 的头文件和函数库的用法
  • 相关阅读:
    淘宝技术架构演进之路
    单点登录
    [c++11] ——条件变量(Condition Variable)
    std::lock_guard unique_lock
    C++中push_back和emplace_back的区别
    C++11 CAS无锁函数compare_exchange_weak的使用
    C++11新特性之 rvalue Reference(右值引用)
    C++ auto和decltype的区别
    ovs contrack
    周总结03
  • 原文地址:https://www.cnblogs.com/kika/p/10851505.html
Copyright © 2020-2023  润新知