久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Linux中的Manual手冊分析

187次閱讀
沒有評論

共計 8243 個字符,預(yù)計需要花費 21 分鐘才能閱讀完成。

這篇文章主要講解了“Linux 中的 Manual 手冊分析”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著丸趣 TV 小編的思路慢慢深入,一起來研究和學(xué)習(xí)“Linux 中的 Manual 手冊分析”吧!

當(dāng)今可能我們很多人已經(jīng)不頻繁使用 man 命令了,取而代之的是更加友好簡單的 tldr。

$ tldr du |head du Disk usage: estimate and summarize file and directory space usage. - List the sizes of a directory and any subdirectories, in the given unit (B/KB/MB): du -{{b|k|m}} {{path/to/directory}} - List the sizes of a directory and any subdirectories, in human-readable form (i.e. auto-selecting the appropriate unit for each size): du -h {{path/to/directory}}r - Show the size of a single directory, in human readable units:

然而,man 命令始終是我個人的最愛。每當(dāng)心情低落時候,我就會中用 man 命令信步由韁的做各種查詢。從中慢慢獲得秩序感,全局的掌控感,低落的心情也慢慢療愈。

man 命令讓我們與計算機對話溝通,又仿佛促使我們與計算機融為一體,人機合一。

1.man 的 9 個章節(jié)

man 可能是唯一一個可以自我陳述的命令。我們先從最直覺的使用方法開始。

man man

 Linux 中的 Manual 手冊分析

從結(jié)果中,我們看到 Manual 手冊共分為 9 個章節(jié) (sections)。似乎有點多,我們將歸類為 4 個部分。

前三項是 commands(shell-commands, system-calls,libraries)

接著是 files(special-file,file-format)

然后是 Miscellaneous, Game 也放在這里

最后是 System(Administation,Kernel)

2. 存放地址

Linux 系統(tǒng)中一切皆為文件,我們首先感興趣的是,這些 manual 手冊存放在哪里。根據(jù)前文 幫你精通 Linux:透徹解析 Linux 的目錄樹結(jié)構(gòu)   可以簡單推測,

配置文件在 /etc/ 目錄下,具體則為 /etc/manpath.config;

變量文件在 /var/ 目錄下,具體則為 /var/cache/man/index.(bt|db|dir|pag)

/etc 和 /var 是 linux 系統(tǒng)下的最重要的兩個目錄。

man 文件本身存儲在 /usr/share 目錄下,/usr/share/man

如何查看特定命令的存儲位置呢? 需要 - w 選項 (對應(yīng)長選項 –where)

$ man -w time /usr/share/man/man1/time.1.gz

加上選 -a(對應(yīng) –all) 則能查到 time 在所有章節(jié)中的位置。

$ man -aw time /usr/share/man/man1/time.1.gz /usr/share/man/man2/time.2.gz /usr/share/man/man7/time.7.gz

從結(jié)果中看到,在 man1(shell commands), man2(system  calls) 和 man7(Miscellaneous) 中都有 time 這個命令。

作為補充,我們也可以用 - f 選項查看命令所屬的 sections。

$ man -f man man (7) - macros to format man pages man (1) - an interface to the on-line reference manuals $ man -f time time (7) - overview of time and timers time (1) - run programs and summarize system resource usage time (2) - get time in seconds

此處的 -f 等價于 –whatis

whatis (1) – display one-line manual page descriptions

3. 指定查詢章節(jié)

從 -w 選項中看到了命令的地址,便可以指定章節(jié)查詢。

whatis (1) - display one-line manual page descriptions

Linux 中的 Manual 手冊分析

man 7 time

Linux 中的 Manual 手冊分析

4. 正則查詢

man 命令最有意思的就是正則查詢,心情不好的時候,可以玩上一整天。

從正則查詢中,能夠獲得對全局的掌控感,比如查詢 systemd 有多少個命令:

$ man -k ^systemd |nl |tail 158 systemd.service (5) - Service unit configuration 159 systemd.slice (5) - Slice unit configuration 160 systemd.socket (5) - Socket unit configuration 161 systemd.special (7) - Special systemd units 162 systemd.swap (5) - Swap unit configuration 163 systemd.syntax (7) - General syntax of systemd configuration files 164 systemd.target (5) - Target unit configuration 165 systemd.time (7) - Time and date specifications 166 systemd.timer (5) - Timer unit configuration 167 systemd.unit (5) - Unit configuration

