28条超有趣的Linux命令
28条有趣的Linux命令,假装自己是命令行黑客高手。这些命令可以在树莓派和Ubuntu系统上运行,有些还可以在Windows的DOS命令行中运行。
看完视频后食用本文更佳
作者:张子豪(同济大学在读研究生)
关注微信公众号 人工智能小技巧 回复 linux有趣命令 即可看到本文最新版。
知乎专栏:人工智能小技巧,所有文章欢迎转载!
简书专栏:人工智能小技巧
Bilibili视频:同济子豪兄
张子豪写于2018-11-25
于2018-12-1发布




[TOC]
1、黑客帝国字节数据流——假装自己是黑客高手,无孔不入
在命令行中输入以下命令安装并运行。
sudo apt-get install cmatrix
cmatrix

还可输入参数控制颜色。
cmatric -C red

按ctrl
+c
退出。
在《黑客帝国》电影里的字节流其实是该片美术指导Simon Whitley的日本妻子菜谱上的片假名。
2、高大上仪表盘blessed-contrib——假装自己指点江山,纵横捭阖
sudo apt-get install npm
sudo apt install nodejs-legacy
git clone https://github.com/yaronn/blessed-contrib.git
cd blessed-contrib
npm install
node ./examples/dashboard.js

建议在云服务器或虚拟机上运行这个命令,在树莓派上运行可能会出问题。
3、高大上仪表盘hollywood——假装自己日理万机,宵衣旰食
Dustin Kirkland 利用一个长途飞行的时间,编写了这个炫酷、有趣但也没什么实际作用的软件。
Ubuntu操作系统可以直接通过以下命令安装并运行。
sudo apt install hollywood
hollywood
在其它Linux发行版中,可以通过以下命令安装并运行。
sudo apt-add-repository ppa:hollywood/ppa
sudo apt-get install hollywood
sudo apt-get install byobu
hollywood


4、追逐鼠标的小猫oneko
在桌面的命令行界面输入
sudo apt-get install oneko
oneko
然后输入oneko
,即可看到效果。
按ctrl
+c
退出。
注意,本命令只能在桌面所在的命令行界面输入,在远程ssh界面会显示“oneko:Can't open display”

5、ASCII艺术框:box命令
sudo apt-get install boxes
echo "Tongji Univerisity" | boxes
echo "Tongji Univerisity" | boxes -d dog
fortune | boxes -d cat | lolcat

6、燃起字符串大火aafire
在命令行界面输入
sudo apt-get install libaa-bin
aafire
然后输入 aafire
,即可看到效果
按ctrl
+c
退出。

7、火车:Strem Locomotive
在命令行界面输入
sudo apt-get install sl
然后输入 sl
,即可看到效果。

输入sl-h
可以看到彩蛋(没有空格)

这个命令其实是在用户把ls命令输错成sl命令的时候准备的彩蛋。
8、盯着鼠标看的大眼睛
在命令行界面输入
sudo apt-get install x11-apps
然后输入 xeyes
,回车,即可看到效果:一双紧盯着鼠标所在位置的大眼睛。
按ctrl
+c
退出。

9、艺术字生成器toilet
在命令行界面输入
sudo apt-get install toilet
然后输入下面任意一行命令,通过在命令中加-f更换字体或滤镜,你可以把命令里的Tongji University
换成你想要转换的字符。
案例1
toilet Tongji University

案例2 双色字:
toilet -f mono12 -F metal Tongji University

案例3 彩色字:
toilet -f mono12 -F gay Tongji University
输入man toilet
查看更多帮助,按q
退出。

10、艺术字生成器figlet
在命令行界面输入
sudo apt-get install figlet
然后输入下面任意一行命令,通过在命令中加-f更换字体或滤镜,你可以把命令里的Tongji University
换成你想要转换的字符。
figlet Tongji University

11、字符串视频——回归计算机的上古时代
在命令行界面输入
sudo apt-get install bb
然后输入 bb
,选择y
加音乐,选择8
继续,即可看到一段用字符串制作的视频,讲述了视频作者的生涯和使用Linux操作系统的历程,这段视频制作于1997年,基于AAlib平台制作。
按ctrl
+c
退出。
这段视频的音乐很带感哦~

12、输出名人名言、古诗词
在命令行界面输入
sudo apt-get install fortune fortune-zh
然后输入 fortune
,即可看到效果。

可以把这个程序设置成每次开机自动启动,每次你登陆的时候就能看到一条新的名人名言或唐诗宋词了。
13、字符串水族馆:ASCIIquarium
第一步:安装各种依赖
sudo apt-get install libcurses-perl
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/K/KB/KBAUCOM/Term-Animation-2.4.tar.gz
tar -zxvf Term-Animation-2.4.tar.gz
cd Term-Animation-2.4/
sudo perl Makefile.PL && make && make test
sudo make install
第二步:安装软件
cd /tmp
sudo wget https://robobunny.com/projects/asciiquarium/asciiquarium.tar.gz
如果显示文件下载失败,可以点击https://robobunny.com/projects/asciiquarium/asciiquarium.tar.gz
下载压缩包,然后通过FileZilla等文件远程传输软件传输到/tmp文件夹中。
然后继续执行下列命令。
tar -zxvf asciiquarium.tar.gz
cd asciiquarium_1.1/
sudo cp asciiquarium /usr/local/bin
sudo chmod 0755 /usr/local/bin/asciiquarium
asciiquarium

14、会说话的牛
在命令行界面输入
sudo apt-get install cowsay
然后输入 cowsay “Hello Tongji Univerisity”
。

只需用 -l
参数就能看到它能提供的所有动物。
cowsay -l
会输出如下人物,你可以通过-f
参数加人物名字来更换说话人物:
# 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
比如更换成hellokitty:
cowsay -f dragon 'Hello Tongji Univerisity'

