Linux基础知识之man手册的使用

摘要:
在Linux中,应该经常使用man。灵活使用它可以帮助您快速掌握陌生命令的用法。关键字:使用关键字指定的字符串作为关键字,从当前接口的位置搜索到文件的开头;不区分大小写的字符n:遵循与收缩命令相同的方向,下一个n:遵循搜索命令的相反方向,最后一次未阅读手册时,q是退出man的实际应用程序。下面是一个通过实际问题说明man功能的示例:当字符终端登录时,当前登录终端编号,显示主机名和当前时间。

在Linux中man的使用频率应该是很高的,灵活运用它可以让自己快速的掌握一个不熟悉命令的使用方法。下面来介绍下man

环境CentOS6.8

man - format and display the on-line manual pages 在线使用手册格式及展示
通俗点来说它就是命令的使用手册。
它共分九个章节

1、用户命令
2、系统调用
3、C库调用
4、设备文件及特殊文件
5、配置文件格式
6、游戏
7、杂项
8、管理命令及守护进程
9、Linux内核API(CentOS7以后出现)
之所以分这九个章节是应为有的命令分属不同类,查看命令具体属于man中的哪个章节需要使用命令
whatis COMMAND

下面就命令echo为例来具体说明man的手册内容
#whatis echo 
echo                (1)  - display a line of text 
echo                (1p)  - write arguments to standard output 
echo [builtins]      (1)  - bash built-in commands, see bash(1)

从上面可以看出来echo属于man的第一章节
下面从具体的man 1 echo中解释具体每项的意义
#man 1 echo 
NAME    命令名称及功能简要说明 
      echo - display a line of text 
  
SYNOPSIS      用法说明,包括可用的选项 
      echo [SHORT-OPTION]... [STRING]... 
      echo LONG-OPTION 
  
      <>:此符号内为必给内容 
      []:此符号内为可选内容 
      |:此符号表示多选一 
        {}:此符号表示为分组 
...:同一内容出现多次 
  
DESCRIPTION    命令功能的详尽说明,可能包括每一项的意义 
      Echo the STRING(s) to standard output. 
  
      -n    do not output the trailing newline 
  
      -e    enable interpretation of backslash escapes 
  
      -E    disable interpretation of backslash escapes (default) 
  
      --help display this help and exit
  
      --version 
              output version information and exit
      . 
      . 
      . 
AUTHOR        作者 
      Written by Brian Fox and Chet Ramey. 
  
REPORTING BUGS  报告程序bug的方式 
      Report echo bugs to bug-coreutils@gnu.org 
      GNU coreutils home page: <http://www.gnu.org/software/coreutils/> 
      General help using GNU software: <http://www.gnu.org/gethelp/> 
      Report echo translation bugs to <http://translationproject.org/team/> 
  
COPYRIGHT    版权声明 
      Copyright    2010  Free Software Foundation, Inc.  License GPLv3+: GNU 
      GPL version 3 or later <http://gnu.org/licenses/gpl.html>. 
      This is free software: you are free  to  change  and  redistribute  it. 
      There is NO WARRANTY, to the extent permitted by law. 
  
SEE ALSO  另外参照 
      The  full documentation for echo is maintained as a Texinfo manual.  If 
      the info and echo programs are properly installed  at  your  site,  the 
      command
  
              info coreutils 'echo invocation'
  
      should give you access to the complete manual.

有的命令中还有OPTIONS(说明每一个选项的意义)、FILES(此命令相关的配置文件)、ARGUMENTS(命令的作用对象),大致有上面这几项。

    man命令中的快捷键,便于查看文本信息

enter return键:向后翻一行        k:向前翻一行

ctrl+d :向文件尾部翻半屏          ctrl+u:向文件首部翻半屏
G:跳至最后一行                    #G:跳转至指定行,#表示行号

    man查找,用于在man手册中快速定位需要的信息
/keyword:以keyword指定的字符串为关键字,从当前界面所在位置向文件尾部搜索;不区分字符大小写
n:下一个            N:上一个


?keyword:以keyword指定的字符串为关键字,从当前界面所在位置向文件首部搜索;不区分字符大小写
n:跟收缩命令同方向,下一个      N:跟搜索命令反向,上一个

  当不看man手册时q为退出

    man的实际应用
下面通过一个实际的问题,来说明man的作用

例子:字符终端登陆时,显示当前登陆终端号,主机名和当前时间。
要求使用man查找实现上述要求,提示:修改/etc/issue文件。怎么修改可以通过man查看issue求助。
我们先用cat看下/etc/issue文件

# cat /etc/issue 
CentOS release 6.8 (Final) 
Kernel on an m

之后我们
man issue

Formatting page, please wait... 
ISSUE(5)                  Linux Programmer’s Manual                  ISSUE(5) 
  
NAME 
      issue - pre-login message and identification file
  
DESCRIPTION 
      The  file  /etc/issue is a text file which contains a message or system 
      identification to be printed before the login prompt.  It  may  contain 
      various  @char and char sequences, if supported by the getty-type pro- 
      gram employed on the system. 
  
FILES 
      /etc/issue
  
SEE ALSO 
      motd(5), agetty(8), mingetty(8) 
  