從結(jié)果中國馬上獲知 167 這個結(jié)果。

或者查詢有多少與 calendar 相關(guān)的命令:

$ man -k calendar |nl 1 cal (1) - displays a calendar and the date of Easter 2 calendar (1) - reminder service 3 ncal (1) - displays a calendar and the date of Easter

又或者查詢?nèi)康?ls 命令:

$ man -k ^ls |nl 1 ls (1) - list directory contents 2 lsar (1) - list archive file contents 3 lsattr (1) - list file attributes on a Linux second extended file system 4 lsb_release (1) - print distribution-specific information 5 lsblk (8) - list block devices 6 lscpu (1) - display information about the CPU architecture 7 lsearch (3) - linear search of an array 8 lseek (2) - reposition read/write file offset 9 lseek64 (3) - reposition 64-bit read/write file offset 10 lsetxattr (2) - set an extended attribute value 11 lshw (1) - list hardware 12 lsinitramfs (8) - list content of an initramfs image 13 lsipc (1) - show information on IPC facilities currently employed in ... 14 lslocks (8) - list local system locks 15 lslogins (1) - display information about known users in the system 16 lsmem (1) - list the ranges of available memory with their online status 17 lsmod (8) - Show the status of modules in the Linux Kernel 18 lsns (8) - list namespaces 19 lsof (8) - list open files 20 lspci (8) - list all PCI devices 21 lspcmcia (8) - display extended PCMCIA debugging information 22 lspgpot (1) - extracts the ownertrust values from PGP keyrings and list... 23 lstat (2) - get file status 24 lstat64 (2) - get file status 25 lsusb (8) - list USB devices

5. 全局掌控

文章開頭就介紹過 section 2 中是 system-calls 命令。我們不免心生好奇,哪些是 system-calls 呢?

man -s 2 -k . |nl |tail 484 vm86old (2) - enter virtual 8086 mode 485 vmsplice (2) - splice user pages to/from a pipe 486 vserver (2) - unimplemented system calls 487 wait (2) - wait for process to change state 488 wait3 (2) - wait for process to change state, BSD style 489 wait4 (2) - wait for process to change state, BSD style 490 waitid (2) - wait for process to change state 491 waitpid (2) - wait for process to change state 492 write (2) - write to a file descriptor 493 writev (2) - read or write data into multiple buffers

由上可知,系統(tǒng)中共有 493 個 system-calls。我們分析下這一行命令:

man -s 2 -k .

短選代表的是長選項 –section,-k 是 keyword,等價于 apropos 命令,最后的 dot 點   乃是正則表達(dá)式里的任意字符的表達(dá)方式。

于是,僅僅通過上面的簡單命令獲得對整個文檔乃至整臺計算機,整個計算機科學(xué)的全局掌控感。我們迅速掠覽一遍這 9 個 sections。

Section 1 Shell Commands 系統(tǒng)命令:

$ man -s 1 -k . |nl| tail -n 5 2451 zless (1) - file perusal filter for crt viewing of compressed text 2452 zlib_decompress (1) - decompress mysqlpump ZLIB-compressed output 2453 zmore (1) - file perusal filter for crt viewing of compressed text 2454 znew (1) - recompress .Z files to .gz files 2455 zsoelim (1) - satisfy .so requests in roff input

Section 2 Syetem Calls 系統(tǒng)調(diào)用

man -s 2 -k . |nl| tail -n 5 489 wait4 (2) - wait for process to change state, BSD style 490 waitid (2) - wait for process to change state 491 waitpid (2) - wait for process to change state 492 write (2) - write to a file descriptor 493 writev (2) - read or write data into multiple buffers

Section 3 C LIbraries C 語庫

$ man -s 3 -k . |nl| tail -n 5 1899 y1l (3) - Bessel functions of the second kind 1900 yn (3) - Bessel functions of the second kind 1901 ynf (3) - Bessel functions of the second kind 1902 ynl (3) - Bessel functions of the second kind 1903 zlib (3) - compression/decompression library

