Linux - Getting Help

Part 1: man Pages

As previously mentioned, UNIX was the operating system from which the Linux foundation was built. The developers of UNIX created help documents called man pages (man stands for manual).

Man pages are used to describe the features of commands. They will provide you with a basic description of the purpose of the command, as well as provide details regarding the options of the command.

1. Viewing man pages

To view a man page for a command, execute man command in a terminal window. For example, the command man cal will display the man page for thecal command:

2. Controlling the man Page Display

The man command uses a "pager" to display documents. Normally this pager is the less command, but on some distributions it may be the more command.

If you want to view the various movement commands that are available, you can type the letter h while viewing a man page. This will display a help page (note: If you are working on a Linux distribution that uses the more command as a pager, your output will be different than the example shown here):

If your distribution uses the less command, you might be a bit overwhelmed with the large number of "commands" that are available. The following table provides a summary of the more useful commands:

Command Function
Return (or Enter) Go down one line
Space Go down one page
/term Search for term
n Find next search item
1G Go to beginning
G Go to end
h Display help
q Quit man page

3. Sections of the man Page

Man pages are broken into sections. Each section is designed to provide specific information about a command. While there are common sections that you will see in most man pages, some developers also create sections that you will only see in a specific man page.

The following table describes some of the more common sections that you will find in man pages:

Section name Purpose
NAME Provides the name of the command and a very brief description.
SYNOPSIS Provides examples of how the command is executed. See below for more information.
DESCRIPTION Provides a more detailed description of the command.
OPTIONS Lists the options for the command as well as a description of how they are used. Often this information will be found in the DESCRIPTION section and not in a separate OPTIONS section.
FILES Lists the files that are associated with the command as well as a description of how they are used. These files may be used to configure the command‘s more advanced features. Often this information will be found in the DESCRIPTION section and not in a separate OPTIONS section.
AUTHOR The name of the person who created the man page and (sometimes) how to contact the person.
REPORTING BUGS Provides details on how to report problems with the command.
COPYRIGHT Provides basic copyright information.
SEE ALSO Provides you with an idea of where you can find additional information. This also will often include other commands that are related to this command.

Part 2: man Pages Categrized by Sections

Until now, we have been displaying man pages for commands. However, sometimes configuration files also have man pages. Configuration files (sometimes called system files) contain information that is used to store information about the Operating System or services.

Additionally, there are several different types of commands (user commands, system commands, and administration commands) as well as other features that require documentation, such as libraries and Kernel components.

As a result, there are thousands of man pages on a typical Linux distribution. To organize all of these man pages, the pages are categorized by sections, much like each individual man page is broken into sections.

By default there are nine default sections of man pages:

  1. Executable programs or shell commands
  2. System calls (functions provided by the kernel)
  3. Library calls (functions within program libraries)
  4. Special files (usually found in /dev)
  5. File formats and conventions, e.g. /etc/passwd
  6. Games
  7. Miscellaneous (including macro packages and conventions), e.g.man(7)groff(7)
  8. System administration commands (usually only for root)
  9. Kernel routines [Non standard]

When you use the man command, it searches each of these sections in order until it finds the first "match". For example, if you execute the command man cal, the first section (Executable programs or shell commands) is searched for a man page called cal. If not found, then the second section is searched. If no man page is found after searching all sections, you will receive an error message:

1. Determining Which Section

To determine which section a specific man page belongs to, look at the numeric value on the first line of the output of the man page. For example, if you execute the command man cal, you will see that the cal command belongs to the first section of man pages:

2. Sepcifying a Section

In some cases you will need to specify the section in order to display the correct man page. This is necessary because sometimes there will be man pages with the same name in different sections.

For example, there is a command called passwd that allows you to change your password. There is also a file called passwd that stores account information. Both the command and the file have a man page.

The passwd command is a "user" command, so the command man passwd will display the man page for the passwd command by default:

To specify a different section, provide the number of the section as the first argument of the man command. For example, the command man 5 passwd will look for the passwd man page just in section 5:

3. Searching Sections

Sometimes it isn‘t clear what section a man page is stored in. In cases like this, you can search for a man page by name.

The -f option to the man command will display man pages that match, or partially match, a specific name and provide a brief description of each man page:

Note that on most Linux distributions, the whatis command does the same thing as man -f. On those distributions, both will produce the same output.

4. Searching man Pages by Keyword

Unfortunately, you won‘t always remember the exact name of the man page that you want to view. In these cases you can search for man pages that match a keyword by using the -k option to the man command.

For example, what if you knew you wanted a man page that displays how to change your password, but you didn‘t remember the exact name? You could run the command man -k password:

When you use this option, you may end up with a large amount of output. The preceding command, for example, provided over 60 results.

Recall that there are thousands of man pages, so when you search for a keyword, be as specific as possible. Using a generic word, such as "the" could result in hundreds or even thousands of results.

Note that on most Linux distributions, the apropos command does the same thing as man -k. On those distributions, both will produce the same output.

Part 2: info Command

Man pages are great sources of information, but they do tend to have a few disadvantages. One example of a disadvantage is that each man page is a separate document, not related to any other man page. While some man pages have a SEE ALSO section that may refer to other man pages, they really tend to be unrelated sources of documentation.

The info command also provides documentation on operating system commands and features. The goal of this command is slightly different from man pages: to provide a documentation resource that provides a logical organizational structure, making reading documentation easier.

Within info documents, information is broken down into categories that work much like a table of contents that you would find in a book. Hyperlinks are provided to pages with information on individual topics for a specific command or feature. In fact, all of the documentation is merged into a single "book" in which you can go to the top level of documentation and view the table of contents representing all of the documentation available.

