1. 程式人生 > >Linux命令學習神器!命令看不懂直接給你解釋!

Linux命令學習神器!命令看不懂直接給你解釋!

大家都知道,Linux 系統有非常多的命令,而且每個命令又有非常多的用法,想要全部記住所有命令的所有用法,恐怕是一件不可能完成的任務。

一般情況下,我們學習一個命令時,要麼直接百度去搜索它的用法,要麼就直接用 man 命令去檢視守冗長的幫助手冊。這兩個都可以實現我們的目標,但有沒有更簡便的方式呢?

答案是必須有的!今天給大家推薦一款有趣而實用學習神器 — kmdr,讓你解鎖 Linux 學習新姿勢。

kmdr 工具最大的亮點就是,如果有一個長串命令你看不懂它的用法及意義,它將直接分模組給你詳細解釋!這個功能真的是非常實用,因為我們在網上或書上難免會看到各種各樣的命令,如果你看不懂,那將永遠留下疑惑。而這個工具就像老師一樣,按模組一個個告訴你命令各個部分的用法及意義,讓你一目瞭然!

kmdr 收納了非常多的 CLI 命令解釋,例如常見的 ansible, conda, docker, git, go, kubectl, mongo, mysql, npm, ruby gems, vagrant 等等,不僅如此,那些 bash 內建命令 它都能為你解釋,非常給力!

不管你是哪個領域的程式設計師,kmdr 都能最大限度地為你提供 CLI 命令學習幫助。

  • Bash Shell 命令(如 echo,export,cd)
  • 容器(如 Docker,kubectl)
  • 版本控制(如 Git)
  • 資料庫伺服器和客戶端(如 mysql,mongod)
  • 部署/雲(如 now cloud)
  • 檔案和存檔工具(如 zip,tar)
  • 媒體(如 ffmpeg,youtube-dl)
  • 網路/通訊(如 netstat,nmap,curl)
  • 包管理器(如 dpkg,pip)
  • 程式語言/執行時環境/編譯器(如 go,python,node,gcc)
  • 系統管理 /監控(如 crontab,top)
  • 文書處理(如 awk,sed)
  • 文字編輯器(如 nano,vim)
  • 其他(如 openssl,bash,bash64)

這個連結裡可以檢視完整的支援列表:https://github.com/ediardo/kmdr-cli#supported-programs)

安裝 Kmdr CLI

kmdr 是用 Nodejs 編寫的免費開源工具,需要 Nodejs 版本 8.x 或更高版本才能執行,需要大家先準備好執行環境。

安裝好 Nodejs 之後,使用 Npm 軟體包管理器安裝 kmdr

$ npm install kmdr@latest --global

不想安裝 Nodejs 這麼麻煩?沒關係,這裡有一個網站可以讓你在 web 瀏覽器直接使用 kmdr ↓↓
http://demo.kmdr.sh/

使用 Kmdr 在終端中顯示 CLI 命令說明

下面我們通過一條複雜點的命令作為例子,來看看 kmdr 究竟有多強!

$ history | awk '{print $2}' | sort | uniq -c | sort -nr | head -5

首先,執行下面的命令,讓 kmdr 進入解釋狀態:

$ kmdr explain

接著,輸入我們上面的示例命令,然後按 ENTER 鍵:

? Enter your command: history | awk '{print $2}' | sort | uniq -c | sort -nr | head -5

history
With no options, display the command history list with line numbers.
|
A pipe serves the sdout of the previous command as input (stdin) to the next one
awk
pattern scanning and processing language
{print $2}
An argument
|
A pipe serves the sdout of the previous command as input (stdin) to the next one
sort
Sort lines of text files
|
A pipe serves the sdout of the previous command as input (stdin) to the next one
uniq
Report or omit repeated lines
-c, --count
Prefix lines by the number of occurrences
|
A pipe serves the sdout of the previous command as input (stdin) to the next one
sort
Sort lines of text files
-n, --numeric-sort
Compare according to string numerical value
-r, --reverse
Reverse the result of comparisons
|
A pipe serves the sdout of the previous command as input (stdin) to the next one
head
Output the first part of files
-5
An argument