在上一章节中,学会了基本的档案与目录之管理以及档案系统的目录架构之後,在这个章节中,要教导如何取得指令的帮助与用法的说明。
man
指令是一种可以查询各个在系统上指令说明的方式,通常常见的Linux手册指印的类型如下清单:
当进入到指令搜寻的说明页面时候,会在终端机上进入到一个阅读器,这时候需要使用到键盘进行浏览与查看,以下是笔者整理出几个在阅读器中操作与观看说明文件的方法:
当进入到指令的说明页面,都有一个固定格式,以下以清单的方式整理出格式之说明:
若是使用man ls
指令,则是利用man找到ls
这个指令的说明与使用方式,若是带上参数-k
则是寻找有关於passwd
这个关键字有关的说明页面,相关执行後的输出如下所示:
[rockylinux@workstation ~]$ man -k passwd
passwd: nothing appropriate.
出现这个原因是因为man
这个指令有一个资料库叫做mandb
,这个mandb
并没有做更新或者是更新不完全,为了要让man
指令可以运作的更好,可以使用sudo mandb -c
来将man
指令所需要用到的资料库再进行更新一次,因为更新mandb资料库需要是root使用者最高权限才可以更新,而这个使用者刚好可以使用sudo
指令来暂时取得最高使用者权限进行mandb
之更新,相关更进一步有关於sudo
的介绍,会在後面章节进行介绍;相关的更新结果之输出如下所示:
[rockylinux@workstation ~]$ sudo mandb -c
Processing manual pages under /usr/share/man/overrides...
Updating index cache for path `/usr/share/man/overrides/man8'. Wait...done.
Checking for stray cats under /usr/share/man/overrides...
Checking for stray cats under /var/cache/man/overrides...
Processing manual pages under /usr/share/man...
Updating index cache for path `/usr/share/man/man1'. Wait...mandb: warning: /usr/share/man/man1/gdk-pixbuf-query-loaders.1.gz: whatis parse for gdk-pixbuf-query-loaders(1) failed
Updating index cache for path `/usr/share/man/man5'. Wait...mandb: can't open /usr/share/man/man5/regulatory.bin.5.gz: No such file or directory
mandb: warning: /usr/share/man/man5/regulatory.db.5.gz: bad symlink or ROFF `.so' request
mandb: warning: /usr/share/man/man5/containers-signature.5.gz: whatis parse for containers-signature(5) failed
Updating index cache for path `/usr/share/man/man3'. Wait...mandb: warning: /usr/share/man/man3/Net::libnetFAQ.3pm.gz: whatis parse for Net::libnetFAQ(3pm) failed
Updating index cache for path `/usr/share/man/mann'. Wait...done.
Checking for stray cats under /usr/share/man...
Checking for stray cats under /var/cache/man...
Processing manual pages under /usr/share/man/overrides...
Updating index cache for path `/usr/share/man/overrides/man8'. Wait...done.
Checking for stray cats under /usr/share/man/overrides...
Checking for stray cats under /var/cache/man/overrides...
Processing manual pages under /usr/share/man/ru...
Updating index cache for path `/usr/share/man/ru/man7'. Wait...done.
Checking for stray cats under /usr/share/man/ru...
Checking for stray cats under /var/cache/man/ru...
Processing manual pages under /usr/share/man/hu...
Updating index cache for path `/usr/share/man/hu/man8'. Wait...done.
Checking for stray cats under /usr/share/man/hu...
Checking for stray cats under /var/cache/man/hu...
Processing manual pages under /usr/share/man/ja...
Updating index cache for path `/usr/share/man/ja/man7'. Wait...done.
Checking for stray cats under /usr/share/man/ja...
Checking for stray cats under /var/cache/man/ja...
Processing manual pages under /usr/share/man/fr...
Updating index cache for path `/usr/share/man/fr/man7'. Wait...done.
Checking for stray cats under /usr/share/man/fr...
Checking for stray cats under /var/cache/man/fr...
Processing manual pages under /usr/share/man/it...
Updating index cache for path `/usr/share/man/it/man8'. Wait...done.
Checking for stray cats under /usr/share/man/it...
Checking for stray cats under /var/cache/man/it...
Processing manual pages under /usr/share/man/pl...
Updating index cache for path `/usr/share/man/pl/man5'. Wait...done.
Checking for stray cats under /usr/share/man/pl...
Checking for stray cats under /var/cache/man/pl...
Processing manual pages under /usr/share/man/ko...
Updating index cache for path `/usr/share/man/ko/man8'. Wait...done.
Checking for stray cats under /usr/share/man/ko...
Checking for stray cats under /var/cache/man/ko...
Processing manual pages under /usr/share/man/sk...
Updating index cache for path `/usr/share/man/sk/man8'. Wait...done.
Checking for stray cats under /usr/share/man/sk...
Checking for stray cats under /var/cache/man/sk...
Processing manual pages under /usr/share/man/cs...
Updating index cache for path `/usr/share/man/cs/man7'. Wait...done.
Checking for stray cats under /usr/share/man/cs...
Checking for stray cats under /var/cache/man/cs...
Processing manual pages under /usr/share/man/da...
Updating index cache for path `/usr/share/man/da/man8'. Wait...done.
Checking for stray cats under /usr/share/man/da...
Checking for stray cats under /var/cache/man/da...
Processing manual pages under /usr/share/man/de...
Updating index cache for path `/usr/share/man/de/man8'. Wait...done.
Checking for stray cats under /usr/share/man/de...
Checking for stray cats under /var/cache/man/de...
Processing manual pages under /usr/share/man/id...
Updating index cache for path `/usr/share/man/id/man5'. Wait...done.
Checking for stray cats under /usr/share/man/id...
Checking for stray cats under /var/cache/man/id...
Processing manual pages under /usr/share/man/pt_BR...
Updating index cache for path `/usr/share/man/pt_BR/man8'. Wait...done.
Checking for stray cats under /usr/share/man/pt_BR...
Checking for stray cats under /var/cache/man/pt_BR...
Processing manual pages under /usr/share/man/sv...
Updating index cache for path `/usr/share/man/sv/man7'. Wait...done.
Checking for stray cats under /usr/share/man/sv...
Checking for stray cats under /var/cache/man/sv...
Processing manual pages under /usr/share/man/tr...
Updating index cache for path `/usr/share/man/tr/man7'. Wait...done.
Checking for stray cats under /usr/share/man/tr...
Checking for stray cats under /var/cache/man/tr...
Processing manual pages under /usr/share/man/zh_CN...
Updating index cache for path `/usr/share/man/zh_CN/man8'. Wait...done.
Checking for stray cats under /usr/share/man/zh_CN...
Checking for stray cats under /var/cache/man/zh_CN...
Processing manual pages under /usr/share/man/zh_TW...
Updating index cache for path `/usr/share/man/zh_TW/man8'. Wait...done.
Checking for stray cats under /usr/share/man/zh_TW...
Checking for stray cats under /var/cache/man/zh_TW...
Processing manual pages under /usr/share/man/es...
Updating index cache for path `/usr/share/man/es/man1'. Wait...done.
Checking for stray cats under /usr/share/man/es...
Checking for stray cats under /var/cache/man/es...
Processing manual pages under /usr/share/man/uk...
Updating index cache for path `/usr/share/man/uk/man1'. Wait...mandb: warning: /usr/share/man/uk/man1/dos2unix.1.gz: whatis parse for dos2unix(1) failed
mandb: warning: /usr/share/man/uk/man1/dos2unix.1.gz: whatis parse for mac2unix(1) failed
mandb: warning: /usr/share/man/uk/man1/dos2unix.1.gz: whatis parse for unix2dos(1) failed
mandb: warning: /usr/share/man/uk/man1/dos2unix.1.gz: whatis parse for unix2mac(1) failed
Updating index cache for path `/usr/share/man/uk/man7'. Wait...done.
Checking for stray cats under /usr/share/man/uk...
Checking for stray cats under /var/cache/man/uk...
Processing manual pages under /usr/share/man/ca...
Updating index cache for path `/usr/share/man/ca/man8'. Wait...done.
Checking for stray cats under /usr/share/man/ca...
Checking for stray cats under /var/cache/man/ca...
Processing manual pages under /usr/share/man/nl...
Updating index cache for path `/usr/share/man/nl/man1'. Wait...done.
Checking for stray cats under /usr/share/man/nl...
Checking for stray cats under /var/cache/man/nl...
Processing manual pages under /usr/share/man/pt...
Updating index cache for path `/usr/share/man/pt/man8'. Wait...done.
Checking for stray cats under /usr/share/man/pt...
Checking for stray cats under /var/cache/man/pt...
Processing manual pages under /usr/local/share/man...
Updating index cache for path `/usr/local/share/man/mann'. Wait...done.
Checking for stray cats under /usr/local/share/man...
Checking for stray cats under /var/cache/man/local...
124 man subdirectories contained newer manual pages.
7794 manual pages were added.
0 stray cats were added.
从上述输出的更新过程中,有时候有些失败讯息是因为有些档案找不到因此更新失败,那个错误讯息可以忽略,因为有可能真的没有那个mandb档案可以做更新,更新完之後,再执行一次man -k passwd
指令,则会有下列正常的输出结果了:
[rockylinux@workstation ~]$ man -k passwd
chgpasswd (8) - update group passwords in batch mode
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
openssl-passwd (1ssl) - compute password hashes
pam_localuser (8) - require users to be listed in /etc/passwd
passwd (1) - update user's authentication tokens
passwd (5) - password file
passwd2des (3) - RFS password encryption
pwhistory_helper (8) - Helper binary that transfers password hashes from passwd or shadow to opasswd
saslpasswd2 (8) - set a user's sasl password
smbpasswd (5) - The Samba encrypted password file
sslpasswd (1ssl) - compute password hashes
vncpasswd (1) - change the VNC password
接下来使用man ls
来看一下,可以看到以下的部分说明页面如下:
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default). Sort entries alphabetically if none of
-cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-a, --all
do not ignore entries starting with .
-A, --almost-all
do not list implied . and ..
--author
with -l, print the author of each file
-b, --escape
print C-style escapes for nongraphic characters
--block-size=SIZE
with -l, scale sizes by SIZE when printing them; e.g., '--block-size=M'; see SIZE format below
.....
从上面的说明页面来看,ls [OPTION]... [FILE]...
的说明如下:
[]
之中括号起来的选项,意思是在执行指令的时候可以带或不带选项,即可有可无的意思。...
的意思是说,在执行指令的後,带选项可以是重复的。接着使用man ps2pdf
指令来看ps2pdf
指令的说明页面,相关节录的说明页面如下:
PS2PDF(1) Ghostscript PS2PDF(1)
NAME
ps2pdf - Convert PostScript to PDF using ghostscript
ps2pdf12 - Convert PostScript to PDF 1.2 (Acrobat 3-and-later compatible) using ghostscript
ps2pdf13 - Convert PostScript to PDF 1.3 (Acrobat 4-and-later compatible) using ghostscript
ps2pdf14 - Convert PostScript to PDF 1.4 (Acrobat 5-and-later compatible) using ghostscript
SYNOPSIS
ps2pdf [options...] {input.[e]ps|-} [output.pdf|-]
ps2pdf12 [options...] {input.[e]ps|-} [output.pdf|-]
ps2pdf13 [options...] {input.[e]ps|-} [output.pdf|-]
ps2pdf14 [options...] {input.[e]ps|-} [output.pdf|-]
DESCRIPTION
The ps2pdf scripts are work-alikes for nearly all the functionality (but not the user interface) of Adobe's
Acrobat(TM) Distiller(TM) product: they convert PostScript files to Portable Document Format (PDF) files.
If the output filename is not specified, the output is placed in a file of the same name with a '.pdf' exten‐
sion in the current working directory. Either the input filename or the output filename can be '-' to request
reading from stdin or writing to stdout, respectively, when used as a filter.
The three scripts differ as follows:
- ps2pdf12 will always produce PDF 1.2 output (Acrobat 3-and-later compatible).
- ps2pdf13 will always produce PDF 1.3 output (Acrobat 4-and-later compatible).
- ps2pdf14 will always produce PDF 1.4 output (Acrobat 5-and-later compatible).
其中,ps2pdf [options...] {input.[e]ps|-} [output.pdf|-]
指令意思是,{}
意思是,这个选项一定要使用,{}
中间必要选其中一个选项来使用,里面的选项以|
来隔开。
平常在一般的情况下,都是使用man 要查询的指令名称
这样方式输出指定要查询的说明页面进行查询,若要将整个指令说明页面输出也是可以的,可以使用:man -t ls > ls.ps
这样的方式将ls
指令说明手册页输出成postscript档案,若要让影印机印出,则可以使用ps2pdf
方式将前面输出的postscript档案输出成PDF档,相关使用指令的方式以及输出後的执行结果如下:
[rockylinux@workstation ~]$ man -t ls > ls.ps
[rockylinux@workstation ~]$ file ls.ps
ls.ps: PostScript document text conforming DSC level 3.0
[rockylinux@workstation ~]$ ps2pdf ls.ps ls.pdf
[rockylinux@workstation ~]$ file ls.pdf
ls.pdf: PDF document, version 1.4
从上述来看,多了使用file
这个指令来协助查看输出的档案格式资讯,可以看到的是,一开始先用man指令输出ls说明手册页之postscript档案,而再将ls.ps
档案输出成ls.pdf
之PDF档,为什麽要用file
档案检查输出的格式,原因是用.
隔开後面的附档名在Linux作业系统中只是因为便於使用者作辨识,实际上在作业系统中档名并没有附档名的概念,如果档案名称乱取的话,还是只能使用file
指令来确认真正的档案格式资讯是什麽,下面的例子可以很显着的说明这件事:
[rockylinux@workstation ~]$ man -t ls > ls.txt
[rockylinux@workstation ~]$ file ls.txt
ls.txt: PostScript document text conforming DSC level 3.0
从上面这个例子来看,就可以证明Linux作业系统之世界中,附档名并不能够决定一个档案格式的资讯,而是需要用file指令协助我们看真正的档案资讯,便於识别档案,通常都会用附档名可以对应到真正的档案格式。
workstation
虚拟主机。fdisk
指令之说明页面。su
指令是在section 1,透过终端机输入man
指令并指定section来找到su
指令说明页面。su
指令说明页面透过终端机使用man
指令输出成Postscript档案并将输出的档案取名叫:su.ps
。su.ps
档案转成PDF档并将输出的PDF档案格式取名叫su.pdf
。
经过昨天的一番努力,我们已经可以在服务无法存取的时候收到通知,那麽今天就来看看另一个议题:服务的重启...
在开发时,常常需要多个指令同时运作(例如一个启动前端专案、一个启动後端专案),因此会需要同时开启多个...
课程目标 了解系统分析实务、系统分析工具之应用、逻辑资料库设计技巧、系统分析产出文件、同仁审查等,以...
for回圈 我们一般会使用for回圈进行某些次数的回圈,(回圈次数确定时) 一个for回圈会不断重复...
Nuxt.js 跟 Vue-Router 是什麽关系? 有使用过 vue-router 的捧由,别紧...