• linux系统man命令用法和安装方法


    Linux提供了丰富的帮助手册,当你需要查看某个命令的参数时不必到处上网查找,只要man一下即可。

    Linux的man手册共有以下几个章节:

    代號 代表內容 1 使用者在shell中可以操作的指令或可执行档 2 系統核心可呼叫的函数与工具等 3 一些常用的函数(function)与函数库(library),大部分是C的函数库(libc) 4 装置档案的说明,通常在/dev下的档案 5 设定档或者是某些档案的格式 6 游戏(games) 7 惯例与协定等,例如Linux档案系统、网络协定、ASCII code等等的說明 8 系統管理員可用的管理指令 9 跟kernel有关的文件

    如:man 5 data

    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]

    1、Standard commands (标准命令) 2、System calls (系统调用) 3、Library functions (库函数) 4、Special devices (设备说明) 5、File formats (文件格式) 6、Games and toys (游戏和娱乐) 7、Miscellaneous (杂项) 8、Administrative Commands (管理员命令) 9 其他(Linux特定的), 用来存放内核例行程序的文档。

    n 新文档, 可能要移到更适合的领域。 o 老文档, 可能会在一段期限内保留。 l 本地文档, 与本特定系统有关的。

    例如:我们输入 man ls,它会在最左上角显示“LS(1)”,在这里,“LS”表示手册名称,而“(1)”表示该手册位于第一节章,同样,我们输入“man ifconfig”它会在最左上角显示“IFCONFIG(8)”。也可以这样输入命令:“man [章节号] 手册名称”。

    man是按照手册的章节号的顺序进行搜索的,比如: man sleep 只会显示sleep命令的手册,如果想查看库函数sleep,就要输入: man 3 sleep

    ubuntu默认是没有安装c语言的库函数man手册的

    1.添加库函数手册 ubuntu默认是没有安装c语言的库函数man手册的,所以你在man perror 和sendto之类的函数时会显示没有相关文档的问题,这个问题让我郁闷了我好久。解决方法: sudo apt-get install manpages-dev 2.让man显示中文 ubuntu源里面已经包含了中文的man包,所以不用从其他地方down了,直接 sudo apt-get install manpages-zh 但是这样man默认显示的还不是中文,还需要以下两步 a.把中文man包转换成utf8格式的 新建一个脚本文件 gedit t.sh 把下面内容添加进去 #!/bin/bashcd /usr/share/man/zh_CN/for k in *docd $kfor i in *.gzdo j=`echo ${i%.gz}` gunzip $i iconv -f gb18030 -t utf8 $j >tmp mv tmp $j gzip $jdonecd ..done 然后 sudo ./t b.修改man默认的语言 sudo gedit /etc/manpath.config 把里面的所有的 /usr/share/man 改成 /usr/share/man/zh_CN 保存后退出,然后你再试一下man ls 3.让没有中文帮助的显示英文 做完上面第二部还不够,这时你再man 一下一些c语言函数(不要用printf,socket之类比较有名的函数,这些已经有中文帮助了)的时候就会发现竟然没有帮助,而刚才明明在第一步已经安装了啊。这是因为你上面 把/usr/share/man 改成 /usr/share/man/zh_CN的操作使man只在中文帮助中搜索,如果没有就直接放弃,因此还需要以下操作,才能让man在没有中文帮助的时候自动显示英文的帮助,如果英文的也没有,哪就真的没有了。 sudo gedit /etc/manpath.config 然后搜索你刚才改过的地方,然后在其后面添加同样的一行,只是后面的目录还用原来的/usr/share/man,比如在修改后的 MANPATH_MAP /bin          /usr/share/man/zh_CN 再添加一行 MANPATH_MAP /bin          /usr/share/man

    新安装了ubuntu 8.04版本,发现安装过的系统中缺少很多手册页。 用以下命令搞定了 sudo apt-get install manpages

    sudo apt-get install manpages-de

    sudo apt-get install manpages-de-dev

    sudo apt-get install manpages-dev

    当我们在ubuntu下使用命令,常常需要用到man命令来帮助查看命令参数的意义。但是我们的英文水平不一,因此好多英文解释根本看不懂。

    比如用该命令查看 vi 的帮助,纯英文很难懂:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    root@iZ235o7pur2Z:~# man vi
    VIM(1)                                                                                                                                                                                                                          VIM(1)
     
    NAME
           vim - Vi IMproved, a programmers text editor
     
    SYNOPSIS
           vim [options] [file ..]
           vim [options] -
           vim [options] -t tag
           vim [options] -q [errorfile]
     
           ex
           view
           gvim gview evim eview
           rvim rview rgvim rgview
     
    DESCRIPTION
           Vim is a text editor that is upwards compatible to Vi.  It can be used to edit all kinds of plain text.  It is especially useful for editing programs.
     
           There  are  a  lot  of enhancements above Vi: multi level undo, multi windows and buffers, syntax highlighting, command line editing, filename completion, on-line help, visual selection, etc..  See ":help vi_diff.txt" for a
           summary of the differences between Vim and Vi.
     
           While running Vim a lot of help can be obtained from the on-line help system, with the ":help" command.  See the ON-LINE HELP section below.
     
           Most often Vim is started to edit a single file with the command
     
                vim file
     
           More generally Vim is started with:
     
                vim [options] [filelist]
     
           If the filelist is missing, the editor will start with

    其实ubuntu有man的中文包,只需几行命令安装配置即可显示中文帮助。命令如下:

    1
    2
    3
    apt-get install manpages-zh
    vi /etc/manpath.config
    :1,$s#/usr/share/man#/usr/share/man/zh_CN#g

    以上3行命令即可搞定。

    第一个命令:下载man帮助的中文包

    第二个命令:用vi编辑man的配置文件

    第三个命令:将所有的/usr/share/man替换为/usr/share/man/zh_CN,

    :1,$s#/usr/share/man#/usr/share/man/zh_CN#g

    说明:

    1.在用 vi 命令编辑文件,使用命令前先按:键,然后输入命令1,$s#/usr/share/man#/usr/share/man/zh_CN#g,回车即可

    2.替换第 1 行开始到最后一行中所有的 /usr/share/man 为 /usr/share/man/zh_CN

    这样配置好后,再次运行命令就能看到中文帮助了

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    root@iZ23pe9qfubZ:~# man vi
    VIM(1)                                                                                                                                                                                                                          VIM(1)
     
    NAME
           vim - Vi IMproved, 一个程序员的文本编辑器
     
    总览 (SYNOPSIS)
           vim [options] [file ..]
           vim [options] -
           vim [options] -t tag
           vim [options] -q [errorfile]
     
           ex
           view
           gvim gview
           rvim rview rgvim rgview
     
    描述 (DESCRIPTION)
           Vim 是 一个 同 Vi 向上兼容的 文本 编辑器, 可以 用来 编辑 任何 ASCII 文本, 特别 适合 用来 编辑 程序.
     
           它对 Vi 作了 许多 增强: 多层撤销, 多窗口, 多缓冲区(buffer), 高亮度 语法显示, 命令行编辑, 文件名匹配, 在线帮助, 可视选定, 等等. 用 ":help vi_diff.txt" 看 Vim 和 Vi 的差别 的 摘要.
     
           在运行 Vim 的时候 可以用 ":help" 命令 获得 很多 帮助.  参考 下面的 在线帮助 一节.
     
           一般 可用
     
                vim file
     
           命令 打开 Vim 来 编辑 一个 文件. 概括的说, 可以
  • 相关阅读:
    mac os programming
    Rejecting Good Engineers?
    Do Undergrads in MIT Struggle to Obtain Good Grades?
    Go to industry?
    LaTex Tricks
    Convert jupyter notebooks to python files
    How to get gradients with respect to the inputs in pytorch
    Uninstall cuda 9.1 and install cuda 8.0
    How to edit codes on the server which runs jupyter notebook using your pc's bwroser
    Leetcode No.94 Binary Tree Inorder Traversal二叉树中序遍历(c++实现)
  • 原文地址:https://www.cnblogs.com/dpf-learn/p/6208317.html
Copyright © 2020-2023  润新知