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

幫你精通Linux:從Manual手冊(cè)中獲得全局掌控感

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

[[357449]]

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

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

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

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

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

man可能是唯一一個(gè)可以自我陳述的命令。我們先從最直覺(jué)的使用方法開(kāi)始。

  1. man man 

  

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

  • 前三項(xiàng)是commands(shell-commands, system-calls,libraries)
  • 接著是files(special-file,file-format)
  • 然后是Miscellaneous, Game也放在這里
  • 最后是System(Administation,Kernel)

2.存放地址

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

  • 配置文件在/etc/目錄下,具體則為/etc/manpath.config;
  • 變量文件在/var/目錄下,具體則為/var/cache/man/index.(bt|db|dir|pag)

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

man文件本身存儲(chǔ)在/usr/share目錄下,/usr/share/man

如何查看特定命令的存儲(chǔ)位置呢?需要 -w選項(xiàng)(對(duì)應(yīng)長(zhǎng)選項(xiàng)--where)

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

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

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

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

作為補(bǔ)充,我們也可以用-f選項(xiàng)查看命令所屬的sections。

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

 此處的 -f 等價(jià)于--whatis

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

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

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

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

 幫你精通Linux:從Manual手冊(cè)中獲得全局掌控感

  1. man  7 time 

 幫你精通Linux:從Manual手冊(cè)中獲得全局掌控感

 4.正則查詢

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

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

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

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

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

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

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

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

 5.全局掌控

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

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

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

  1. man -s 2 -k .  

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

于是,僅僅通過(guò)上面的簡(jiǎn)單命令獲得對(duì)整個(gè)文檔乃至整臺(tái)計(jì)算機(jī),整個(gè)計(jì)算機(jī)科學(xué)的全局掌控感。我們迅速掠覽一遍這9個(gè)sections。

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

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

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

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

 Section 3 C LIbraries C語(yǔ)庫(kù) 

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

 Section 4 Special Files 特殊文件 

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

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

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

 Secion 6 Games 游戲 

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

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

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

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

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

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

  1. ➜  ~ man -s 9 -k . 
  2. vmxnet (9)           - vmware kernel module 

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

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

 我們看到每個(gè)section都有一個(gè)intro。

比如我們查看section 2的intro:

幫你精通Linux:從Manual手冊(cè)中獲得全局掌控感

 6.游戲

man命令有良好的療愈功效,不妨來(lái)看看Kubuntu自帶的四個(gè)游戲。

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

 7.收尾總結(jié)

man命令是我們最好的陪伴,幫助滿血復(fù)活對(duì)工作和生活的掌控感。

 

責(zé)任編輯:姜華 來(lái)源: 今日頭條
相關(guān)推薦

2021-04-01 10:16:01

EmacsJavaScript elisp

2025-02-24 10:07:10

2010-11-15 14:12:00

德訊

2020-12-21 10:55:41

Linux系統(tǒng)ls命令

2012-02-29 00:49:06

Linux學(xué)習(xí)

2021-01-13 11:25:12

JavaScript閉包函數(shù)

2020-12-17 08:14:30

Linuxrsync備份

2011-06-27 09:40:09

Linux歷史命令

2011-09-29 11:22:47

Linux 歷史命令

2023-09-24 23:40:54

Python變量

2022-11-07 11:16:30

大數(shù)據(jù)數(shù)據(jù)倉(cāng)庫(kù)Hadoop

2020-03-12 13:09:02

編程數(shù)據(jù)科學(xué)代碼

2020-04-29 10:35:45

遠(yuǎn)程工作員工CIO

2010-04-21 13:30:24

Linux rpm命令

2009-12-24 11:29:42

ipvsadm命令

2012-01-09 11:25:34

2019-01-04 08:00:59

Linux硬件容器

2009-12-10 16:21:42

Fedora Linu

2011-03-02 11:30:02

vsFTPd
點(diǎn)贊
收藏

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