在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 \r 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\015’ 115200 ttyS1 
  
ISSUE ESCAPES 
      The issue-file (/etc/issue or the file set with the -f option) may con- 
      tain certain escape codes to display the system  name,  date  and  time
      etc.  All  escape codes consist of a backslash (\) immediately followed 
      by one of the letters explained below. 
  
      b      Insert the baudrate of the current line. 
  
      d      Insert the current date. 
  
      s      Insert the system name, the name of the operating system. 
  
      l      Insert the name of the current tty line. 
  
      m      Insert the architecture identifier of the machine, eg. i486 
  
      n      Insert the nodename of the machine, also known as the  hostname. 
  
      o      Insert the NIS domainname of the machine. 
  
      O      Insert the DNS domainname of the machine. 
  
      r      Insert the release number of the OS, eg. 1.1.9. 
  
      t      Insert the current time. 
  
      u      Insert the number of current users logged in. 
  
      U      Insert  the string "1 user" or "<n> users" where <n> is the num- 
              ber of current users logged in. 
  
      v      Insert the version of the OS, eg. the build-date etc. 
  
      Example: On my system, the following /etc/issue file: 
  
              This is \n.\o (\s \m \r) \t 
  
      displays as 
  
              This is thingol.orcan.dk (Linux i386 1.1.9) 18:29:30

这里我们找到\l可以解决显示当前登陆终端号问题,\n解决主机名问题,\t解决时间显示问题。既然找到了,那我们尝试修改/etc/issue文件。
#vi /etc/issue 
CentOS release 6.8 (Final) 
Kernel \r on an \m 
\l        
\n 
time is \t

wq保存退出。
logout

显示如下

问题解决。

man的使用需要大家在平时的使用中慢慢摸索这样才会越用越得心应手。希望大家看了又所帮助。

Linux基础知识之man手册的使用的更多相关文章

  1. 运维之linux基础知识(一)

    运维之linux基础知识(一) 1.GUI:Graphic User Interface 图形用户界面 2.CLI:Command line Interface 命令行界面 3 dll:Dynamic ...

  2. 系统和帮助-Linux基础知识

    iOS镜像: 硬盘分区:留出一些空间;实在不成,可安装完成以后,新增一块虚拟硬盘; 终端:terminal 用户界面: GUI:图形界面 GNome KDE CLI: bash,zsh,sh,csh, ...

  3. Linux基础知识入门

    [Linux基础]Linux基础知识入门及常见命令.   前言:最近刚安装了Linux系统, 所以学了一些最基本的操作, 在这里把自己总结的笔记记录在这里. 1,V8:192.168.40.10V1: ...

  4. 运维之Linux基础知识(三)

    运维之Linux基础知识(三) 1. 查看文本 cat tac more less head tail 1.1 cat 连接并显示文件 cat -n:在显示的时候,将每一行编号 -E:显示结束符$ - ...

  5. Linux基础知识梳理

    Linux基础知识梳理 Linux内核最初只是由芬兰人林纳斯?托瓦兹(Linus Torvalds)在赫尔辛基大学上学时出于个人爱好而编写的.Linux是一套免费使用和自由传播的类Unix操作系统,是 ...

  6. Linux基础知识第九讲,linux中的解压缩,以及软件安装命令

    目录 Linux基础知识第九讲,linux中的解压缩,以及软件安装命令 一丶Linux Mac Windows下的压缩格式简介 2.压缩以及解压缩 3.linux中的软件安装以及卸载 1.apt进行安 ...

  7. Linux基础知识第八讲,系统相关操作命令

    目录 Linux基础知识第八讲,系统相关操作命令 一丶简介命令 2.磁盘信息查看. 3.系统进程 Linux基础知识第八讲,系统相关操作命令 一丶简介命令 时间和日期 date cal 磁盘和目录空间 ...

  8. Linux基础知识第七讲,用户权限以及用户操作命令

    目录 Linux基础知识第七讲,用户权限以及用户操作命令 一丶简介linux用户,用户权限,组的概念. 1.1 基本概念 1.2 组 1.3 ls命令查看权限. 二丶用户权限修改命令 1.chmod ...

  9. Linux基础知识第六讲,远程管理ssh操作

    目录 Linux基础知识第六讲,远程管理ssh操作 一丶什么是SSH 1.什么是SSH 2.了解域名跟端口 二丶SSH命令以及远程连接linux进行维护 1.ssh命令格式 2.scp远程终端拷贝文件 ...

随机推荐

  1. [hihoCoder] #1089 : 最短路径·二:Floyd算法

    时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 万圣节的中午,小Hi和小Ho在吃过中饭之后,来到了一个新的鬼屋! 鬼屋中一共有N个地点,分别编号为1..N,这N个地点之间 ...

  2. iptables的4表5链(未完)

    iptables中共4张表:filter,nat,raw,mangle,其中默认表为filter如:iptables -A -p tcp -j ACCEPT 等价于 iptables -t filte ...

  3. Let's call it a "return"

    Preface Long time no see. For some reason that I failed to keep updating this blog, which is really ...

  4. 黑客编程教程(六)Windows的关机和重起

    第六节 Windows的关机和重起 很多木马都有远程关机功能,但这并不是一个很好的功能.不过对于入侵服务器,有时需要重起服务器.其实对于关机和重起,只需要调用几个 API函数即可实现. 对于WIN9X ...

  5. 用C++画光(二)——矩形

    在上篇文章的基础上,做了许多调整,修复了许多BUG.在解决bug的过程中,我逐渐领悟到一个要领:枯燥地一步步调试太痛苦了,找不到问题的根源!所以我选择将中间结果打到图片上.如: (注意,里面的点是我随 ...

  6. CAsyncSocket编程 MFC

    许多时候我们实现网络编程使用的是winsock api函数,虽然这些函数使用起来也很方便,很灵活,但是VC++的MFC类库中提供了CAsyncSocket这样一个套接字类,用它来实现socket编程会 ...

  7. 在eclipse中执行sql

    只要你配置好了你的database(在Data Source Explorer中,可以通过window->show view打开) 写好你的sql script,然后配置好profile 右键, ...

  8. FreeRTOS 低功耗之待机模式

    STM32F103 如何进入待机模式在 FreeRTOS 系统中,让 STM32 进入待机模式比较容易,调用固件库函数PWR_EnterSTANDBYMode 即可. STM32F103 如何退出待机 ...

  9. Ubuntu 16.04和win10双系统时间不一致解决办法

    windows10和ubuntu16.04双系统,装完后,在windows下时间不对,之前的老办法是: sudo gedit /etc/default/rcS 2 utc=yes 改成utc=no 然 ...

  10. JAVA-JSP之taglib指令

    相关资料:<21天学通Java Web开发>http://blog.csdn.net/dyyaries/article/details/9960987 备注:这个实例我没有跑起来,我看的是 ...