bash手册

man命令

man命令用来访问存储在Linux系统上的手册页面。在想要查找的工具的名称前面输入man命令,就可以找到那个工具相应的手册条目。

man man

窍门:bash手册甚至包含了一份有关其自身的参考信息。输入man man来查看与手册页相关的手册页。

根据上面的提示,我在控制台终端输入这行代码:

root@huangzihan:/# man man

然后它弹出这样一个页面:

MAN(1)                                                    Manual pager utils                                                   MAN(1)

NAME
man - an interface to the system reference manuals SYNOPSIS
man [man options] [[section] page ...] ...
man -k [apropos options] regexp ...
man -K [man options] [section] term ...
man -f [whatis options] page ...
man -l [man options] file ...
man -w|-W [man options] page ... 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 (see DEFAULTS), and to show only the first page found, even if page exists in several sections.
...
...
...

如果我们想退出这个页面,直接按q键就可以。然后我又查了我平时用的那条ls指令,整个过程代码如下:

root@huangzihan:/# man ls

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 is specified. Mandatory arguments to long options are mandatory for short options too. -a, --all
do not ignore entries starting with . ...
...
...

窍门:如果你是新接触bash shell,可能一开始会觉得手册页面并不太用。但是如果养成了阅读手册的习惯,尤其是阅读第一段或是DESCRIPTION部分的前两段,最终你会学到各种技术行话,手册页也会变得越来越有用。

分页程序(page)

当使用man命令查看命令手册的时候,这些手册页是由分页程序(page)来显示的。分页程序是一种实用工具,能够逐页显示文本。可以通过点击空格键进行翻页,或是使用回车键逐行查看。另外还可以使用箭头键向前向后滚动手册页的内容(假设你用的终端仿真软件包支持箭头键功能)。

在分页程序最下面的一行有这样一条语句:

 Manual page ls(1) line 1/218 15% (press h for help or q to quit)

当我们使用回车键和箭头键向前向后的时候,这句话在中的1/218的1不断地增加。

读完了手册页,可以点击q键退出。退出手册页之后,你会重新获得shell CLI提示符,这表示shell正在等待接受下一条命令。

手册页将与命令相关的信息分成了不同的节。每一节惯用的命名标准如表Linux手册页惯用的节名

Linux手册页惯用的节名

描述
Name 显示命令名和一段简短的描述
Synopsis 命令的语法
Confi guration 命令配置信息
Description 命令的一般性描述
Options 命令选项描述
Exit Status 命令的退出状态指示
Return Value 命令的返回值
Errors 命令的错误消息
Environment 描述所使用的环境变量
Files 命令用到的文件
Versions 命令的版本信息
Conforming To 命令所遵从的标准
Notes 其他所遵从的标准
Bugs 提供提交bug的途径
Example 展示命令的用法
Authors 命令开发人员的信息
Copyright 命令源代码的版权状况
See Also 与该命令类型的其他命令

窍门:如果不记得命令名怎么办?可以使用关键字搜索手册页。语法是:man -k 关键字。例如,要查找与终端相关的命令,可以输入man -k terminal。

除了对节按照惯例进行命名,手册页还有对应的内容区域。每个内容区域都分配了一个数字,从1开始,一直到9,如下表Linux手册页的内容区域

Linux手册页的内容区域

区域号 所涵盖的内容
1 可执行程序或shell命令
2 系统调用
3 库调用
4 特殊文件
5 文件格式与约定
6 游戏
7 概览、约定及杂项
8 超级用户和系统管理员命令
9 内核例程
查看命令在Linux手册页中的区域

man工具通常提供的是命令所对应的最低编号的内容。

当我在命令行输入man ls,在弹出来的分页程序中的第一行和最后一行,发现这两条语句中的LS和ls后面的括号有一个数字:(1)。这表示所显示的手册页来自内容区域1(可执行程序或shell命令)

LS(1)                  User Commands                         LS(1)
Manual page ls(1) line 1/218 15% (press h for help or q to quit)

一个命令偶尔会在多个内容区域都有对应的手册页。比如说,有个叫作hostname的命令。手册页中既包括该命令的相关信息,也包括对系统主机名的概述。想要查看所需要的页面,可以输入man section# topic。对手册页的第一部分而言,就是输入man 1 hostname。对于手册页中的第7部分,就是输入man 7 hostname

