在 Linux 中让 cmatrix 开机自动启动,常见做法取决于你使用的是 桌面环境(GUI) 还是 纯终端(TTY / 服务器)。下面按常见场景说明。
确认已安装 cmatrix
sudo apt install cmatrix # Debian/Ubuntu
sudo yum install cmatrix # CentOS/RHEL
打开「启动应用程序」(Startup Applications)
gnome-session-properties点击 Add(添加)
cmatrixcmatrix -b
保存,重启即可。
✅ 适合桌面用户
❌ 不适合纯命令行服务器
注意:cmatrix 是 交互式程序,不能直接用 systemd 后台运行,否则会失败。
sudo mkdir -p /etc/systemd/system/getty@tty1.service.d
sudo nano /etc/systemd/system/getty@tty1.service.d/autologin.conf
内容:
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin 你的用户名 --noclear %I $TERM
编辑用户 .bash_profile 或 .bashrc:
nano ~/.bash_profile
添加:
if [ "$(tty)" = "/dev/tty1" ]; then
cmatrix -b
fi
保存后重启:
reboot
✅ 开机直接进入 tty1 并运行 cmatrix
✅ 适合服务器 / 树莓派
.bashrc(最简单但不严谨)nano ~/.bashrc
添加:
cmatrix -b
⚠️ 缺点:
cmatrix -b # 加粗字符
cmatrix -C cyan # 青色
cmatrix -u 2 # 更新速度
| 场景 | 推荐方式 |
|---|---|
| 桌面 Linux | 启动应用程序 |
| 服务器 / TTY | systemd + 自动登录 |
| 测试 | .bashrc |
如果你愿意,可以告诉我:
我可以给你 完全定制的一套配置。