Section 4 Special Files 特殊文件

$ man -s 4 -k . |nl| tail -n 5 48 veth (4) - Virtual Ethernet Device 49 vmware (4) - VMware SVGA video driver 50 wacom (4) - Wacom input driver 51 wavelan (4) - AT T GIS WaveLAN ISA device driver 52 zero (4) - data sink

Secion 5 File Format and conventions 文件格式及慣例

$ man -s 5 -k . |nl| tail -n 5 424 xorg.conf (5) - configuration files for Xorg X server 425 xorg.conf.d (5) - configuration files for Xorg X server 426 Xsession (5) - initialize X session 427 Xsession.options (5) - configuration options for Xsession (5) 428 Xwrapper.config (5) - Xorg X server binary wrapper

Secion 6 Games 游戲

$ man -s 6 -k . |nl| tail -n 5 1 intro (6) - introduction to games 2 kmahjongg (6) - Mahjongg game for KDE 3 kmines (6) - KDE mine sweeper game 4 kpat (6) - A highly addictive card game. 5 ksudoku (6) - KDE Sudoku games

Section 7 Miscellaneous (including macro packages and conventions) 雜項

$ man -s 7 -k . |nl| tail -n 5 470 XConsortium (7) - X Consortium information 471 xkeyboard-config (7) - XKB data description files 472 XOrgFoundation (7) - X.Org Foundation information 473 Xsecurity (7) - X display access control 474 XStandards (7) - X Window System Standards and Specifications

Section 8 System administration commands (usually only for root) 系統(tǒng)管理命令

$ man -s 8 -k . |nl| tail -n 5 890 xtables-nft-multi (8) - iptables using nftables kernel api 891 xtables-translate (8) - translation tool to migrate from iptables to nftables 892 zdump (8) - timezone dumper 893 zic (8) - timezone compiler 894 zramctl (8) - set up and control zram devices

Section 9 Kernel routines [Non standard] 內(nèi)核函數(shù)

? ~ man -s 9 -k . vmxnet (9) - vmware kernel module

掌控全局還有另外一種方法,就是 intro 命令:

$ man -f intro intro (8) - introduction to administration and privileged commands intro (7) - introduction to overview and miscellany section intro (3) - introduction to library functions intro (4) - introduction to special files intro (1) - introduction to user commands intro (5) - introduction to file formats and filesystems intro (6) - introduction to games intro (2) - introduction to system calls

我們看到每個 section 都有一個 intro。

比如我們查看 section 2 的 intro:

Linux 中的 Manual 手冊分析

6. 游戲

man 命令有良好的療愈功效,不妨來看看 Kubuntu 自帶的四個游戲。

$ man -s 6 -k . |nl 1 intro (6) - introduction to games 2 kmahjongg (6) - Mahjongg game for KDE 3 (6) - KDE mine sweeper game 4 kpat (6) - A highly addictive card game. 5 ksudoku (6) - KDE Sudoku games

感謝各位的閱讀,以上就是“Linux 中的 Manual 手冊分析”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對 Linux 中的 Manual 手冊分析這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是丸趣 TV,丸趣 TV 小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

正文完
 
丸趣
版權(quán)聲明:本站原創(chuàng)文章,由 丸趣 2023-08-25發(fā)表,共計8243字。
轉(zhuǎn)載說明:除特殊說明外本站除技術(shù)相關(guān)以外文章皆由網(wǎng)絡(luò)搜集發(fā)布,轉(zhuǎn)載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 龙江县| 原平市| 新和县| 武鸣县| 唐山市| 清苑县| 呼伦贝尔市| 琼中| 高台县| 曲靖市| 邓州市| 杭锦旗| 香格里拉县| 浙江省| 佛教| 东宁县| 黎平县| 虹口区| 瓮安县| 民丰县| 泰顺县| 蓬溪县| 耿马| 手机| 敦化市| 阳信县| 福泉市| 疏附县| 刚察县| 建水县| 天气| 大化| 延边| 大英县| 东阿县| 清徐县| 南木林县| 红桥区| 渝北区| 邹平县| 同仁县|