我根据上面的提示分别打开了hostname的第1部分和第7部分,部分代码如下:

root@huangzihan:/# man 1 hostname
HOSTNAME(1) Linux Programmer's Manual HOSTNAME(1) NAME
hostname - show or set the system's host name
domainname - show or set the system's NIS/YP domain name
ypdomainname - show or set the system's NIS/YP domain name
nisdomainname - show or set the system's NIS/YP domain name
dnsdomainname - show the system's DNS domain name ...
...
...
root@huangzihan:/# man 7 hostname
HOSTNAME(7) Linux Programmer's Manual HOSTNAME(7) NAME
hostname - hostname resolution description
...
...
...

你也可以只看各部分内容的简介:输入man 1 intro阅读第1部分,输入man 2 intro阅读第2部分,输入man 3 intro阅读第3部分,等等。

根据上面的提示,我在提示符#后面分别输入man 1 introman 7 intro,控制台终端的输出如下:

root@huangzihan:/# man 1 intro
INTRO(1) Linux User's Manual INTRO(1) NAME
intro - introduction to user commands
...
...
...
root@huangzihan:/# man 7 intro
INTRO(7) Linux Programmer's Manual INTRO(7) NAME
intro - introduction to overview and miscellany section
...
...
...

当我想查看ls的第2部分、第3部分、第4部分,在shell提示符#后面分别输入man 2 lsman 3 lsman 4 ls,但是因为ls这条命令没有这三部分,所以控制台终端输出是这样的:

root@huangzihan:/# man 2 ls
No manual entry for ls in section 2
root@huangzihan:/# man 3 ls
No manual entry for ls in section 3
root@huangzihan:/# man 4 ls
No manual entry for ls in section 4

info页面

手册页不是唯一的参考资料。还有另一种叫作info页面的信息。可以输入info info来了解info页面的相关内容。

根据上面的提示,我在提示符#后面输入info info,控制台终端的输出如下:

Next: Stand-alone Info,  Up: (dir)

Stand-alone GNU Info
******************** This documentation describes the stand-alone Info reader which you can
use to read Info documentation.
...
...
...

如果想查看ls的info页面,我们可以把上面那条命令改为info ls,对应的控制台的输出为:

root@huangzihan:/# info ls
Next: dir invocation, Up: Directory listing 10.1 ‘ls’: List directory contents
================================== The ‘ls’ program lists information about files (of any type, including
directories). Options and file arguments can be intermixed arbitrarily,
as usual.
...
...
...

help帮助

另外,大多数命令都可以接受-help--help选项。例如你可以输入hostname -help来查看帮助。关于帮助的更多信息,可以输入help help。(看出这里面的门道没?)

根据上面的提示,我在shell提示符#后面输入help help,对应的控制台终端输出是这样的:

root@huangzihan:/# help help
help: help [-dms] [pattern ...]
Display information about builtin commands. Displays brief summaries of builtin commands. If PATTERN is
specified, gives detailed help on all commands matching PATTERN,
otherwise the list of help topics is printed. ...
...
...

如果想查看ls命名,可以在shell提示符#后面输入ls --help,这个查看ls的命令只有这个是对的,中途我还输错了几次,整个过程代码是这样的:

root@huangzihan:/# ls -help
ls: invalid option -- 'e'
Try 'ls --help' for more information.
root@huangzihan:/# ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
...
...
...

