zoukankan      html  css  js  c++  java
  • linux —— 基础——whatis & info & man & which & whereis

    #man -k
    
    root@bae226a5b14a:/etc/dpkg/dpkg.cfg.d# man -k man
    add_key (2)          - add a key to the kernel's key management facility
    at (1posix)          - execute commands at a later time
    batch (1posix)       - schedule commands to be executed in a batch queue
    bpf (2)              - perform a command on an extended BPF map or program
    bsd_signal (3)       - signal handling with BSD semantics
    command (1posix)     - execute a simple command
    copysign (3posix)    - number manipulation function
    cproj (3)            - project into Riemann Sphere
    cprojf (3)           - project into Riemann Sphere
    cprojl (3)           - project into Riemann Sphere
    CPU_ALLOC (3)        - macros for manipulating CPU sets
    CPU_ALLOC_SIZE (3)   - macros for manipulating CPU sets
    CPU_AND (3)          - macros for manipulating CPU sets
    CPU_AND_S (3)        - macros for manipulating CPU sets
    CPU_CLR (3)          - macros for manipulating CPU sets
    CPU_CLR_S (3)        - macros for manipulating CPU sets
    CPU_COUNT (3)        - macros for manipulating CPU sets
    CPU_COUNT_S (3)      - macros for manipulating CPU sets
    CPU_EQUAL (3)        - macros for manipulating CPU sets
    CPU_EQUAL_S (3)      - macros for manipulating CPU sets
    CPU_FREE (3)         - macros for manipulating CPU sets
    CPU_ISSET (3)        - macros for manipulating CPU sets
    CPU_ISSET_S (3)      - macros for manipulating CPU sets
    CPU_OR (3)           - macros for manipulating CPU sets
    CPU_OR_S (3)         - macros for manipulating CPU sets
    CPU_SET (3)          - macros for manipulating CPU sets
    CPU_SET_S (3)        - macros for manipulating CPU sets
    CPU_XOR (3)          - macros for manipulating CPU sets
    CPU_XOR_S (3)        - macros for manipulating CPU sets
    CPU_ZERO (3)         - macros for manipulating CPU sets
    CPU_ZERO_S (3)       - macros for manipulating CPU sets
    dot (1posix)         - execute commands in the current environment
    env (1posix)         - set the environment for command invocation
    ether_aton (3)       - Ethernet address manipulation routines
    ether_aton_r (3)     - Ethernet address manipulation routines
    ether_hostton (3)    - Ethernet address manipulation routines
    ether_line (3)       - Ethernet address manipulation routines
    ether_ntoa (3)       - Ethernet address manipulation routines
    ether_ntoa_r (3)     - Ethernet address manipulation routines
    ether_ntohost (3)    - Ethernet address manipulation routines
    eval (1posix)        - construct command by concatenating arguments
    exec (1posix)        - execute commands and open, close, or copy file descriptors
    fallocate (2)        - manipulate file space
    fc (1posix)          - process the command history list
    fcntl (2)            - manipulate file descriptor
    fcntl64 (2)          - manipulate file descriptor
    frexp (3posix)       - extract mantissa and exponent from a double precision number
    get_thread_area (2)  - manipulate thread-local storage information
    getnameinfo (3)      - address-to-name translation in protocol-independent manner
    getopt (3)           - Parse command-line options
    getopt (3posix)      - command option parsing
    getopt_long (3)      - Parse command-line options
    getopt_long_only (3) - Parse command-line options
    gnu_dev_major (3)    - manage a device number
    gnu_dev_makedev (3)  - manage a device number
    gnu_dev_minor (3)    - manage a device number
    hcreate (3)          - hash table management
    hcreate (3posix)     - manage hash search table
    hcreate_r (3)        - hash table management
    hdestroy (3)         - hash table management
    hdestroy_r (3)       - hash table management
    hosts.equiv (5)      - list of hosts and users that are granted "trusted" r command access to your system
    hsearch (3)          - hash table management
    hsearch_r (3)        - hash table management
    inet (3)             - Internet address manipulation routines
    inet_addr (3)        - Internet address manipulation routines
    inet_addr (3posix)   - IPv4 address manipulation
    inet_aton (3)        - Internet address manipulation routines
    inet_lnaof (3)       - Internet address manipulation routines
    inet_makeaddr (3)    - Internet address manipulation routines
    inet_netof (3)       - Internet address manipulation routines
    inet_network (3)     - Internet address manipulation routines
    inet_ntoa (3)        - Internet address manipulation routines
    intro (1)            - introduction to user commands
    intro (8)            - introduction to administration and privileged commands
    ioctl_fat (2)        - manipulating the FAT filesystem
    iruserok (3)         - routines for returning a stream to a remote command
    iruserok_af (3)      - routines for returning a stream to a remote command
    keyctl (2)           - manipulate the kernel's key management facility
    keyrings (7)         - in-kernel key management and retention facility
    major (3)            - manage a device number
    makecontext (3)      - manipulate user context
    makedev (3)          - manage a device number
    man (1posix)         - display system documentation
    man (7)              - macros to format man pages
    man-pages (7)        - conventions for writing Linux man pages
    minor (3)            - manage a device number
    nextafter (3)        - floating-point number manipulation
    nextafterf (3)       - floating-point number manipulation
    nextafterl (3)       - floating-point number manipulation
    nexttoward (3)       - floating-point number manipulation
    nexttowardf (3)      - floating-point number manipulation
    nexttowardl (3)      - floating-point number manipulation
    optarg (3)           - Parse command-line options
    opterr (3)           - Parse command-line options
    optind (3)           - Parse command-line options
    optopt (3)           - Parse command-line options
    perf_event_open (2)  - set up performance monitoring
    perfmonctl (2)       - interface to IA-64 performance monitoring unit
    posix_trace_close (3posix) - trace log management (TRACING)
    posix_trace_eventid_equal (3posix) - manipulate the trace event type identifier (TRACING)
    posix_trace_eventset_add (3posix) - manipulate trace event type sets (TRACING)
    posix_trace_open (3posix) - trace log management (TRACING)
    pthread_getspecific (3posix) - thread-specific data management
    pthread_setspecific (3posix) - thread-specific data management
    quotactl (2)         - manipulate disk quotas
    rcmd (3)             - routines for returning a stream to a remote command
    rcmd_af (3)          - routines for returning a stream to a remote command
    request_key (2)      - request a key from the kernel's key management facility
    rexec (3)            - return stream to a remote command
    rexec_af (3)         - return stream to a remote command
    rresvport (3)        - routines for returning a stream to a remote command
    rresvport_af (3)     - routines for returning a stream to a remote command
    rtnetlink (3)        - macros to manipulate rtnetlink messages
    ruserok (3)          - routines for returning a stream to a remote command
    ruserok_af (3)       - routines for returning a stream to a remote command
    set_thread_area (2)  - manipulate thread-local storage information
    sgetmask (2)         - manipulation of signal mask (obsolete)
    sh (1posix)          - shell, the standard command language interpreter
    sighold (3posix)     - signal management
    signal (3posix)      - signal management
    significand (3)      - get mantissa of floating-point number
    significandf (3)     - get mantissa of floating-point number
    significandl (3)     - get mantissa of floating-point number
    sigrelse (3posix)    - signal management
    ssetmask (2)         - manipulation of signal mask (obsolete)
    swapcontext (3)      - manipulate user context
    sys_mman.h (7posix)  - memory management declarations
    system (3)           - execute a shell command
    system (3posix)      - issue a command
    sysv_signal (3)      - signal handling with System V semantics
    tdelete (3)          - manage a binary search tree
    tdelete (3posix)     - manage a binary search tree
    tdestroy (3)         - manage a binary search tree
    tfind (3)            - manage a binary search tree
    time (1posix)        - time a simple command
    tsearch (3)          - manage a binary search tree
    twalk (3)            - manage a binary search tree
    twalk_r (3)          - manage a binary search tree
    type (1posix)        - write a description of command type
    ulimit.h (7posix)    - ulimit commands
    uux (1posix)         - remote command execution
    root@bae226a5b14a:/etc/dpkg/dpkg.cfg.d#
    

      

    root@bae226a5b14a:/# whatis command
    command (1posix)     - execute a simple command
    root@bae226a5b14a:/# whatis ls
    ls (1posix)          - list directory contents
    root@bae226a5b14a:/# whatis man
    man (7)              - macros to format man pages
    man (1posix)         - display system documentation
    root@bae226a5b14a:/# whatis -w "loca*"
    locale (1)           - get locale-specific information
    locale (1posix)      - get locale-specific information
    locale (5)           - describes a locale definition file
    locale (7)           - description of multilanguage support
    locale.h (7posix)    - category macros
    localeconv (3)       - get numeric formatting information
    localeconv (3posix)  - return locale-specific information
    localedef (1)        - compile locale definition files
    localedef (1posix)   - define locale environment
    localtime (3)        - transform date and time to broken-down time or ASCII
    localtime (3posix)   - convert a time value to a broken-down local time
    localtime_r (3)      - transform date and time to broken-down time or ASCII
    root@bae226a5b14a:/# info command
    bash: info: command not found
    

      

    # dockerfile
    
    && apt-get install -y info
    

     

    1.2. 命令使用

    查看命令的简要说明

    简要说明命令的作用(显示命令所处的man分类页面):

    $whatis command
    

    正则匹配:

    $whatis -w "loca*"
    

    更加详细的说明文档:

    $info command
    

    使用man

    查询命令command的说明文档:

    $man command
    eg:man date
    

    使用page up和page down来上下翻页

    在man的帮助手册中,将帮助文档分为了9个类别,对于有的关键字可能存在多个类别中, 我们就需要指定特定的类别来查看;(一般我们查询bash命令,归类在1类中);

    man页面所属的分类标识(常用的是分类1和分类3)

    (1)、用户可以操作的命令或者是可执行文件
    (2)、系统核心可调用的函数与工具等
    (3)、一些常用的函数与数据库
    (4)、设备文件的说明
    (5)、设置文件或者某些文件的格式
    (6)、游戏
    (7)、惯例与协议等。例如Linux标准文件系统、网络协议、ASCⅡ,码等说明内容
    (8)、系统管理员可用的管理条令
    (9)、与内核有关的文件
    

    前面说到使用whatis会显示命令所在的具体的文档类别,我们学习如何使用它

    eg:
    $whatis printf
    printf               (1)  - format and print data
    printf               (1p)  - write formatted output
    printf               (3)  - formatted output conversion
    printf               (3p)  - print formatted output
    printf [builtins]    (1)  - bash built-in commands, see bash(1)
    

    我们看到printf在分类1和分类3中都有;分类1中的页面是命令操作及可执行文件的帮助;而3是常用函数库说明;如果我们想看的是C语言中printf的用法,可以指定查看分类3的帮助:

    $man 3 printf
    
    $man -k keyword
    

    查询关键字 根据命令中部分关键字来查询命令,适用于只记住部分命令的场合;

    eg:查找GNOME的config配置工具命令:

    $man -k GNOME config| grep 1
    

    对于某个单词搜索,可直接使用/word来使用: /-a; 多关注下SEE ALSO 可看到更多精彩内容

    root@bae226a5b14a:/# whatis printf
    printf (3)           - formatted output conversion
    printf (1posix)      - write formatted output
    printf (3posix)      - print formatted output
    root@bae226a5b14a:/# man 3 printf
    PRINTF(3)                                     Linux Programmer's Manual                                     PRINTF(3)
    
    NAME
           printf, fprintf, dprintf, sprintf, snprintf, vprintf, vfprintf, vdprintf, vsprintf, vsnprintf - formatted out-
           put conversion
    
    SYNOPSIS
           #include <stdio.h>
    
           int printf(const char *format, ...);
           int fprintf(FILE *stream, const char *format, ...);
           int dprintf(int fd, const char *format, ...);
           int sprintf(char *str, const char *format, ...);
           int snprintf(char *str, size_t size, const char *format, ...);
    
           #include <stdarg.h>
    
           int vprintf(const char *format, va_list ap);
           int vfprintf(FILE *stream, const char *format, va_list ap);
           int vdprintf(int fd, const char *format, va_list ap);
           int vsprintf(char *str, const char *format, va_list ap);
           int vsnprintf(char *str, size_t size, const char *format, va_list ap);
    
       Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
    
           snprintf(), vsnprintf():
               _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE ||
                   || /* Glibc versions <= 2.19: */ _BSD_SOURCE
    
           dprintf(), vdprintf():
               Since glibc 2.10:
                   _POSIX_C_SOURCE >= 200809L
               Before glibc 2.10:
                   _GNU_SOURCE
    
    DESCRIPTION
           The functions in the printf() family produce output according to a format as described below.   The  functions
           printf() and vprintf() write output to stdout, the standard output stream; fprintf() and vfprintf() write out-
           put to the given output stream; sprintf(), snprintf(), vsprintf()  and  vsnprintf()  write  to  the  character
           string str.
    
           The function dprintf() is the same as fprintf() except that it outputs to a file descriptor, fd, instead of to
           a stdio stream.
    
           The functions snprintf() and vsnprintf() write at most size bytes (including the terminating null byte (''))
           to str.
    
           The  functions  vprintf(),  vfprintf(),  vdprintf(),  vsprintf(),  vsnprintf() are equivalent to the functions
    root@bae226a5b14a:/# man -k keyword
    keyword: nothing appropriate.
    root@bae226a5b14a:/# man -k GNOME config| grep 1
    GNOME: nothing appropriate.
    dir_colors (5)       - configuration file for dircolors(1)
    getconf (1posix)     - get configuration values
    root@bae226a5b14a:/#   
    

      

    查看路径

    查看程序的binary文件所在路径:

    $which command
    

    eg:查找make程序安装路径:

    $which make
    /opt/app/openav/soft/bin/make install
    

    查看程序的搜索路径:

    $whereis command
    

    当系统中安装了同一软件的多个版本时,不确定使用的是哪个版本时,这个命令就能派上用场;

    总结

    whatis info man which whereis

    root@bae226a5b14a:/# man -k keyword
    keyword: nothing appropriate.
    root@bae226a5b14a:/# man -k GNOME config| grep 1
    GNOME: nothing appropriate.
    dir_colors (5)       - configuration file for dircolors(1)
    getconf (1posix)     - get configuration values
    root@bae226a5b14a:/# which make
    root@bae226a5b14a:/# which vi
    /usr/bin/vi
    root@bae226a5b14a:/# whereis vi
    vi: /usr/bin/vi /usr/share/man/man1/vi.1posix.gz
    root@bae226a5b14a:/#
    

      

    #dockerfile change
    
    
    # base image
    FROM ubuntu:latest
    
    LABEL maintainer="Pan"
    # WORKDIR /app
    
    EXPOSE 3000
    EXPOSE 35729
    
    COPY sources.list /etc/apt
    RUN  apt-get update 
    # && apt-get install -y locales 
    # && apt-get install debconf 
    # && echo "Asia/Shanghai" > /etc/timezone 
    # && dpkg-reconfigure -f noninteractive tzdata  
    # && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 
    # && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen 
    # && echo 'LANG="en_US.UTF-8"'>/etc/default/locale 
    # && dpkg-reconfigure --frontend=noninteractive locales 
    # && update-locale LANG=en_US.UTF-8 
    && apt-get install -y man 
    && apt-get install manpages 
    && apt-get install manpages-dev 
    && apt-get install manpages-posix 
    && apt-get install manpages-posix-dev 
    && apt-get install -y vim 
    && apt-get install -y info
    
    # CMD ["/bin"]
    

      

    原文地址:

    https://linuxtools-rst.readthedocs.io/zh_CN/latest/base/01_use_man.html

     

  • 相关阅读:
    ExtJs-学习篇(1)
    js中的Ajax经典示例
    软件工程开发流程
    Maven和Ajax
    搭建SSH框架
    拦截器
    OGNL
    Struts 2配置详解
    Struts 2入门
    HQL连接查询和注解
  • 原文地址:https://www.cnblogs.com/panpanwelcome/p/12667852.html
Copyright © 2011-2022 走看看