温馨提示×

Linux cmatrix如何开机启动

小樊
32
2026-08-16 17:03:22
栏目: 智能运维

在 Linux 中让 cmatrix 开机自动启动,常见做法取决于你使用的是 桌面环境(GUI) 还是 纯终端(TTY / 服务器)。下面按常见场景说明。


一、桌面环境(推荐,适用于 Ubuntu / Debian / CentOS 桌面等)

方法 1:通过「自动启动程序」(最简单)

  1. 确认已安装 cmatrix

    sudo apt install cmatrix        # Debian/Ubuntu
    sudo yum install cmatrix        # CentOS/RHEL
    
  2. 打开「启动应用程序」(Startup Applications)

    • Ubuntu:搜索 Startup Applications
    • GNOME:gnome-session-properties
  3. 点击 Add(添加)

    • Name:cmatrix
    • Command:
      cmatrix -b
      
    • Comment:开机运行 cmatrix
  4. 保存,重启即可。

✅ 适合桌面用户
❌ 不适合纯命令行服务器


二、使用 systemd(通用,适合服务器 / TTY)

方法 2:让 cmatrix 在 TTY 登录后自动运行(推荐)

注意:cmatrix 是 交互式程序,不能直接用 systemd 后台运行,否则会失败。

1️⃣ 创建 systemd 服务(用于自动登录 TTY)

启用 TTY 自动登录(以 tty1 为例)

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

2️⃣ 在用户登录后自动启动 cmatrix

编辑用户 .bash_profile.bashrc

nano ~/.bash_profile

添加:

if [ "$(tty)" = "/dev/tty1" ]; then
    cmatrix -b
fi

保存后重启:

reboot

✅ 开机直接进入 tty1 并运行 cmatrix
✅ 适合服务器 / 树莓派


三、使用 .bashrc(最简单但不严谨)

nano ~/.bashrc

添加:

cmatrix -b

⚠️ 缺点:

  • 每次打开终端都会运行
  • 不适合服务器
  • 容易被误触发

四、cmatrix 常用参数(可选)

cmatrix -b       # 加粗字符
cmatrix -C cyan  # 青色
cmatrix -u 2     # 更新速度

五、推荐方案总结

场景 推荐方式
桌面 Linux 启动应用程序
服务器 / TTY systemd + 自动登录
测试 .bashrc

如果你愿意,可以告诉我:

  • ✅ 发行版(Ubuntu / CentOS / Arch)
  • ✅ 桌面还是服务器
  • ✅ 是否要全屏、无登录界面

我可以给你 完全定制的一套配置

0