1 概述
当我们不知道命令该如何使用,或者不记得命令拼写或他的参数用法时,借助系统的帮助文档是一个非常便捷和有效的方法。
- 当只记得部分命令关键字时,可以通过man -k来搜索
- 需要查询命令的简要说明,可以使用whatis,需要详细的介绍使用info
- 查看命令在哪个位置,使用which,whereis
- 查询命令的具体参数及其使用方法,就需要使用强大的man
2 命令使用
- 查询命令
[aaron@localhost ~]$ whatis vmstat vmstat (8) - Report virtual memory statistics [aaron@localhost ~]$ whatis -w "netst*" netstat (8) - Print network connections, routing tables, interface statistic... [aaron@localhost ~]$ info df File: coreutils.info, Node: df invocation, Next: du invocation, Up: Disk usage 14.1 'df': Report file system disk space usage ============================================== 'df' reports the amount of disk space used and available on file systems. Synopsis: df [OPTION]... [FILE]...
- 查看路径
[aaron@localhost ~]$ which man /usr/bin/man [aaron@localhost ~]$ whereis man man: /usr/bin/man /usr/share/man /usr/share/man/man1/man.1.gz /usr/share/man/man1p/man.1p.gz /usr/share/man/man7/man.7.gz [aaron@localhost ~]$
- man命令
在man的帮助手册中,将帮助文档分为了9个类别,对于有的关键字可能存在多个类别中, 我们就需要指定特定的类别来查看;(一般我们查询bash命令,归类在1类中);
man页面所属的分类标识(常用的是分类1和分类3)
- 用户可以操作的命令或者是可执行文件
- 系统核心可调用的函数与工具等
- 一些常用的函数与数据库
- 设备文件的说明
- 设置文件或者某些文件的格式
- 游戏
- 惯例与协议等。例如Linux标准文件系统、网络协议、ASCⅡ,码等说明内容
- 系统管理员可用的管理条令
- 与内核有关的文件
使用whatis会显示命令所在的具体的文档类别。
[aaron@localhost ~]$ whatis free free (3) - allocate and free dynamic memory free (1) - Display amount of free and used memory in the system free (3p) - free allocated memory [aaron@localhost ~]$ man 1 free FREE(1) User Commands FREE(1) NAME free - Display amount of free and used memory in the system ... [aaron@localhost ~]$ man 3 free MALLOC(3) Linux Programmer's Manual MALLOC(3) NAME malloc, free, calloc, realloc - allocate and free dynamic memory SYNOPSIS #include <stdlib.h> void *malloc(size_t size); void free(void *ptr); void *calloc(size_t nmemb, size_t size); void *realloc(void *ptr, size_t size); ....
当只记得部分命令时,可以通过man -k 来查询
[aaron@localhost ~]$ man -k netst netstat (8) - Print network connections, routing tables, interface statistic... [aaron@localhost ~]$