首页 Linux教程linux帮助

linux命令

linux系统目录结构

运维派隶属马哥教育旗下专业运维社区,是国内成立最早的IT运维技术社区,欢迎关注公众号:yunweipai
领取学习更多免费Linux云计算、Python、Docker、K8s教程关注公众号:马哥linux运维

获得帮助

获取帮助的能力决定了技术的能力!

多层次的帮助

  • whatis
  • command –help
  • man and info
  • /usr/share/doc/
  • Red Hat documentation 、Ubuntu documentation
  • 软件项目网站
  • 其它网站
  • 搜索

whatis

whatis 使用数据库来显示命令的简短描述
刚安装后不可立即使用,需要制作数据库

#CentOS 7 版本以后
mandb 
#CentOS 6 版本之前
makewhatis

范例:

[root@centos8 ~]#whatis cal
cal (1)              - display a calendar
cal (1p)             - print a calendar
[root@centos8 ~]#man -f cal
cal (1)              - display a calendar
cal (1p)             - print a calendar

范例:

[root@centos8 ~]#whatis ls
ls: nothing appropriate.
#生成man相关数据库
[root@centos8 ~]#mandb
Processing manual pages under /usr/share/man...
Updating index cache for path `/usr/share/man/mann'. Wait...done.
Checking for stray cats under /usr/share/man...
...省略...
0 old database entries were purged.
[root@centos8 ~]#whatis ls
ls (1)               - list directory contents

查看命令的帮助

内部命令:

  • help COMMAND
  • man bash

范例:

[root@centos8 ~]#type history
history is a shell builtin
[root@centos8 ~]#help history
history: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
    Display or manipulate the history list.

    Display the history list with line numbers, prefixing each modified
    entry with a `*'.  An argument of N lists only the last N entries.

    Options:
      -c        clear the history list by deleting all of the entries
      -d offset delete the history entry at position OFFSET.

      -a        append history lines from this session to the history file
      -n        read all history lines not already read from the history file
                and append them to the history list
      -r        read the history file and append the contents to the history
                list
      -w        write the current history to the history file

      -p        perform history expansion on each ARG and display the result
                without storing it in the history list
      -s        append the ARGs to the history list as a single entry

    If FILENAME is given, it is used as the history file.  Otherwise,
    if HISTFILE has a value, that is used, else ~/.bash_history.

    If the HISTTIMEFORMAT variable is set and not null, its value is used
    as a format string for strftime(3) to print the time stamp associated
    with each displayed history entry.  No time stamps are printed otherwise.

    Exit Status:
    Returns success unless an invalid option is given or an error occurs.

外部命令和软件:

  • COMMAND –help 或 COMMAND -h
  • 使用手册(manual)

    ​ man COMMAND

  • 信息页
    info COMMAND
  • 程序自身的帮助文档
    README
    INSTALL
    ChangeLog
  • 程序官方文档
    官方站点:Documentation
  • 发行版的官方文档
  • (7) Google

–help 或 -h 选项

显示用法总结和参数列表,大多数命令使用,但并非所有的

范例:

[root@centos8 ~]#date --help
Usage: date [OPTION]... [+FORMAT]
  or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.

[root@centos8 ~]#cal -h
Usage:
 cal [options] [[[day] month] year]
 cal [options] <timestamp|monthname>

[root@centos8 ~]#strace --help
strace: invalid option -- '-'
Try 'strace -h' for more information.

[root@centos8 ~]#openssl --help
Invalid command '--help'; type "help" for a list.

[root@centos8 ~]#date -h
date: invalid option -- 'h'
Try 'date --help' for more information.

[root@centos8 ~]#shutdown -h
Shutdown scheduled for Fri 2020-03-20 08:26:27 CST, use 'shutdown -c' to cancel.

格式说明:

  • [] 表示可选项
  • CAPS或 表示变化的数据
  • … 表示一个列表
  • x |y| z 的意思是“ x 或 y 或 z ”
  • -abc的 意思是 -a -b –c
  • { } 表示分组

范例:
1、显示当前时间,格式:2016-06-18 10:20:30
2、显示前天是星期几
3、设置当前日期为2019-08-07 06:05:10

man 命令

man 提供命令帮助的文件,手册页存放在/usr/share/man

几乎每个命令都有man的“页面”

中文man需安装包

  • man-pages
  • man-pages-zh-CN

man 页面分组为不同的“章节”,统称为Linux手册,man 1 man

  • 1:用户命令
  • 2:系统调用
  • 3:C库调用
  • 4:设备文件及特殊文件
  • 5:配置文件格式
  • 6:游戏
  • 7:杂项
  • 8:管理类的命令
  • 9:Linux 内核API

man命令的配置文件:

#CentOS 6 之前版 man 的配置文件
/etc/man.config 
#CentOS 7 之后版 man 的配置文件
/etc/man_db.conf
#ubuntu  man 的配置文件
/etc/manpath.config

格式:

MANPATH /PATH/TO/SOMEWHERE   #指明man文件搜索位置

也可以指定位置下搜索COMMAND命令的手册页并显示

man -M /PATH/TO/SOMEWHERE COMMAND

查看man手册页

man  [章节]  keyword

man 帮助段落说明

  • NAME 名称及简要说明
  • SYNOPSIS 用法格式说明
  • [] 可选内容
  • 必选内容
  • a|b 二选一
  • { } 分组
  • … 同一内容可出现多次
  • DESCRIPTION 详细说明
  • OPTIONS 选项说明
  • EXAMPLES 示例
  • FILES 相关文件
  • AUTHOR 作者
  • COPYRIGHT 版本信息
  • REPORTING BUGS bug信息
  • SEE ALSO 其它帮助参考

列出所有帮助

man -a keyword 

