自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

在Linux中遨游手冊(cè)頁(yè)的海洋

系統(tǒng) Linux
Linux 系統(tǒng)上的手冊(cè)頁(yè)可以做的不僅僅是提供特定命令的信息。它們可以幫助你發(fā)現(xiàn)你沒有意識(shí)到的命令。

Linux 系統(tǒng)上的手冊(cè)頁(yè)可以做的不僅僅是提供特定命令的信息。它們可以幫助你發(fā)現(xiàn)你沒有意識(shí)到的命令。

手冊(cè)頁(yè)提供了關(guān)于 Linux 命令的基本信息,很多用戶經(jīng)常參考它,但手冊(cè)頁(yè)的內(nèi)容比我們很多人意識(shí)到的要多得多。

你總是可以輸入一個(gè)像 man who 這樣的命令,然后得到 who 命令的工作原理的漂亮描述,但是探索你可能不知道的命令可能會(huì)更有啟發(fā)。例如,你可以使用 man 命令來(lái)幫助找到一些處理非常具有挑戰(zhàn)性的任務(wù)的命令,或者顯示一些選項(xiàng),這些選項(xiàng)可以幫助你以新的更好的方式使用你已經(jīng)知道的命令。

讓我們來(lái)瀏覽一些選項(xiàng),看看最終的結(jié)果是什么。

用 man 去識(shí)別命令

man 命令可以幫助你按主題查找命令。例如,如果你要找一個(gè)計(jì)算文件中的行數(shù)的命令,你可以提供一個(gè)關(guān)鍵字。在下面的例子中,我們把關(guān)鍵字 “count” 放在了引號(hào)中,并添加了空格,這樣我們就不會(huì)得到與 “accounts” 或 “accounting” 相關(guān)的命令,而是得到那些可以為我們做一些計(jì)算的命令。

  1. $ man -k ' count '
  2. anvil (8postfix) - Postfix session count and request rate control
  3. cksum (1) - checksum and count the bytes in a file
  4. sum (1) - checksum and count the blocks in a file
  5. timer_getoverrun (2) - get overrun count for a POSIX per-process timer

為了顯示與新用戶賬戶相關(guān)的命令,我們可以嘗試使用這樣的命令。

  1. $ man -k "new user"
  2. newusers (8) - update and create new users in batch
  3. useradd (8) - create a new user or update default new user information
  4. zshroadmap (1) - informal introduction to the zsh manual The Zsh Manual,

需要說(shuō)明的是,上面的第三項(xiàng)只是提到 “new users” 類似的內(nèi)容,并不是設(shè)置、刪除或配置用戶賬號(hào)的命令。man 命令只是在命令描述中匹配了一些詞,作用很像 apropos 命令。注意上面列出的每個(gè)命令后面的括號(hào)中的數(shù)字。這些數(shù)字與包含這些命令的手冊(cè)頁(yè)的分區(qū)有關(guān)。

確定手冊(cè)頁(yè)的分區(qū)

man 命令的分區(qū)將其內(nèi)容劃分為不同的類別。要列出這些類別,請(qǐng)鍵入 man man,并查看類似下面的描述。你的系統(tǒng)中很可能沒有第 9 分區(qū)的命令。

  • 1:可執(zhí)行程序或 shell 命令
  • 2:系統(tǒng)調(diào)用(內(nèi)核提供的函數(shù))
  • 3:庫(kù)調(diào)用(程序庫(kù)內(nèi)的函數(shù))
  • 4:特殊文件(通常在可以 /dev 中找到)
  • 5:文件格式和慣例,例如 /etc/passwd
  • 6:游戲
  • 7:雜項(xiàng)(包括宏包和約定),例如 man(7)、groff(7)
  • 8:系統(tǒng)管理命令(通常只由 root 用戶使用)
  • 9:內(nèi)核例程(非標(biāo)準(zhǔn))

手冊(cè)頁(yè)涵蓋了比我們通常認(rèn)為的“命令”更多的內(nèi)容。從上面的描述中可以看到,它們涵蓋了系統(tǒng)調(diào)用、庫(kù)調(diào)用、特殊文件等等。

下面的列表顯示了 Linux 系統(tǒng)中的手冊(cè)頁(yè)的實(shí)際存儲(chǔ)位置。這些目錄上的日期會(huì)有所不同,因?yàn)殡S著更新,其中一些分區(qū)會(huì)有新的內(nèi)容,而另一些則不會(huì)。

  1. $ ls -ld /usr/share/man/man?
  2. drwxr-xr-x 2 root root 98304 Feb 5 16:27 /usr/share/man/man1
  3. drwxr-xr-x 2 root root 65536 Oct 23 17:39 /usr/share/man/man2
  4. drwxr-xr-x 2 root root 270336 Nov 15 06:28 /usr/share/man/man3
  5. drwxr-xr-x 2 root root 4096 Feb 4 10:16 /usr/share/man/man4
  6. drwxr-xr-x 2 root root 28672 Feb 5 16:25 /usr/share/man/man5
  7. drwxr-xr-x 2 root root 4096 Oct 23 17:40 /usr/share/man/man6
  8. drwxr-xr-x 2 root root 20480 Feb 5 16:25 /usr/share/man/man7
  9. drwxr-xr-x 2 root root 57344 Feb 5 16:25 /usr/share/man/man8