COLOPHON 
      This page is part of release 3.22 of the Linux  man-pages  project.  A 
      description  of  the project, and information about reporting bugs, can 
      be found at http://www.kernel.org/doc/man-pages/. 
  
Linux                            1993-07-24                          ISSUE(5)

查看之后发现找不到一点有价值的信息,不过在最后提示我们可以查看motd、agetty、mingetty这三个文件。
man motd 
MOTD(5)                    Linux Programmer’s Manual                  MOTD(5) 
  
NAME 
      motd - message of the day 
  
DESCRIPTION 
      The  contents of /etc/motd are displayed by login(1) after a successful 
      login but just before it executes the login shell. 
  
      The abbreviation "motd" stands for "message of the day", and this  file
      has  been  traditionally  used  for exactly that (it requires much less
      disk space than mail to all users). 
  
FILES 
      /etc/motd
  
SEE ALSO 
      login(1), issue(5) 
  
COLOPHON 
      This page is part of release 3.22 of the Linux  man-pages  project.  A 
      description  of  the project, and information about reporting bugs, can 
      be found at http://www.kernel.org/doc/man-pages/. 
  
Linux                            1992-12-29                          MOTD(5)

motd里面也没有值得我们参考的信息,继续下一个
man agentty 
AGETTY(8)                                                            AGETTY(8) 
  
NAME 
      agetty - alternative Linux getty 
  
SYNOPSIS 
      agetty  [-8ihLmnUw]  [-f  issue_file]  [-l login_program] [-I init] [-t 
      timeout] [-H login_host] port baud_rate,...  [term] 
      agetty [-8ihLmnw] [-f issue_file]  [-l  login_program]  [-I  init]  [-t 
      timeout] [-H login_host] baud_rate,...  port [term] 
  
DESCRIPTION 
      agetty  opens  a  tty  port,  prompts  for a login name and invokes the 
      /bin/login command. It is normally invoked by init(8). 
  
      agetty has several non-standard features that are useful for hard-wired 
      and for dial-in lines: 
  
      o      Adapts  the tty settings to parity bits and to erase, kill, end- 
              of-line and uppercase characters when it  reads  a  login  name. 
              The  program can handle 7-bit characters with even, odd, none or 
              space parity, and 8-bit characters with no parity. The following 
              special  characters  are  recognized: @ and Control-U (kill); #, 
              DEL and back space (erase); carriage return and line  feed  (end 
              of line).  See also --erase-chars and --kill-chars options. 
  
      o      Optionally  deduces the baud rate from the CONNECT messages pro- 
              duced by Hayes(tm)-compatible modems. 
              ... 
              .. 
              .

由于这个手册内容很多,所以我们使用/issue快速找到关于/etc/issue的相关内容作为参考。
connection and turn on auto-answer after 1 ring.) 
            /sbin/agetty -w -I ’ATE0Q1&D2&C1S0=1

免责声明:内容来源于网络,仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇PhpStorm添加PHP代码规范检查CodeSniffer(phpcs)和PHP代码静态分析工具Mess Detector(phpmd)动态查询:getBy字段名下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

安装cfssl证书工具

安装版本 cfssl 1.2 https://pkg.cfssl.org/R1.2/cfssl_linux-amd64 https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64 https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64 下载安装包 wget http...

Linux下安装Maven

maven是现在比较流行的一种,现在记录下Linux下Maven的安装过程。 1、准备工作: 可以直接从maven官网下载,链接地址:https://www.apache.org/dist/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz,然后在手动copy到服务器中。 如果感觉麻烦,可以...

关于生产环境linux系统中的wheel用户组

本文系统环境:CentOS Linux release 7.7.1908 (Core) 一般来说,目前linux系统中的wheel组,默认情况是没有使用到的、 如果要使用wheel组,让其有具体的作用,需要结合/etc/pam.d/su文件配置 很多在Linux中为了更进一步加强系统的安全性,都有一个管理员的组, 只允许这个组的用户来执行su - xxx...

【Qt开发】Linux下Qt开发环境的安装与集成

近期工作需要在Linux下用Qt进行C++开发,所以就在linux下尝试装QT开发环境。本人用的linux是CentOS 6.5。现在对安装过程做出总结。有两种安装方式,下面分别详述: 1 图形化安装 1.1 安装包的下载与获取       到http://www.qt.io/download-open-source/#section-7链接下载。这个...

在Linux下执行Jmeter脚本

前言 Jmeter这款接口测试工具,已经在越来越多的公司被要求会使用了。 而且,现在应该部分小伙伴们都开始用起来了。 但是,你们知道除了在Windows用图形化界面的Jmeter执行脚本之外,还有其他可以执行的方法吗?? 今天就来告诉你们,如何在Linux服务器里执行Jmeter的jmx。 前提准备: 1.Linux下安装好JDK 2.在Windows下使...

【Linux】ArchLinux 使用之旅

主要参考以下两个链接进行,安装系统和安装桌面环境。以官方Wiki的方式安装ArchLinux | viseator's blog ArchLinux安装后的必须配置与图形界面安装教程 | viseator's blog 期间遇到的问题: 无法使用sudos在root用户下,编辑文件 /etc/sudoers删除 %wheel ALL=(ALL)ALL...