Debian 系统里“屏蔽 message”通常指 关闭或过滤系统日志、登录提示、广播消息、systemd 消息 等。下面按常见场景给你具体做法,你可以按需选择。
wall / write 等广播消息(最常见)如果你是 普通用户或 root,不想收到别人发的广播消息:
mesg n
永久生效(对当前用户):
echo "mesg n" >> ~/.bashrc
systemd 启动/状态信息(journal 消息)systemctl start xxx --quiet
或
journalctl -q
编辑:
sudo nano /etc/systemd/journald.conf
修改:
Storage=none
⚠️ 不推荐:会导致无法排查问题
sudo systemctl disable motd-news.timer
sudo systemctl stop motd-news.timer
sudo rm -f /etc/motd
sudo rm -f /etc/update-motd.d/*
如果你想 完全不显示登录提示:
touch ~/.hushlogin
apt / Debian 更新提示sudo apt-get -qq update
sudo apt-get -qq upgrade
sudo apt remove unattended-upgrades
dmesg -n 1
级别说明:
1:只显示 panic3:错误4:警告7:全部(默认)编辑:
sudo nano /etc/default/grub
添加:
GRUB_CMDLINE_LINUX="quiet loglevel=1"
然后:
sudo update-grub
sudo systemctl edit 服务名
加入:
[Service]
StandardOutput=null
StandardError=null
编辑 SSH 配置:
sudo nano /etc/ssh/sshd_config
添加或修改:
PrintMotd no
重启 SSH:
sudo systemctl restart ssh
| 需求 | 命令 |
|---|---|
| 屏蔽广播消息 | mesg n |
| 屏蔽登录提示 | touch ~/.hushlogin |
| 屏蔽 MOTD | 删除 /etc/update-motd.d/* |
| 屏蔽 systemd 输出 | journalctl -q |
| 屏蔽内核信息 | dmesg -n 1 |
| 屏蔽 SSH 提示 | PrintMotd no |
如果你能具体说一句 “我想屏蔽的是哪种 message”(比如:开机、SSH 登录、systemctl、apt、桌面弹窗),我可以给你 最精准的做法。