搜索man手册

#列出所有匹配的页面,使用 whatis  数据库
man -k keyword 

相当于 whatis

man -f keyword 

打印man帮助文件的路径

man -w  [章节] keyword

范例:

[root@centos8 ~]#dnf install man-pages
[root@centos8 ~]#man -w 1 passwd
/usr/share/man/man1/passwd.1.gz
[root@centos8 ~]#whatis passwd
openssl-passwd (1ssl) - compute password hashes
passwd (1)           - update user's authentication tokens
[root@centos8 ~]#man 1ssl openssl-passwd
[root@centos8 ~]#man 7 ascii
[root@centos8 ~]#man 7 utf8

man命令的操作方法:使用less命令实现

  • space, ^v, ^f, ^F: 向文件尾翻屏
  • b, ^b: 向文件首部翻屏
  • d, ^d: 向文件尾部翻半屏
  • u, ^u: 向文件首部翻半屏
  • RETURN, ^N, e, ^E or j or ^J: 向文件尾部翻一行
  • y or ^Y or ^P or k or ^K:向文件首部翻一行
  • q: 退出
  • #:跳转至第#行
  • 1G: 回到文件首部
  • G:翻至文件尾部
  • /KEYWORD
    以KEYWORD指定的字符串为关键字,从当前位置向文件尾部搜索;不区分字符大小写
    n:下一个
    N:上一个
  • ?KEYWORD
    以KEYWORD指定的字符串为关键字,从当前位置向文件首部搜索;不区分字符大小写
    n:跟搜索命令同方向,下一个
    N:跟搜索命令反方向,上一个

范例:
1、在本机字符终端登录时,除显示原有信息外,再显示当前登录终端号,主机名和当前时间
2、今天18:30自动关机,并提示用户

info

man常用于命令参考 ,GNU工具 info 适合通用文档参考
没有参数,列出所有的页面
info 页面的结构就像一个网站
每一页分为“节点”
链接节点之前 *

info 命令格式

info [ 命令 ]

导航info页

  • 方向键,PgUp,PgDn 导航
  • Tab键 移动到下一个链接
  • d 显示主题目录
  • Home 显示主题首部
  • Enter进入 选定链接
  • n/p/u/l 进入下/前/上一层/最后一个链接
  • s 文字 文本搜索
  • q 退出 info

Linux 安装提供的本地文档获取帮助

Applications -> documentation->help(centos7)

System->help(centos6)

命令自身提供的官方使用指南

/usr/share/doc 目录

多数安装了的软件包的子目录,包括了这些软件的相关原理说明
常见文档:README INSTALL CHANGES
不适合其它地方的文档的位置
配置文件范例
HTML/PDF/PS 格式的文档
授权书详情

系统及第三方应用官方文档

通过在线文档获取帮助

http://www.github.com
https://www.kernel.org/doc/html/latest/
http://httpd.apache.org
http://www.nginx.org
https://mariadb.com/kb/en
https://dev.mysql.com/doc/
http://tomcat.apache.org
https://jenkins.io/zh/doc/
https://kubernetes.io/docs/home/
https://docs.openstack.org/train/
http://www.python.org
http://php.net

Linux官方在线文档和知识库

通过发行版官方的文档光盘或网站可以获得安装指南、部署指南、虚拟化指南等

http://kbase.redhat.com
http://www.redhat.com/docs
http://access.redhat.com
https://help.ubuntu.com/lts/serverguide/index.html
http://tldp.org

红帽全球技术支持服务

rhn.redhat.com或者本地卫星服务器/代理服务器
RHN账户为及其注册和基于网络管理的RHN用户
sosreport 收集所有系统上的日志信息的工具,并自动打成压缩包,方便技术支持人员和红帽全球支持提供分析问题依据

范例:

[root@centos8 ~]#dnf -y install sos 
[root@centos8 ~]# sosreport
sosreport (version 3.6)
This command will collect diagnostic and configuration information from
this CentOS Linux system and installed applications.

An archive containing the collected information will be generated in
/var/tmp/sos.8fs1kg3w and may be provided to a CentOS support
representative.

Any information provided to CentOS will be treated in accordance with
the published support policies at:

  https://wiki.centos.org/

The generated archive may contain data considered sensitive and its
content should be reviewed by the originating organization before being
passed to any third party.

No changes will be made to system configuration.

Press ENTER to continue, or CTRL-C to quit.

Please enter the case id that you are generating this report for []: 2

 Setting up archive ...
 Setting up plugins ...
 Running plugins. Please wait ...

  Finishing plugins              [Running: processor]
  Finished running plugins
Creating compressed archive...

Your sosreport has been generated and saved in:
  /var/tmp/sosreport-centos8-2-2020-03-20-xllummc.tar.xz

The checksum is: ffbbe6fa9f009f4024e272fbce500bff

Please send this file to your support representative.

[root@centos8 sysconfig]#ll /var/tmp/sosreport-centos8-2-2020-03-20-xllummc.tar.xz
-rw------- 1 root root 4409596 Mar 20 18:57 /var/tmp/sosreport-centos8-2-2020-03-20-xllummc.tar.xz
[root@centos8 sysconfig]#cd
[root@centos8 ~]#ll /var/tmp/sosreport-centos8-2-2020-03-20-xllummc.tar.xz

网站和搜索

http://www.google.com

Openstack filetype:pdf
rhca site:redhat.com/docs

http://www.slideshare.net

本文链接:https://www.yunweipai.com/33857.html

linux命令

linux系统目录结构

网友评论comments

发表回复

您的电子邮箱地址不会被公开。

暂无评论

Copyright © 2012-2022 YUNWEIPAI.COM - 运维派 京ICP备16064699号-6
扫二维码
扫二维码
返回顶部