也可以利用管道命令,将fortune生成的名人名言在cowsay中输出
fortune | cowsay
加个颜色
sudo apt install lolcat
利用管道命令,让彩色的恐龙大哥说彩色的唐诗:
fortune | cowsay -f stegosaurus | lolcat

15、会说话的牛2
注意,本命令只能在桌面所在的命令行界面输入,在远程ssh命令行界面输入会显示“Can't open display”
在命令行界面输入
sudo apt-get install xcowsay
然后输入 xcowsay “Hello Tongji Univerisity欢迎来同济大学”

16、日历
直接在命令行界面输入
cal 12 2018
即可看到2018年12月的日历。

有趣的是,如果你输入。
cal 9 1752
你会发现这个月少了11天,这是因为当时大英帝国美洲殖民地的历法从凯撒历法换成了格里高利历法,凯撒历法要迟11天,所以这11天成了日历上的空白期。
17、yes命令
直接在命令行界面输入
yes Tongji University
yes Tongji University | lolcat
就会看到无穷无尽输出的Tongji University
按ctrl
+c
退出。

18、分解因数
在命令行界面输入
factor 60
即可看到60的分解质因数的结果

19、screenfetch:显示系统、主题信息
sudo apt install screenfetch
screenfetch
在开源社区或程序员社区提问时,可以通过这条命令,直接截图,就能很清晰地描述自己的系统环境。
在Ubuntu云服务器上运行:

在树莓派上运行:

20、linux各发行版logo图片及系统信息
sudo apt install linuxlogo
linux_logo
linux_logo -f -L list
sudo apt-get install neofetch
neofetch
在ubuntu云服务器上运行linux_logo

在树莓派上运行linux_logo


循环打印所有支持打印的图标
for i in {1..30};do linux_logo -f -L $i;sleep 0.5;done

21、图片转字符串
这条命令在树莓派上运行会出问题,建议在云主机或虚拟机上运行。
sudo apt-get install aview imagemagick
wget http://labfile.oss.aliyuncs.com/courses/1/Linus.png
asciiview Linus.png

你可以把wget后面的链接换成任意图片的URL。
比如
wget http://www.shumeipai.wang/bingbingbing.jpg
asciiview bingbingbing.jpg

22、反转字符命令
在命令行中输入rev
,打开rev界面,然后输入任意字符,比如
I am a student in Tongji Univerisity
按回车,即可看到字符反转之后的结果
按ctrl
+c
退出rev界面回到命令行界面。
echo "I am a student in Tongji Univerisity" | rev
将一句话中所有单词的顺序反转,但在单词内部字母顺序不变
echo "I am a student in Tongji University" | rev | tr ' ' '\n' | tac | tr '\n' ' '| rev

23、打字机pv命令:字幕一个个匀速显示出来
sudo apt-get install pv
echo "Tongji Opensource" | pv -qL 10
cal | pv -qL 10

24、从删库到跑路 sudo rm -rf /*
[图片上传失败...(image-921040-1543520463592)]
友情提示:千万不要轻易尝试这个命令,特别是在运行有网站服务器、数据库的Linux主机上
sudo rm -rf /*
- sudo:获取root管理员权限
- rm:remove,即删除
- -rf:r表示递归删除,即删除所有的子目录,f表示不需要再进行确认
- /:home目录
- *:所有文件
也就是说,这条命令是删除这台Linux主机上的所有文件,甚至包括开机文件
关于这条命令的一些有趣的图片:
25、播放星球大战
这条命令在windows上都可以运行
1、打开控制面板,找到”启动或关闭Windows功能“,然后打开Telnet客户端。


2、用管理员模式打开DOS命令行界面,输入以下命令,回车。

telnet towel.blinkenlights.nl


26、让命令行说话
运行这个命令不能通过远程连接,必须通过音响
sudo apt install espeak
espeak 'Hello my dariling'
27、随机产生人名与地址
sudo apt-get install rig
rig

28、超级牛力——包管理器的彩蛋
在Ubuntu和Debian上,apt-get包管理器内嵌着一个彩蛋。
如果你在命令行界面输入
apt-get help
在最后一行能找到
This APT has Super Cow Powers。
本APT具有超级牛力。
则说明你的系统可以运行这个菜单。

在命令行界面输入
apt-get moo
即可看到这个彩蛋。
aptitiude包管理器也有类似的彩蛋
aptitude moo
aptitude moo -vv
aptitude moo -vvv
aptitude moo -vvvv
aptitude moo -vvvvv
aptitude moo -vvvvvv

扩展阅读与参考文献
Shell常识--基本函数和简单命令rev--总结自《Linux Shell 脚本攻略》
启用Windows中的Telnet功能一起看DOS版星球大战
作者介绍:
张子豪,同济大学在读研究生。微信公众号、知乎专栏:人工智能小技巧。
自媒体人工智能小技巧由同济大学在读研究生张子豪于2018年11月创立。包括微信公众号、知乎专栏、简书专栏、Bilibili视频专栏等。致力于用通俗易懂的大白话帮助零基础非计算机专业的初学者快速掌握人工智能、大数据可视化、区块链、Python趣味编程、树莓派智能硬件等前沿科技知识,并手把手指导新手迅速上手开发实战项目。
微信公众号:人工智能小技巧
知乎专栏:人工智能小技巧
Bilibili视频:同济子豪兄
Github代码仓库:TommyZihao
个人主页:www.python666.org
同济大学开源软件协会
同济大学微软学生俱乐部
西南人工智能爱好者联盟
重庆大学人工智能协会
重庆大学树莓派爱好者俱乐部
[图片上传失败...(image-15d68b-1543520463593)]
