Linux is fun! Huhhh. OK so you don't believe me. Mind me at the end
of this article you will have to believe that Linux is actually a fun
box.
Linux 是非常有趣的,别不相信 —— 看完这篇文章,你一定会发现 Linux 系统神奇的用法。
请注意,下面部分命令给出了两种包管理软件的安装方式,如果是 Debian 系的系统,请使用 apt
,如果是 Red Hat 系的系统,请使用 yum
。如果你使用了其他 Linux 发行版,或使用了其他包管理工具(例如 macOS 上的 brew),可能无法找到所有这些命令。
注:为了在代码块中区别输入输出,以 $
开头的行代表输入,其它行代表输出。
curl
命令:curl
curl 用于互联网传输数据,支持多种协议。通过以下命令可以查看天气:
$ curl -4 http://wttr.in |
sl (Steam Locomotive)
命令:sl(蒸汽机车的缩写)
You
might be aware of command 'ls' the list command and use it frequently
to view the contents of a folder but because of miss-typing sometimes
you would result in 'sl', how about getting a little fun in terminal and
not command not found
.
你一定知道 ls 是用来显示文件夹内容的常见命令,但如果不小心打成 sl 呢?通过包管理工具安装它,你就能看见一辆跑过屏幕的火车,而不是「找不到命令」:
$ apt install sl #In Debian like OS, or aptitude based system |
This command works even when you type 'LS' and not 'ls'.
telnet
命令:telnet
No!
No!! it is not as much complex as it seems. You would be familiar with
telnet. Telnet is a text-oriented bidirectional network protocol over
network. Here is nothing to be installed. What you should have is a
Linux box and a working Internet.
不!它并不像看上去那样复杂。你会熟悉它的。Telnet 是一个基于文本的双向网络协议。你无需安装它,只需要一台能够联网的 linux 机器就行。
而以下命令将会在你的命令行中生成一个 ASCII 世界地图:
$ telnet mapscii.me |
是不是很有趣?
fortune
命令:fortune What about getting your random fortune, sometimes funny in
terminal.
在终端获取随机的人生经验,听上去不错吧?
$ apt install fortune |
rev (Reverse)
命令:rev(反转的缩写)
It reverse every string given to it, is not it funny.
它会反转任何输入的字符串,然后输出。
$ rev |
factor
命令:factor Time for some Mathematics, this command output all the possible factors of a given number.
数学时间到:这个命令会输出一个数字的所有质因数。
$ factor 5 |
script
shell 脚本
OK fine this is not a command and a script but it is nice.
它会输出乘法口诀表。
$ for i in {1..9}; do for j in $(seq 1 $i); do echo -ne $i*$j=$((i*j))\\t;done; echo;done |
cowsay
命令:cowsay
An ASCII cow in terminal that will say what ever you want.
一个终端里由 ASCII 码组成的牛,你想让它说什么,它就会说什么。
$ apt install cowsay |
How about pipelineing 'fortune command', described above with cowsay?
通过管道指令将 fortune 命令的输出作为 cowsay 的输入:
$ fortune | cowsay |
Note:
'|' is called pipeline instruction and it is used where the output of
one command needs to be the input of another command. In the above
example the output of 'fortune' command acts as an input of 'cowsay'
command. This pipeline instruction is frequently used in scripting and
programming.
注意:'|' 被称为管道指令,用于将一个命令的输出作为另一个命令的输入。在上面的例子中,fortune 命令的输出作为 cowsay 命令的输入。管道指令经常用于脚本和编程。
xcowsay is a graphical program which response similar to cowsay but in a graphical manner, hence it is X of cowsay.
xcowsay 是一个图形程序,其效果类似于 cowsay,但是是以图形方式显示说话的牛。
$ apt install xcowsay |
cowthink is another command, just run cowthink Linux is sooo funny
and see the difference in output of cowsay and cowthink. cowthink 是另一个命令,你可以执行 cowthink Linux is sooo funny
看看它和 cowthink 的输出差异。
$ apt install cowthink |
注:你可以查看以上命令的帮助菜单,可以把牛换成其他会说话的动物。
yes
命令:yes
It
is funny but useful as well, specially in scripts and for System
Administrators where an automated predefined response can be passed to
terminal or generated.
它很有趣,也很实用。使用 yes,终端将会不断输出你所输入的字符串。
$ yes I Love Linux |
Note: (Till you interrupt i.e Ctrl+C).
直到你使用 Ctrl+C 结束它,否则会一直输出。
toilet
命令:toilet
What?
Are u kidding, huhh no! Definitely not, but for sure this command name
itself is too funny, and I don't know from where this command gets it's
name.
什么?你在开玩笑吗,不!绝对不是,但肯定这个命令名称本身太有趣了,我不知道这个命令从哪里得到它的名字。
$ apt install toilet |
It even offers some kind of color and fonts style.
它甚至提供了颜色和字体样式。
$ toilet -f mono12 -F metal mimi.com |
Note: Figlet is another command that more or less provide such kind of effect in terminal.
注意:Figlet 是另一个或多或少在终端提供这种效果的命令。
cmatrix
命令:cmatrix
You
might have seen Hollywood movie 'matrix' and would be fascinated with
power, Neo was provided with, to see anything and everything in matrix
or you might think of an animation that looks alike Hacker's desktop.
你可能已经看过好莱坞电影《黑客帝国》,并且会被 Neo 获取的力量所吸引 —— 在矩阵中看到一切;或许你也会想到一个看起来和 Hacker 的桌面一样的动画。
$ apt install cmatrix |
yum 上似乎找不到,可以使用源码编译安装。
oneko
命令:oneko
OK
so you believe that mouse pointer of Linux is the same silly
black/white pointer where no animation lies then I fear you could be
wrong. oneko
is a package that will attach a "Jerry" with you mouse pointer and moves along with you pointer.
如果你觉得 Linux 的鼠标就是一个愚蠢的黑色 / 白色指针,而没有动画,我担心你可能是错的。使用 oneko
命令,就可以创造一只与你的鼠标指针玩耍的猫。
$ apt install oneko |
Note:
Once you close the terminal from which oneko was run, jerry will
disappear, nor will start at start-up. You can add the application to
start up and continue enjoying.
注意:一旦你关闭了运行 oneko 的终端,小猫就会消失。你可以把它添加到开机启动中,继续享受撸猫的乐趣。
while
命令:while
The below while
command is a script which provides you with colored date and file till you interrupt (Ctrl+C). Just copy and paste the below code in terminal.
下面的 while
命令是一个脚本,它会为你提供彩色日期和文件,直到你用 Ctrl+C 中断。只需在终端中复制并粘贴以下代码即可。
$ while true; do echo "$(date '+%D %T' | toilet -f term -F border --gay)"; sleep 1; done |
Note:
The above script when modified with following command, will gives
similar output but with a little difference, check it in your terminal.
注意:上面的脚本在使用以下命令修改后,会给出类似的输出,但有一点区别,请在终端中检查它。
$ while true; do clear; echo "$(date '+%D %T' | toilet -f term -F border --gay)"; sleep 1; done |
espeak
命令:espeak
Just
Turn the Knob of your multimedia speaker to full before pasting this
command in your terminal and let us know how you felt listening the
god's voice.
在将此命令粘贴到终端之前,请将你的音箱音量开到最大,让我们知道你是如何聆听上帝的声音的。
$ apt install espeak |
aafire
命令:aafire
How about fire in your terminal. Just type aafire
in the terminal, without quotes and see the magic. Press any key to interrupt the program.
在你的终端放火,听上去如何?只需在终端输入 aafire
,就可以看到神奇的现象。按任意键中断程序。
$ apt install libaa-bin |
bb
命令:bb
First install apt insatll bb
and then, type bb
in terminal and see what happens.
首先用 apt
安装 bb
命令,然后在终端输入 bb
,看看会发生什么。
$ apt install bb |
注:需要图形界面。
url
命令:url
Won't
it be an awesome feeling for you if you can update you twitter status
from command line in front of your friend and they seems impressed. OK
just replace username, password and your status message with your's
username, password and "your status message".
如果你可以在你的朋友面前通过命令行更新你的
Twitter 状态,这绝对是超棒的感觉 —— 而且他们也会印象深刻。好的,只需把下面的 YourUsername,YourPassword 和
Your status message 替换为你自己的用户名,密码和状态信息即可。
$ url -u YourUsername:YourPassword -d status="Your status message" http://twitter.com/statuses/update.xml |
ASCIIquarium
命令:ASCIIquarium
How it will be to get an aquarium in terminal.
怎样才能在终端获得一个水族馆?
$ apt install libcurses-perl |
Now Download and Install ASCIIquarium.
现在下载并安装 ASCIIquarium。
$ cd /tmp |
And finally run asciiquarium
or /usr/local/bin/asciiquarium
in terminal without quotes and be a part of magic that will be taking place in front of your eyes.
最后在终端中运行 asciiquarium,水族馆便展现在你面前。
$ asciiquarium |
更多
Have fun, you can say me thanks later :) yup your comment is highly appreciated which encourages us write more. Tell us which command you liked the most. Stay tuned i will be back soon with another article worth reading.
本文翻译自:20 Funny Commands of Linux or Linux is Fun in Terminal
拓展阅读:
扫盲 Linux&UNIX 命令行 —— 从 “电传打字机” 聊到 “shell 脚本编程”
计算机领域有哪些经典的典故或笑话?
一行代码可以做什么?
the-art-of-command-line
No comments:
Post a Comment