注意,為了節(jié)省空間,手冊(cè)頁(yè)文件一般都是 gzip 壓縮的。每當(dāng)你使用 man 命令時(shí),man 命令會(huì)根據(jù)需要解壓。

  1. $ ls -l /usr/share/man/man1 | head -10
  2. total 12632
  3. lrwxrwxrwx 1 root root 9 Sep 5 06:38 [.1.gz -> test.1.gz
  4. -rw-r--r-- 1 root root 563 Nov 7 05:07 2to3-2.7.1.gz
  5. -rw-r--r-- 1 root root 592 Apr 23 2016 411toppm.1.gz
  6. -rw-r--r-- 1 root root 2866 Aug 14 10:36 a2query.1.gz
  7. -rw-r--r-- 1 root root 2361 Sep 9 15:13 aa-enabled.1.gz
  8. -rw-r--r-- 1 root root 2675 Sep 9 15:13 aa-exec.1.gz
  9. -rw-r--r-- 1 root root 1142 Apr 3 2018 aaflip.1.gz
  10. -rw-r--r-- 1 root root 3847 Aug 14 10:36 ab.1.gz
  11. -rw-r--r-- 1 root root 2378 Aug 23 2018 ac.1.gz

按分區(qū)列出的手冊(cè)頁(yè)

即使只看第 1 分區(qū)的前 10 個(gè)手冊(cè)頁(yè)(如上所示),你也可能會(huì)看到一些新的命令 —— 也許是 a2queryaaflip(如上所示)。

探索命令的更好策略是按分區(qū)列出命令,不查看文件本身,而是使用 man 命令向你顯示命令并提供每個(gè)命令的簡(jiǎn)要說(shuō)明。

在下面的命令中,-s 1 指示 man 顯示第 1 分區(qū)中的命令信息。-k . 使該命令對(duì)所有命令都有效,而不是指定一個(gè)特定的關(guān)鍵字;如果沒有這個(gè),man 命令就會(huì)回過(guò)頭來(lái)問(wèn):“你想要什么手冊(cè)頁(yè)?”所以,使用關(guān)鍵字來(lái)選擇一組相關(guān)的命令,或者使用點(diǎn)來(lái)顯示一個(gè)分區(qū)中的所有命令。

  1. $ man -s 1 -k .
  2. 2to3-2.7 (1) - Python2 to Python3 converter
  3. 411toppm (1) - convert Sony Mavica .411 image to ppm
  4. as (1) - the portable GNU assembler.
  5. baobab (1) - A graphical tool to analyze disk usage
  6. busybox (1) - The Swiss Army Knife of Embedded Linux
  7. cmatrix (1) - simulates the display from "The Matrix"
  8. expect_dislocate (1) - disconnect and reconnect processes
  9. red (1) - line-oriented text editor
  10. enchant (1) - a spellchecker

有多少手冊(cè)頁(yè)?

如果你對(duì)每個(gè)分區(qū)中有多少手冊(cè)頁(yè)感到好奇,可以使用以下命令按分區(qū)對(duì)它們進(jìn)行計(jì)數(shù):

  1. $ for num in {1..8}
  2. > do
  3. > man -s $num -k . | wc -l
  4. > done
  5. 2382
  6. 493
  7. 2935
  8. 53
  9. 441
  10. 11
  11. 245
  12. 919

確切的數(shù)量可能有所不同,但是大多數(shù) Linux 系統(tǒng)的命令數(shù)量差不多。如果我們使用命令將這些數(shù)字加在一起,我們可以看到運(yùn)行該命令的系統(tǒng)上有將近 7500 個(gè)手冊(cè)頁(yè)。有很多命令,系統(tǒng)調(diào)用等。

  1. $ for num in {1..8}
  2. > do
  3. > num=`man -s $num -k . | wc -l`
  4. > tot=`expr $num + $tot`
  5. > echo $tot
  6. > done
  7. 2382
  8. 2875
  9. 5810
  10. 5863
  11. 6304
  12. 6315
  13. 6560
  14. 7479 <=== total

閱讀手冊(cè)頁(yè)可以學(xué)到很多東西,但是以其他方式瀏覽手冊(cè)頁(yè)可以幫助你了解系統(tǒng)上可能不知道的命令。 

責(zé)任編輯:龐桂玉 來(lái)源: Linux中國(guó)
相關(guān)推薦

2021-07-12 17:45:25

LinuxTealdeer手冊(cè)頁(yè)

2021-06-15 16:11:51

Linux手冊(cè)頁(yè)

2022-05-06 08:07:45

NoSQL數(shù)據(jù)庫(kù)

2021-02-20 18:00:26

rangerLinux

2019-03-10 08:13:28

物聯(lián)網(wǎng)戰(zhàn)場(chǎng)海洋

2010-12-08 13:34:05

SUSE Linux

2009-02-17 10:12:10

ASP面試技術(shù)

2009-12-24 11:29:42

ipvsadm命令

2020-11-09 09:00:16

物聯(lián)網(wǎng)IOT物聯(lián)網(wǎng)技術(shù)

2015-03-30 10:41:37

大數(shù)據(jù)

2009-12-10 16:21:42

Fedora Linu

2010-03-10 14:18:36

Python數(shù)組

2011-08-15 10:21:09

man中文man

2011-08-23 18:00:21

LDP中文man

2010-03-11 19:34:57

Python字符串

2012-03-09 17:26:07

憤怒的小鳥憤怒的小鳥太空版

2019-12-26 16:49:20

華為

2011-08-19 18:30:52

ipc中文man

2022-03-29 12:35:02

海洋數(shù)字孿生:DTO計(jì)劃

2011-08-24 16:48:36

man中文man
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)