首页 > 编程笔记

Linux man命令的用法

通过 man(manual:手册)命令可以快速查询其他每个 Linux 命令的详细描述和使用方法。

man 手册一般保存在 /user/share/man 目录下,它是最常见的帮助命令,也是 Linux 最主要的帮助命令。

man 命令格式如下:

[root@bogon ~]# man [选项] 命令

[ ] 括号括起来的部分为可选参数,可以省略不用。

man 命令常用的选项为:
【例 1】man 命令的使用。
在终端页面中输入命令如下:

[root@bogon ~]# man ls
Formatting page, please wait...

随即,会进入如下界面:

LS(1)                            User Commands                           LS(1)

NAME
       ls - list directory contents

SYNOPSIS
       ls [OPTION]... [FILE]...

DESCRIPTION
       List  information  about  the FILEs (the current directory by default).
       Sort entries alphabetically if none of -cftuvSUX nor --sort.

       Mandatory arguments to long options are  mandatory  for  short  options
       too.

       -a, --all
              do not ignore entries starting with .

       -A, --almost-all
              do not list implied . and ..

       --author
              with -l, print the author of each file
:

在执行 man 命令时,命令的开头会有一个数字标识这个命令的帮助级别。例如:LS(1) User Commands LS(1),其中 LS(1) 中的“1”表示这是 ls 的 1 级别的帮助信息。

man 命令的帮助级别及功能如表 1 所示。

表 1 man 命令的帮助级别及功能
级 别 功 能
1 用户命令:普通用户可以使用的系统命令
2 内核可以调用的函数和工具的帮助
3 C语言函数的帮助
4 设备和特殊文件的帮助
5 文件的说明,查询命令的文件说明
6 游戏的帮助(个人版的 Linux 中是有游戏的)
7 杂项的帮助
8 管理命令:查询只有 Linux 系统的管理员 root 用户可以使用的命令说明
9 内核的帮助

优秀文章