Another advantage of info over man pages is that the writing style of info documents is typically more conducive to learning a topic. Consider man pages to be more of a reference resource and info documents to be more of a learning guide.

时间: 2024-10-19 08:54:56

Linux - Getting Help的相关文章

排查Linux机器是否已经被入侵

随着开源产品的越来越盛行,作为一个Linux运维工程师,能够清晰地鉴别异常机器是否已经被入侵了显得至关重要,个人结合自己的工作经历,整理了几种常见的机器被黑情况供参考 背景信息:以下情况是在CentOS 6.9的系统中查看的,其它Linux发行版类似 1.入侵者可能会删除机器的日志信息,可以查看日志信息是否还存在或者是否被清空,相关命令示例: [[email protected] ~]# ll -h /var/log/* -rw-------. 1 root root 2.6K Jul 7 18

linux下Nginx配置文件(nginx.conf)配置设置详解(windows用phpstudy集成)

linux备份nginx.conf文件举例: cp /usr/local/nginx/nginx.conf /usr/local/nginx/nginx.conf-20171111(日期) 在进程列表里 面找master进程,它的编号就是主进程号. ps -ef | grep nginx 查看进程 cat /usr/local/nginx/nginx.pid 每次修改完nginx文件都要重新加载配置文件linux命令: /usr/local/nginx -t //验证配置文件是否合法 若ngin

Linux下WebSphereV8.5.5.0 安装详细过程

Linux下WebSphereV8.5.5.0 安装详细过程 自WAS8以后安装包不再区别OS,一份介质可以安装到多个平台.只针对Installation Manager 进行了操作系统的区分 ,Websphere产品介质必须通过专门的工具Install Managere安装.进入IBM的官网http://www.ibm.com/us/en/进行下载.在云盘http://yun.baidu.com/share/linkshareid=2515770728&uk=4252782771 中是Linu

Linux centos下让alias自定义永久生效(+常用的别名)

alias可以简化一些复杂的命令串,使一个单词或简化后的命令即可实现复杂(通常是带很多参数的长串)命令. 基本用法: alias 简化命令='实际的长串命令'    //实际长串命令通常为'原命令 -/选项参数' eg. alias ll='ls -a' 获取别名: alias        //即可查看当前设定的所有alias别名 取消别名: unalias 简化命令 eg. unalias ll            //取消ll的别名 永久生效: 直接使用alias命令定义的别名,重启后就

Linux下修改环境变量PATH

1.什么是环境变量(PATH) 在Linux中,在执行命令时,系统会按照PATH的设置,去每个PATH定义的路径下搜索执行文件,先搜索到的文件先执行. 我们知道查阅文件属性的指令ls 完整文件名为:/bin/ls(这是绝对路径), 那你会不会觉得很奇怪:"为什么我可以在任何地方执行/bin/ls这个指令呢? " 为什么我在任何目录下输入 ls 就一定可以显示出一些讯息而不会说找不到该 /bin/ls 指令呢? 这是因为环境变量 PATH 的帮助所致呀! 当我们在执行一个指令癿时候,举例

老男孩Linux运维第41期20170917开班第四周学习重点课堂记录

第1章 必知必会文件 配置文件位置 该文件作用 /etc/sysconfig/network-scripts/ifcfg-eth0 第一块网卡的配置文件 同setup中的network /etc/resolv.conf 客户端DNS配置文件,优先级低于网卡配置文件 /etc/hosts 主要作用是定义IP地址和主机名的映射关系(域名解析),是一个映射IP地址和主机名的规定 /etc/sysconfig/network 用于配置hostname和networking /etc/fstab 开机自动

Linux基础命令小结

注意:Linux严格区分大小写 老男孩方法论经验之谈: 有一种方法叫做没方法 有两种方法,左右为难 有三种方法才叫有方法 停止一个命令:CTR + C 1.创建目录 英文:make directorys 命令:mkdir 实例:三种方式 mkdir /data cd / mkdir data cd /;mkdir data mkdir x y z    表示同时创建多个目录 mkdir -p /data/x/y   表示同时创建多级目录(递归创建),切记不可用mkdir /data/x/y 2.

Linux red hat 安装ansible

今日对Linux 系统是Red Hat Enterprise Linux Server release 6.5 (Santiago)对ansible进行安装. 由于系统的源为yum源,所以使用yum install ansible 进行安装,但是报错.如图.(这个错误是yum源没有注册到red hat 系统). yum源不能安装,所以换了一个思路.使用pip安装.pip是依赖python安装的. 1.检查Python版本 Python -v 检查出来为Python 2.6.6 2.检查pip 版

初识运维3--在虚拟机中安装Linux发行版系统(CentOS)的方法

在讲Linux系统发行版本的安装过程之前,先大略说明一下虚拟化. 虚拟化:将底层硬件资源抽象为用户更容易读懂和使用的逻辑抽象层的技术. 最早由IBM提出,现使用率较高的虚拟化软件平台有三类:VMware workstation.VirtualBOX.HyperV.在这里使用VMware workstation作为例子讲解说明安装过程. 虚拟化网络: 桥接模式:让物理机和虚拟机利用物理网络接口完成通信.虚拟机可以访问互联网. 仅主机模式:让虚拟机和物理机利用被虚拟出来的VMnet1网络接口完成通信

查看Linux系统版本信息

一.查看Linux内核版本命令(两种方法): 1.cat /proc/version [[email protected]CentOS home]# cat /proc/versionLinux version 2.6.32-431.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013 2.uname -a [