[華為云在線課程][Linux基礎入門和幫助][第五章Linux幫助獲得][學習筆記]
獲取幫助的能力決定了技術的能力!
多層次的幫助
whatis
command --help
man and info
/usr/share/doc/
Red Hat documentation, Ubuntu documentation
軟件項目網站
其他網站
搜索
whatis
whatis使用數據庫來顯示命令的簡短描述
此工具在系統剛安裝后,不可立即使用,需要制作數據庫后才可使用
執行下面命令生成數據庫
#CentOS7版本以后 mandb #CentOS6版本以前 makewhatis
例子:
[root@localhost ~]# whatis cal cal (1) - display a calendar cal (1p) - print a calendar [root@localhost ~]# man -f cal cal (1) - display a calendar cal (1p) - print a calendar
例子:
[root@localhost ~]# whatis ls ls (1) - list directory contents ls (1p) - list directory contents #生成man相關數據庫 [root@localhost ~]# mandb
查看命令的幫助
內部命令幫助
help COMMAND
man bash
例子:
[root@localhost ~]# type history history is a shell builtin [root@localhost ~]# 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 offset OFFSET. -a append history lines from this session to the history file -n read all history lines not already read from the history file -r read the history file and append the contents to the history list -w write the current history to the history file and append them to the history list -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.
外部命令及軟件幫助
程序自身的幫助文檔:README、INSTALL、ChangeLog
程序官方文檔
相關網站,如:技術論壇
搜索引擎
外部命令的–help或-h選項
顯示用法總結和參數列表,大多數命令使用,但并非所有的
例子:
[root@localhost ~]# 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@localhost ~]# cal -h Usage: cal [options] [[[day] month] year] [root@localhost ~]# strace --help strace: invalid option -- '-' Try 'strace -h' for more information.
格式說明:
[]表示可選項
CAPS或<>表示變化的數據
…表示一個列表
x |y| z 的意思是"x或y或z"
-abc的意思是-a -b -c
{}表示分組
練習:
1,顯示當前時間,格式:2022-03-18 21:57:25 [root@localhost ~]# date +"%Y-%m-%d %H:%M:%S" 2022-03-18 08:02:44 2,顯示前天是星期幾 [root@localhost ~]# date -d "2 day ago" +"%A" Wednesday 3,設置當前日期為2023-03-18 22:57:25 [root@localhost ~]# date -s "2023-03-18 22:57:25" Sat Mar 18 22:57:25 CST 2023 [root@localhost ~]# date Sat Mar 18 22:57:29 CST 2023
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命令的配置文件
#CentOS6之前版man的配置文件 /etc/man.config #CentOS7之后版man的配置文件 /etc/man_db.conf #Ubuntu man的配置文件 /etc/manpath.config
格式:
MANPATH /PATH/TO/SOMEWHERE #指明man文件搜索位置
也可以指定位置下搜索COMMAND命令的手冊頁并顯示
man -M /PATH/TO/SOMEWHERE COMMAND
查看man手冊頁
man [OPTION...] [SECTION] PAGE... man [章節] keyword
man幫助段落說明
NAME 名稱及簡要說明
SYNOPSIS 用法格式說明
[] 可選內容
<> 必選內容
a|b 二選一
{} 分組
… 同一內容可出現多次
DESCRIPTION 詳細說明
OPTIONS 選項說明
EXAMPLES 示例
FILES 相關文件
COPYRIGHT 版本信息
REPORTING BUGS bug信息
SEE ALSO 其他幫助參考
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:跟搜索命令反方向,上一個
常用選項
列出所有幫助
man -a keyword
搜索man手冊
#列出所有匹配的頁面,使用whatis 數據庫 man -k keyword
相當于whatis
man -f keyword
打印出man幫助文件的路徑
man -w [章節] keyword
例子:
dnf install man-pages man -w 1 passwd whatis passwd man 1ssl openssl-passwd man 7 ascii man 7 utf8
例子:查看passwd相關命令和文件,man幫助文件路徑
[root@localhost ~]# whereis passwd passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz
info
man常用于命令參考,GNU工具info適合通用文檔參考
沒有參數,列出所有的頁面
info頁面的結構就像一個網站
每一頁分為"節點"
鏈接節點之前*
info命令格式
info [命令]
導航info頁
方向鍵,PgUp,PgDn導航
Tab鍵 移動到下一個鏈接
d 顯示主題目錄
Home 顯示主題首部
Enter 進入選定鏈接
n/p/u/l 進入下/前/上一層/最后一個鏈接
s文字 文本搜索
q退出 info
Linux安裝提供的本地文檔獲取幫助
Application->documentation->help(CentOS7)
System->help(CentOS6)
命令自身提供的官方使用指南
/usr/share/doc 目錄
多數安裝了的軟件包的子目錄,包括了這些軟件的相關原理說明
常見文檔:README INSTALL CHANGES
不適合其他地方的文檔的位置
配置文件范例
HTML/PDF/PS格式的文檔
授權書詳情
系統及第三方應用官方文檔
通過在線文檔獲取幫助
http://www.github.com
http://www.kernel.org/doc/html/latest
http://httpd.apache.org
http://www.nginx.org
http://mariadb.com/kb/en
http://dev.mysql.com/doc/
http://tomcat.apache.org
http://jenkins.io/zh/doc/
http://kubernetes.io/docs/home
http://docs.openstack.org/train/
http://www.python.org
http://php.net
Linux官方在線文檔和知識庫
通過發行版官方的文檔光盤或網站可以獲得安裝指南,部署指南,虛擬化指南等
http://kabase.redhat.com
http://www.redhat.com/docs
http://access.redhat.com
http://help.ubuntu.com/lts/serverguide/index.html
http://tldp.org
紅帽全球技術支持服務
rhn.redhat.com或者本地衛星服務服務器/代理服務器
RHN賬戶為及其注冊和基于網絡管理的RHN用戶
sosreport 收集所有系統上的日志信息的工具,并自動打成壓縮包,方便技術支持人員和紅帽全球支持提供分析問題依據
dnf -y install sos sosreport
Linux
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。