bash手册的更多相关文章

  1. bash手册 之重定向原理与实现

    http://www.gnu.org/software/bash/manual/bashref.html#Redirections http://www.cnblogs.com/weidagang20 ...

  2. bash帮助文档简单学习;bash手册翻译

    关于bash的四种工作方式的不同,可以参考:http://feihu.me/blog/2014/env-problem-when-ssh-executing-command-on-remote/,但是 ...

  3. Linux编程 3 (初识bash shell与man查看手册)

    一.初识bash shell 1.1 启动 shell   GNU bash shell 能提供对Linux系统的交互式访问.通常是在用户登录终端时启动,登录时系统启动shell依赖于用户账户的配置. ...

  4. 基本bash命令

    bash手册 输入man命令可以访问存储在linux系统上的手册页面.  如果不记得命令名,可以使用关键字搜索手册.语法是man -k 关键字.  手册被分为了不同的内容区域.man工具提供的是命 ...

  5. bash脚本编程之二 字符串测试及for循环

    shell中大量的测试和比较选项而困惑呢? 这个技巧可以帮助您解密不同类型的文件.算术和字符串测试,这样您就能够知道什么时候使用 test. [ ]. [[ ]].(( )) 或 if-then-el ...

  6. Linux命令行–基本的bash shell命令

    启动shell: /etc/passwd:包含系统用户账户列表以及每个用户的基本配置信息 每个条目有七个字段,每个字段用冒号隔开 用户名 用户密码 用户的系统UID 用户的系统GID 用户的全名 用户 ...

  7. 【转】Linux 技巧: Bash 参数和参数扩展

    重点看下清单7 现在,很多 Linux® 和 UNIX® 系统上都有 bash shell,它是 Linux 上常见的默认 shell.通过本文,您将了解到如何在 bash 脚本中处理参数和选项,以及 ...

  8. 【深夜急报,Win10下的Linux子系统之Bash】

    [在Windows下进行的编程人员,你真的需要学习下Linux] 手册:<Linux 命令手册(特洛伊版2.0)> 链接: https://pan.baidu.com/s/1skrVSvV ...

  9. 了解基本的bash shell命令

    本节内容主要介绍如何使用bash shell提供的基本命令处理Linux文件和目录: 1.启动shell shell是一个可以交互访问的Linux系统程序,它的运行与普通程序相同,系统启动的shell ...

随机推荐

  1. cs_play

    # -*-coding:utf-8-*-__author__ = "logan.xu"###构造函数#class Role:# n = 123# # 类变量 比如 n = 123# ...

  2. 免费 CDN 玩法 —— 将整个网站打包成一个图片文件

    资源合并 前端开发者都知道,过多的请求对性能影响很大.而且有些 CDN 不仅按流量收费,请求数也收费,如果网页里有大量小文件,显然不划算. 为此不少开发者将零碎的小文件进行合并优化,例如 JS/CSS ...

  3. 服务器安装CentOS7.9系统(U盘启动方式)

    一.安装环境 机房的华为GPU服务器,型号G2500,8张P4显卡,需要安装最小化的CentOS7.9操作系统,利用U盘启动的方式进行安装. 二.安装说明 虽然本环境是GPU服务器,但是安装方式同样适 ...

  4. MongoDB(10)- 查询嵌套文档

    插入测试数据 db.inventory.insertMany( [ { item: "journal", qty: 25, size: { h: 14, w: 21, uom: & ...

  5. 第06课:GDB 常用命令详解(中)

    本课的核心内容: info 和 thread 命令 next.step.util.finish.return 和 jump 命令 info 和 thread 命令 在前面使用 info break 命 ...

  6. 写了一年golang,来聊聊进程、线程与协程

    本文已收录 https://github.com/lkxiaolou/lkxiaolou 欢迎star. 进程 在早期的单任务计算机中,用户一次只能提交一个作业,独享系统的全部资源,同时也只能干一件事 ...

  7. ysoserial CommonsColletions4分析

    ysoserial CommonsColletions4分析 其实CC4就是 CC3前半部分和CC2后半部分 拼接组成的,没有什么新的知识点. 不过要注意的是,CC4和CC2一样需要在commons- ...

  8. Linux的bg和fg和jobs和nohup命令简单介绍

    我们都知道,在 Windows 上面,我们要么让一个程序作为服务在后台一直运行,要么停止这个服务.而不能让程序在前台后台之间切换.而 Linux 提供了 fg 和 bg 命令,让我们轻松调度正在运行的 ...

  9. Nginx:进程调度

    Blog:博客园 个人 Nginx采用的是固定数量的多进程模型,由一个主进程(MasterProcess)和数量与主机CPU核数相同的工作进程协同处理各种事件. 主管理进程负责工作进程的配置加载.启停 ...

  10. Vue组件封装之无限滚动列表

    无限滚动列表:分为单步滚动和循环滚动两种方式 <template> <div class="box" :style="{width:widthX,hei ...