別再說 Linux 枯燥,這八個趣味命令讓你玩到停不下來
本文我將基于Ubuntu系統來詳解八個有趣的Linux命令。下面,我們一起來看。
1. 動力火車:sl
這是一個小彩蛋命令,在終端中輸入 sl,會看到一個小火車經過。專門為“手滑”把 ls 打成 sl 而設計的。
(1) 安裝
sudo apt install sl
可執行文件默認安裝在/usr/games,需要添加環境變量:
vi /etc/profile
export PATH=$PATH:/usr/games
# 使文件生效
source /etc/profile
(2) 使用
sl
(3) 效果
2. 黑色帝國:cmatrix
這個命令是模擬《黑客帝國》中的字符流,有非常酷炫且神秘的屏幕效果。
(1) 安裝
sudo apt install cmatrix
(2) 使用
cmatrix
# 字符流顯示為紅色
cmatrix -C red
# 字符流顯示為藍色
cmatrix -C blue
(3) 效果
3. 水族館:asciiquarium
asciiquarium 并不在所有Linux系統的官方軟件庫中,所以在Ubuntu、Debian等系統上可能無法直接通過 apt 安裝。解決方法是通過手動安裝來獲取它。
(1) 安裝 Perl 及必要的依賴
asciiquarium 是用 Perl 編寫的,需要安裝 Perl 以及相關模塊。
apt install perl libcurses-perl
(2) 下載 asciiquarium
使用 wget 命令直接從官方資源下載 asciiquarium 的代碼。
wget http://www.robobunny.com/projects/asciiquarium/asciiquarium.tar.gz
(3) 解壓下載的文件
tar -xzf asciiquarium.tar.gz
(4) 將 asciiquarium 文件移動到 /usr/bin
把解壓后的 asciiquarium 文件復制到系統路徑下,方便在任何地方調用。
sudo cp asciiquarium_1.1/asciiquarium /usr/bin
(5) 添加執行權限
確保 asciiquarium 文件具有執行權限。
sudo chmod +x /usr/local/bin/asciiquarium
asciiquarium 依賴于 Term::Animation 模塊,但默認情況下該模塊沒有安裝。可以通過 cpan(Perl的包管理工具)來安裝它
使用 cpan 安裝 Term::Animation 如果還沒有安裝 cpan,可以先執行以下命令:
sudo apt install cpanminus
安裝完成后,執行以下命令來安裝 Term::Animation 模塊:
sudo cpanm Term::Animation
(6) 驗證安裝
安裝完成后,可以運行 asciiquarium 來測試是否還會出現錯誤。如果沒有錯誤提示,說明依賴項已正確安裝。
可能出現的問題及解決 如果 cpan 安裝過程較慢或失敗,可以嘗試使用以下命令進行重新安裝:
sudo apt install libterm-animation-perl
(7) 使用
asciiquarium
(8) 效果
4. 俄羅斯方塊:bastet
bastet 是終端中的俄羅斯方塊游戲,可以在終端中直接玩。
(1) 安裝
apt install bastet -y
(2) 使用
安裝完成后,直接輸入 bastet 命令即可啟動游戲:
bastet
(3) 效果
5. 會說話的牛:cowsay
讓一只“ASCII奶牛”在終端顯示一段文字,十分有趣!
(1) 安裝
sudo apt install cowsay
(2) 使用
cowsay "hello abin"
# 可以查看他支持哪些動物
root@user:~# cowsay -l
Cow files in /usr/share/cowsay/cows:
apt bud-frogs bunny calvin cheese cock cower daemon default dragon
dragon-and-cow duck elephant elephant-in-snake eyes flaming-sheep fox
ghostbusters gnu hellokitty kangaroo kiss koala kosh luke-koala
mech-and-cow milk moofasa moose pony pony-smaller ren sheep skeleton
snowman stegosaurus stimpy suse three-eyes turkey turtle tux unipony
unipony-smaller vader vader-koala www
# 顯示大象
cowsay -f elephant "hello abin"
# 顯示龍
cowsay -f dragon "hello abin"
# 可以加個顏色,幫你打印出來一個有顏色的動物圖案
cowsay -f dragon "hello abin" |lolcat
(3) 效果
6. 使用字符生成藝術圖片:boxes
給文本添加框架的工具,可以生成各種ASCII圖形的框,用來美化終端輸出。
(1) 安裝
apt install boxes
(2) 使用
# 顯示貓
echo "Hello, Lige!" | boxes -d cat
# 顯示狗
# 添加顏色,結合lolcat使用
echo "Hello, Linux!" | boxes -d dog |lolcat
echo "Hello, Linux!" | boxes -d cat |lolcat
7. 顯示系統信息:neofetch
顯示系統的漂亮信息,包括操作系統、內核、內存等詳細信息,同時展示系統的LOGO。
(1) 安裝
sudo apt install neofetch
(2) 使用
neofetch
(3) 效果
8. 假裝忙碌神器:hllowood
Hollywood 是一個在Ubuntu上非常有趣的“假裝忙碌”工具,通過在終端中顯示各種炫酷的代碼效果,模擬一系列黑客界面效果。
(1) 安裝 Hollywood
sudo apt install hollywood -y
(2) 安裝依賴項
Hollywood 依賴于 byobu、tmux 等終端管理工具,安裝命令通常會自動處理這些依賴,但為了確保可以正常運行,可以手動安裝它們:
sudo apt install byobu -y
(3) 使用
hollywood
(4) 效果
運行后,您的終端會顯示類似黑客電影中的各種代碼和數據流,非常適合在公開場合“假裝繁忙”。