|
大家都知道,Linux 系统有非常多的命令,而且每个命令又有非常多的用法,想要全部记住所有命令的所有用法,恐怕是一件不可能完成的任务。 一般情况下,我们学习一个命令时,要么直接百度去搜索它的用法,要么就直接用 man 命令去查看守冗长的帮助手册。这两个都可以实现我们的目标,但有没有更简便的方式呢?2 [* I n5 _: V) ], F, _ 1 _ w1 ~2 ]. @! L+ ~7 z+ K( t # U5 C. X6 u& L- Q% w: K) @ Y 答案是必须有的!今天给大家推荐一款有趣而实用学习神器 — kmdr,让你解锁 Linux 学习新姿势。 # Q' J# \ X! [ 5 j( t) a8 r6 [) R* q kmdr 工具最大的亮点就是,如果有一个长串命令你看不懂它的用法及意义,它将直接分模块给你详细解释!这个功能真的是非常实用,因为我们在网上或书上难免会看到各种各样的命令,如果你看不懂,那将永远留下疑惑。而这个工具就像老师一样,按模块一个个告诉你命令各个部分的用法及意义,让你一目了然! 3 ]9 q' s4 [4 ?% ]/ y/ b) V) ? kmdr 收纳了非常多的 CLI 命令解释,例如常见的 ansible, conda, docker, git, go, kubectl, mongo, mysql, npm, ruby gems, vagrant 等等,不仅如此,那些 bash 内置命令 它都能为你解释,非常给力! 不管你是哪个领域的程序员,kmdr 都能最大限度地为你提供 CLI 命令学习帮助。4 H" y8 b8 ]& l9 X0 g 7 ]% `0 p4 I# T' g0 R* E Bash Shell 命令(如 echo,export,cd) 容器(如 Docker,kubectl) 版本控制(如 Git) 数据库服务器和客户端(如 mysql,mongod) 部署/云(如 now cloud) 文件和存档工具(如 zip,tar) 媒体(如 ffmpeg,youtube-dl), r4 T5 M e% C$ c 网络/通讯(如 netstat,nmap,curl)5 R3 Z, p6 C- D( B3 L 包管理器(如 dpkg,pip) 编程语言/运行时环境/编译器(如 go,python,node,gcc) 系统管理 /监控(如 crontab,top)" b9 {' Q& x3 v0 g 文字处理(如 awk,sed)6 a4 W/ p. v( f 文本编辑器(如 nano,vim) 其他(如 openssl,bash,bash64) 这个链接里可以查看完整的支持列表:http://github.com/ediardo/kmdr-cli#supported-programs) . Z0 y) @* ^- _! e5 d' n 0 L" ]5 |( {2 y5 K0 U) s 安装 Kmdr CLI/ r! g+ y! b! j# q( _! B! | 1 p; V( ?; |' s6 M' s 3 }# h; X: K3 G. H! S2 ` 7 `2 K3 P* ?# x1 z- k 2 `; c- ?' W2 q- y7 I: A' Z kmdr 是用 Nodejs 编写的免费开源工具,需要 Nodejs 版本 8.x 或更高版本才能运行,需要大家先准备好运行环境。 # K; T( }( J+ l + B0 e1 Y2 k0 ?9 I: ?. } 安装好 Nodejs 之后,使用 Npm 软件包管理器安装 kmdr:- _" s5 ^( Y$ W3 a" ? 1 P( O" e9 j3 t5 N $ npm install kmdr@latest --global 不想安装 Nodejs 这么麻烦?没关系,这里有一个网站可以让你在 web 浏览器直接使用 kmdr ↓↓ 9 G* E) s; m+ g1 B& c http://demo.kmdr.sh/4 C: u; m$ R; X$ l4 e. x - L7 v2 L& Z' R 8 q1 B% d* z) m9 a/ E " @. s% y8 S# E- b 使用 Kmdr 在终端中显示 CLI 命令说明6 [2 x- ~. r4 y. `3 h' `; } b' K) n5 k# R. p$ p9 a$ f5 F - `1 W+ C! O; k' R& w9 \0 Q6 e # S& V# |" U! ]* [ Y* J 下面我们通过一条复杂点的命令作为例子,来看看 kmdr 究竟有多强! $ history | awk '{print $2}' | sort | uniq -c | sort -nr | head -5- F- Y+ G' @/ S2 | 首先,运行下面的命令,让 kmdr 进入解释状态: $ kmdr explain; o; I2 N7 j% A$ ?# v9 ~3 t0 G 接着,输入我们上面的示例命令,然后按 ENTER 键: 8 [* B# o& J" ?+ w# f 3 r+ Y# F) l/ o ? Enter your command: history | awk '{print $2}' | sort | uniq -c | sort -nr | head -5 & |+ p2 I; J* H x; ?, k# f F. ?4 b history With no options, display the command history list with line numbers. | Y- ]0 R# l I1 G6 k) U A pipe serves the sdout of the previous command as input (stdin) to the next one- @( V7 j* [0 t% ?# ^) r2 Q awk: J" M3 f7 s5 ?( O. ^$ \2 b6 G pattern scanning and processing language- S ?: c. H5 t1 M, V$ m8 G C% D {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# m3 D! P2 D) c4 }& t2 Y# C |. {! ?/ P$ a5 k1 v0 z- O A pipe serves the sdout of the previous command as input (stdin) to the next one uniq7 k8 X3 p' V- A* v) x% U Report or omit repeated lines. F8 v0 @% r# F7 o; q6 { -c, --count; Q4 K( J8 j% [7 ~1 \9 F! c Prefix lines by the number of occurrences | A pipe serves the sdout of the previous command as input (stdin) to the next one" v; h+ D5 c) m f9 U+ G4 P3 o7 n sort5 |% A% y% R0 T' [" y Sort lines of text files -n, --numeric-sort' R& `" E0 }- w4 r# ~/ I Compare according to string numerical value0 L7 J. y6 u0 U8 n1 x' X -r, --reverse Reverse the result of comparisons1 t: Q5 D9 B ]$ W9 v |3 H+ S( C3 k* F) r A pipe serves the sdout of the previous command as input (stdin) to the next one% @% b( G5 Y" g- r0 w+ e, Q head9 h: O3 |" u4 `) u2 \ Output the first part of files% G$ Q" v6 O6 Z8 y/ Y. \2 `. W -5( l4 a. I& g; }( k7 F! w An argument. p4 X9 A( l5 B4 ] |
微信公众号
手机版