Linux 命令總記不???一招幫你搞定!

對于 Linux 用戶來說,man 應該是最常用的命令之一了,它主要用于顯示某個命令/實用程序的詳細說明,通常被稱為 “手冊頁”。
雖然 man 很強大,但卻時常會讓人崩潰,滿屏的選項和解釋,簡直是又臭又長。為了解決這一問題,tldr 應運而生了。

Life is short, You need tldr
tldr是『Too Long; Didn't Read』的縮寫,形容太長而不值得一讀的意思(這不就是指的man嗎)。它簡化了煩瑣的man幫助文檔,僅列出了 Linux 命令中最常用的一些用法,簡潔清晰、自然易懂。GitHub地址:https://github.com/tldr-pages/tldr
1 安裝 tldr
tldr 有多種語言(例如:Python、Go、Node.js 等)編寫的客戶端,但據(jù)官網(wǎng)所述,目前最成熟的客戶端是基于 Node.js 的,可以使用 npm 包管理器輕松地安裝它。
如果之前沒有安裝過 nodejs 和 npm,需要先進行安裝:
$ sudo apt install nodejs
$ sudo apt install npm
為了方便后續(xù)快速下載,更新一下 npm 的包鏡像源:
$ sudo npm config set registry https://registry.npm.taobao.org
全局安裝 n 管理器,并升級 nodejs 為最新穩(wěn)定版:
$ sudo npm install -g n
$ sudo n stable
隨后,就可以安裝 tldr 客戶端了:
$ sudo npm install -g tldr
一旦安裝完成,最好在使用之前更新下緩存:
$ tldr --update
2 基本用法
tldr 的使用非常簡單,后面直接跟想要查詢的命令就可以啦!
來看一個例子,顯示 tar 命令的相關文檔:
$ tldr tar
tar
Archiving utility.Often combined with a compression method, such as gzip or bzip.More information: https://www.gnu.org/software/tar.
- Create an archive from files:
tar cf {{target.tar}} {{file1}} {{file2}} {{file3}}
- Create a gzipped archive:
tar czf {{target.tar.gz}} {{file1}} {{file2}} {{file3}}
- Create a gzipped archive from a directory using relative paths:
tar czf {{target.tar.gz}} -C {{path/to/directory}} .
- Extract a (compressed) archive into the current directory:
tar xf {{source.tar[.gz|.bz2|.xz]}}
- Extract a (compressed) archive into the target directory:
tar xf {{source.tar[.gz|.bz2|.xz]}} -C {{directory}}
- Create a compressed archive, using archive suffix to determine the compression program:
tar caf {{target.tar.xz}} {{file1}} {{file2}} {{file3}}
- List the contents of a tar file:
tar tvf {{source.tar}}
- Extract files matching a pattern:
tar xf {{source.tar}} --wildcards "{{*.html}}"
- Extract a specific file without preserving the folder structure:
tar xf {{source.tar}} {{source.tar/path/to/extract}} --strip-components={{depth_to_strip}}
怎么樣,可以很容易地找到命令的具體用法吧!
如果要顯示幫助頁面,執(zhí)行命令:
$ tldr --help
哈哈,絕對的神器,Cheers!
·END·
評論
圖片
表情
