Linux的10個彩蛋

Linux的10個彩蛋
每當你打開的Linux虛擬主機的時候,通常是爲了完成工作。但是,一臺普通的Linux主機上,有成千上萬的開發者開發的軟件,你能保證他們都是這麼正經的?

Linux的軟件有加一些有趣的彩蛋的傳統。本文主要是介紹一些有趣的命令和選項,讓你的生活更多彩一些。這些並非全是彩蛋,不過我相信你多少會喜歡它們的。

文本編輯器

vim和Douglas Adams

熟悉Douglas Adams(也就是The Hitchhiker’s Guide to the Galaxy一書的作者)的人,vim編輯器有個幫忙選項會讓你讚不絕口。

如果你還沒裝vim。在Ubuntu/Debian,你可以這樣:

sudo apt-get install vim

在CentOS/Fedora裏,可以:

sudo yum install vim

在命令行打開vim:

vim

輸入以下命令打開vim的一個特殊的幫助菜單:

:help 42
What is the meaning of life, the universe and everything?Douglas Adams, the only person who knew what this question really was about is now dead, unfortunately.  So now you might wonder what the meaning of death is

想退出vim的話,敲兩遍這個:

:q
:q

Emacs遊戲

從未敗績,除了廚房水槽外包羅萬象無所不有的著名文本編輯器, Emacs,它裏面包含的遊戲多的讓你乍舌,直接在編輯器裏就能玩。

首先,你得先裝一下Emacs,在Ubuntu/Debian,你可以這樣:

sudo apt-get install emacs

在CentOS/Fedora裏,可以:

sudo yum install emacs

看下這個目錄你會發現有很多的遊戲:

