通过 Linux 的 motd(Message of the Day)可以很方便的修改登录信息,下面就动手。
本文均以 Debian 系统为例,其他发行版可能略有出入,请自行查证。
motd 消息组成
以 Debian 为例,默认的登录消息是这样的,下面就先来看看这玩意是怎么生成的。
1
2
3
4
5
6
7
8
9
10
Linux HOSTNAME 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
You have no mail.
Last login: Sat Jan 6 17:48:05 2024 from 1.1.1.1
拆解
进入 /etc/update-motd.d 目录,可以看到一个默认的脚本,可以看下它的内容:
1
2
3
cd /etc/update-motd.d
ls
cat 10-uname
发现是一个标准的 Shell 脚本:
1
2
#!/bin/sh
uname -snrvm
运行一下 uname -snrvm,就是登录消息的第一部分:
Linux LH-Shanghai 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x 86_64
The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
for font in banner big block bubble digital ivrit lean mini mnemonic script shadow slant small smscript smshadow smslant standard term; do echo "Font: $font"; toilet -f $font "Hello World"; done
确定好样式之后,像上面一样,创建一个脚本,然后把命令填进去,例如:
1
2
#!/bin/sh
toilet -f block -F gay Phoenix
生成固定字符画
toilet 好用是好用,就是可用的字体比较少,如果想要更多更多的样式,可以用 这个网站 来自己生成字符画,可选的字体非常多,可以点击 Test All 来测试所有的字体。