獲取幫助的能力決定了你技術(shù)能力唆樊。
本篇博文教你如何獲取命令的幫助文檔宛琅,如通過help、man和本地安裝的方法進(jìn)行查詢逗旁。
一嘿辟、linux中命令的類型
linux 中命令類型分為內(nèi)部命令和外部命令。
type命令是判斷一個(gè)命令是外部命令還是內(nèi)部命令片效,示例如下:
[root@centos7 ~]#type cd
cd is a shell builtin #cd是shell 的內(nèi)置命令
[root@centos7 ~]#type passwd
passwd is /usr/bin/passwd #passwd命令存放在/usr/bin/passwd路徑下
二仓洼、使用man命令獲取外部命令幫助信息
man手冊(cè)分為以下幾個(gè)章節(jié),但并不是每個(gè)命令都包含這些章節(jié)堤舒。
man章節(jié):
1 用戶命令
2 系統(tǒng)調(diào)用
3 從庫(kù)調(diào)用
4 備文件及特殊文件
5 置文件格式
6 游戲
7 雜項(xiàng)
8 理類的命令
9 linux的內(nèi)核API
man命令的手冊(cè)頁(yè)存放在/usr/shar/man中
man命令的的配置文件:/etc/man.config (CentOS 6)|man_db.conf(CentOS 7)
whatis命令是列出一個(gè)命令中manual章節(jié)的概述
[root@centos7 ~]#whatis ls
ls (1) - list directory contents
ls (1p) - list directory contents
此命令在剛剛安裝好的系統(tǒng)中可能不能正常使用色建;可以手動(dòng)創(chuàng)建數(shù)據(jù)庫(kù),使用命令makewhatis(CentOS 6)舌缤;文件存在的位置在/var/cache/man/中箕戳。mandb更新數(shù)據(jù)庫(kù)(CentOS 7)
一般使用man命令獲取幫助的步驟:
type COMMAND -->whatis COMMAND -->man # COMMAND
man命令使用
-a 列出所有幫助信息
-k 搜索關(guān)鍵字某残,列出所有匹配的頁(yè)面
[root@centos7 ~]#man -k passwd
chpasswd (8) - update passwords in batch mode
fgetpwent_r (3) - get passwd file entry reentrantly
getpwent_r (3) - get passwd file entry reentrantly
gpasswd (1) - administer /etc/group and /etc/gshadow
grub2-mkpasswd-pbkdf2 (1) - Generate a PBKDF2 password hash.
lpasswd (1) - Change group or user password
lppasswd (1) - add, change, or delete digest passwords.
pam_localuser (8) - require users to be listed in /etc/passwd
passwd (1) - update user's authentication tokens
sslpasswd (1ssl) - compute password hashes
passwd (5) - password file
passwd2des (3) - RFS password encryption
pwhistory_helper (8) - Helper binary that transfers password hashes from pa...
saslpasswd2 (8) - set a user's sasl password
smbpasswd (5) - The Samba encrypted password file
vncpasswd (1) - change the VNC password
-f 相當(dāng)于whatis命令
[root@centos7 ~]#man -f ls
ls (1) - list directory contents
ls (1p) - list directory contents
-w # 顯示路徑
[root@centos7 ~]#man -w ls
/usr/share/man/man1/ls.1.gz
三、help獲取命令幫助
1.查看內(nèi)部命令 **help COMMAND **
[root@centos7 ~]#help cd
cd: cd [-L|[-P [-e]]] [dir]
Change the shell working directory.
Change the current directory to DIR. The default DIR is the value of the
HOME shell variable.
2.查看外部命令 COMMAND --help | -h
[root@centos7 ~]#ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
四陵吸、通過本地文檔獲取幫助
本地文檔存放在/usr/shar/man目錄下
1玻墅、多數(shù)安裝了的軟件包的子目錄,包括了這些軟件的相關(guān)原理說明壮虫;
2澳厢、常見文檔:README INSTALL CHANGES
3、可以通過自己手動(dòng)安裝幫助文檔,默認(rèn)安裝在/usr/shar/man
[root@centos7 ~]#rpm -ivh /run/media/root/CentOS\ 7\ x86_64/Packages/httpd-manual-2.4.6-45.el7.centos.noarch.rpm