cd /usr/share/emacs/*/lisp/play
ls
5x5.elc       decipher.elc    gametree.elc   meese.elc      spook.elc
animate.elc   dissociate.elc  gomoku.elc     morse.elc      studly.elc
blackbox.elc  doctor.elc      handwrite.elc  mpuz.elc       tetris.elc
bruce.el      dunnet.elc      hanoi.elc      pong.elc       yow.elc
bubbles.elc   fortune.elc     landmark.elc   snake.elc      zone.elc
cookie1.elc   gamegrid.elc    life.elc       solitaire.elc

運行它們的話,先打開Emacs:

emacs

然後同時按下Esc鍵和x(執行),然後輸入你想玩的遊戲的名字:

Esc-x
pong

https://assets.digitalocean.com/articles/easter_eggs/emacs_pong.png” />

要退出Emacs的話,同時按下ctrl鍵和x,然後是ctrl+c:

Ctrl-x
Ctrl-c

Apt命令

apt-get的超級牛力

在Ubuntu和Debian上,apt-get這個包管理器很久以來一直都內嵌着一個彩蛋。

如果你輸入一個apt-get的幫助命令,你會得到個這樣的提示:

apt-get help
. . .
. . .
  -c=? Read this configuration file
  -o=? Set an arbitrary configuration option, eg -o dir::cache=/tmp
See the apt-get(8), sources.list(5) and apt.conf(5) manual
pages for more information and options.
                       This APT has Super Cow Powers.
這個APT有着超級牛力

如果看到最後一行的提示說明這個版本的apt是支持這個彩蛋的。再輸入一個:

apt-get moo
         (__)
         (oo)
   /------\/
  / |    || 
 *  /\---/\
    ~~   ~~ 
...."Have you mooed today?"

Aptitude的呢?

看到apt-get和牛的曖昧關係,用戶不禁會想,另一個apt工具aptitude是不是也有這個有趣的彩蛋呢?

我們像之前那樣再試一下:

aptitude help
. . .
. . .
 -u             Download new package lists on startup.
                  (terminal interface only)
 -i             Perform an install run on startup.
                  (terminal interface only)

                  This aptitude does not have Super Cow Powers.
這個aptitude沒有超級牛力。

太令人失望了。再試下別的方式:

aptitude moo
There are no Easter Eggs in this program(這個程序沒有彩蛋).

太直白了吧。不過堅持很重要。我們再試下有沒有更多信息:

aptitude -v moo
There really are no Easter Eggs in this program.(這個程序真的沒有彩蛋)

再來:

aptitude -vv moo
Didn't I already tell you that there are no Easter Eggs in this program?
我不是告訴過你這個程序沒有彩蛋了嗎?

不過你再不停的加v的話,最終你會看到這個:

aptitude -vvvvv moo
All right, you win.好吧,你贏了。

                               /----\
                       -------/      \
                      /               \
                     /                |
   -----------------/                  --------\
   ----------------------------------------------

不過這看着不大像。我們再加一個v:

aptitude -vvvvvv moo
What is it?  It's an elephant being eaten by a snake, of course.
這是什麼?這就是一條蛇吞了一隻大象.(看不懂的請自覺搜索小王子)

這裏引用了Antoine de Saint-Exupéry的《小王子》書裏的一句話。
常見程序的另類參數

在一些常見的程序中也有些奇怪的參數,這你一定會很好奇。

用sudo來羞辱用戶

你可以配置sudo(用來給命令授權的),來羞辱那些輸錯密碼的用戶。

想這麼做的話,先用個visudo的工具編輯下sudoers文件,這個工具用來編輯sudo配置文件並且進行修改的校驗。

sudo visudo

在文件頂部,加上這麼一行:

Defaults insults

然後保存並且關閉文件。

然後,清空密碼的緩存,然後在sudo命令裏輸入錯的密碼:

sudo -k
sudo ls
[sudo] password for demo: # 輸入一個錯的密碼
Have you considered trying to match wits with a rutabaga?(你這是在開玩笑麼,)?
[sudo] password for demo:
My pet ferret can type better than you!(我的寵物鼬都能敲的比你好!)
[sudo] password for demo:
Wrong!  You cheating scum! (不對!你個騙子!)

腳本小子的Nmap輸出

Nmap是一款網絡檢測工具,它可以用來進行系統的安全檢查。

在Ubuntu/Dedian上安裝一下它:

sudo apt-get install nmap

在CentOS/Fedora上面這樣:

sudo yum install nmap

Nmap提供了這麼一個選項,讓它能把數據輸出成“腳本小子”的那種格式。

我們先來看下正常的格式是什麼樣的,用Nmap來檢測下它自己的網站:

nmap scanme.nmap.org
Starting Nmap 5.21 ( http://nmap.org ) at 2013-09-18 17:43 UTC
Nmap scan report for scanme.nmap.org (74.207.244.221)
Host is up (0.072s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 1.40 seconds

我們來加個選項調整下輸出的格式:

$tart|ng NMap 5.21 ( http://Nmap.org ) at 2013-09-18 17:45 UTC
Nmap $cAn r3p0rt F0r scanM3.nmaP.oRg (74.207.244.221)
Ho$t 1z Up (0.071z laT3ncy).
Not sh0wN: 998 cl0$Ed p0rt$
POrT   ST4TE $ERV!C3
22/tcp opEn  Ssh
80/tcP 0p3n  HtTp

Nmap d0n3: 1 iP AddrESz (1 h0$t Up) $canNed !n 1.34 secondz

其實它就是用看起來相近的字符替換了原有的字符,讓結果看起來更有“黑客範”一點。

命令行的星球大戰

終端裏就有兩款網絡版的命令行的星球大戰。

用telnet觀看ASCII版的星球大戰影片

Simon Jansen, Sten Spans, 和Mike Edwards用ASCII模擬了一個完整的星球大戰影片,你可以用telnet來觀看它。

首先,如果沒有安裝的話,下載一下telnet,它是ssh的先驅:

在Ubuntu/Debian上面:

sudo apt-get install telnet

在CentOS/Fedora上面:

sudo yum install telnet

然後你只要連上正確的服務器就可以了:

telnet towel.blinkenlights.nl
                                 /~\                             
       R2-D2!                   |oo )                            
   Where are you?         #     _\=/_    #                       
                           \\  /  _  \  //                       
                            \\//|/.\|\\//                        
                             \/  \_/  \/                         
                                |\ /|                            
                                \_ _/                            
                                | | |                            
                                | | |                            
                                []|[]                            
                                | | |                            
_______________________________/_]_[_\_____________________________

如果你不想看了,按下ctrl+]。會有一個提示,然後你輸入”close”就行了:

Ctrl-]
close

星球大戰版traceroute

還有一份獻禮是Ryan Werber送上的,他把網絡的節點全都命名成特殊的地址了。

如果你運行traceroute,一個跟蹤網絡包到遠程機器的路徑的程序,你會在網絡節點名上看到星球大戰的介紹。

就敲一下:

traceroute -m 254 -q1 obiwan.scrye.net

路由信息就會不斷產生了。經過幾跳後,奇蹟發生了:

. . .
. . .
15  Episode.IV (206.214.251.1)  77.506 ms
16  A.NEW.HOPE (206.214.251.6)  87.194 ms
17  It.is.a.period.of.civil.war (206.214.251.9)  77.699 ms
18  Rebel.spaceships (206.214.251.14)  78.171 ms
19  striking.from.a.hidden.base (206.214.251.17)  87.624 ms
20  have.won.their.first.victory (206.214.251.22)  86.249 ms
21  against.the.evil.Galactic.Empire (206.214.251.25)  77.505 ms
22  During.the.battle (206.214.251.30)  85.622 ms
23  Rebel.spies.managed (206.214.251.33)  78.121 ms
24  to.steal.secret.plans (206.214.251.38)  77.049 ms
. . .


在第4,5,6幕介紹完後,Ryan開始自娛自樂起來了:

99  Were.no.strangers.to.love (206.214.251.206)  77.472 ms
100  You.know.the.rules.and.so.do.I (206.214.251.209)  78.054 ms
101  A.full.commitments.what.Im.thinking.of (206.214.251.214)  78.512 ms
102  I.just.wanna.tell.you.how.Im.feeling (206.214.251.217)  79.884 ms
103  Gotta.make.you.understand (206.214.251.222)  79.427 ms
104  Never.gonna.give.you.up (206.214.251.225)  77.032 ms
105  Never.gonna.let.you.down (206.214.251.230)  78.909 ms
106  Never.gonna.run.around.and.desert.you (206.214.251.233)  80.286 ms

純粹找樂子的程序

拼寫錯誤

如果你想要用ls列出目錄下的文件卻敲成了sl,那你可能會想安裝一下sl這個程序。

在Ubuntu/Debian上面:

sudo apt-get install sl

在CentOS/Fedora上面:

sudo yum install sl

現在,如果你不小心敲成了sl,你一定會樂了:

                        (  ) (@@) ( )  (@)  ()    @@    O     @     O     @
                   (@@@)
               (    )
            (@@@@)

          (   )
      ====        ________                ___________
  _D _|  |_______/        \__I_I_____===__|_________|
   |(_)---  |   H\________/ |   |        =|___ ___|      _________________
   /     |  |   H  |  |     |   |         ||_| |_||     _|                \___
  |      |  |   H  |__--------------------| [___] |   =|
  | ________|___H__/__|_____/[][]~\_______|       |   -|
  |/ |   |-----------I_____I [][] []  D   |=======|____|______________________
__/ =| o |=-~~\  /~~\  /~~\  /~~\ ____Y___________|__|________________________
 |/-=|___|=O=====O=====O=====O   |_____/~\___/          |_D__D__D_|  |_D__D__D
  \_/      \__/  \__/  \__/  \__/      \_/               \_/   \_/    \_/   \

會有一輛火車呼嘯而過。

cowsay和Fortune

如果你想玩點簡單腦殘的,而apt那些牛又不能滿足你,那你可以試試cowsay和fortune。

在Ubuntu/Debian上:

sudo apt-get install fortune cowsay

在CentOS/Fedora上:

sudo yum install fortune cowsay

cowsay會用ASCII畫一頭牛出來,你輸入什麼,這牛就說什麼。

cowsay "hello, I'm a cow”
__________________
< hello, I'm a cow >
 ------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

fortune程序則會說一些語錄,運程,笑話或者廢話什麼的,這些可以拿來傳給cowsay程序:

cowsay "hello, I'm a cow”
________________________________________
/ Q: What looks like a cat, flies like a \
| bat, brays like a donkey, and          |
|                                        |
\ plays like a monkey? A: Nothing.       /
 ----------------------------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

如果你對牛不太感冒,那麼還可以換成別的角色:

fortune | cowsay -f tux
_____________________________________
/ You never know how many friends you \
| have until you rent a house on the  |
\ beach.                              /
 -------------------------------------
   \
    \
        .--.
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
    \___)=(___/

想知道cowsay都支持哪些角色,輸入下:

cowsay -l
Cow files in /usr/share/cowsay/cows:
apt beavis.zen bong bud-frogs bunny calvin cheese cock cower daemon default
dragon dragon-and-cow duck elephant elephant-in-snake eyes flaming-sheep
ghostbusters gnu head-in hellokitty kiss kitty koala kosh luke-koala
mech-and-cow meow milk moofasa moose mutilated pony pony-smaller ren sheep
skeleton snowman sodomized-sheep stegosaurus stimpy suse three-eyes turkey
turtle tux unipony unipony-smaller vader vader-koala www

我個人是比較喜歡劍龍:

fortune | cowsay -f stegosaurus
_________________________________________
/ Q: What lies on the bottom of the ocean \
\ and twitches? A: A nervous wreck.       /
 -----------------------------------------
\                             .       .
 \                           / `.   .' "
  \                  .---.  <    > <    >  .---.
   \                 |    \  \ - ~ ~ - /  /    |
         _____          ..-~             ~-..-~
        |     |   \~~~\.'                    `./~~~/
       ---------   \__/                        \__/
      .'  O    \     /               /       \  "
     (_____,    `._.'               |         }  \/~~~/
      `----.          /       }     |        /    \__/
            `-.      |       /      |       /      `. ,~~|
                ~-.__|      /_ - ~ ^|      /- _      `..-' 
                     |     /        |     /     ~-.     `-. _  _  _
                     |_____|        |_____|         ~ - . _ _ _ _ _>

總結

這篇文章不會傳授你什麼重要的知識或者提高你的Linux水平啥的,就是希望能你能稍微放鬆一下,有可能的話多探索一下你的系統。

原創文章轉載請註明出處:deepinmind
http://www.open-open.com/lib/view/open1394512279036.html

發佈了38 篇原創文章 · 獲贊 166 · 訪問量 31萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章