关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

Ubuntu中如何禁用 motd 欢迎消息

发布时间:2022-09-26 12:38:39
1491984010112764.jpg

Ubuntu中如何禁用 motd 欢迎消息?本篇文章为大家分享一下Ubuntu下禁用motd 欢迎消息具体方法,有需要的小伙伴可以参考一下。

Ubuntu 使用的是update-motd,它是一个动态 motd 生成工具。从手册页: UNIX/Linux 系统管理员通常通过在文件 /etc/motd 中维护文本来向控制台和远程用户传达重要信息,该文件由 pam_motd(8) 模块在交互式 shell 登录时显示。

传统上,此文件是静态文本,通常由发行版安装并仅在版本升级时更新,或者由本地管理员使用相关信息覆盖。

Ubuntu 引入了update-motd框架,通过该框架,motd(5) 在登录时从一组脚本中动态获取。

/etc/update-motd.d/* 中的可执行脚本在每次登录时由 pam_motd(8) 作为 root 用户执行,并且这些信息连接在 /var/run/motd 中。

如何查看当前脚本?

脚本存放的位置在/etc/update-motd.d目录中:

bob@ubuntu-20-04:~$&nbsp;ls&nbsp;-l&nbsp;/etc/update-motd.d/

total&nbsp;44

-rwxr-xr-x&nbsp;1&nbsp;root&nbsp;root&nbsp;1220&nbsp;4月&nbsp;&nbsp;&nbsp;9&nbsp;&nbsp;2018&nbsp;00-header

-rwxr-xr-x&nbsp;1&nbsp;root&nbsp;root&nbsp;1157&nbsp;4月&nbsp;&nbsp;&nbsp;9&nbsp;&nbsp;2018&nbsp;10-help-text

-rwxr-xr-x&nbsp;1&nbsp;root&nbsp;root&nbsp;5023&nbsp;8月&nbsp;&nbsp;17&nbsp;&nbsp;2020&nbsp;50-motd-news

-rwxr-xr-x&nbsp;1&nbsp;root&nbsp;root&nbsp;&nbsp;&nbsp;96&nbsp;6月&nbsp;&nbsp;19&nbsp;&nbsp;2020&nbsp;85-fwupd

-rwxr-xr-x&nbsp;1&nbsp;root&nbsp;root&nbsp;&nbsp;218&nbsp;4月&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;2020&nbsp;90-updates-available

-rwxr-xr-x&nbsp;1&nbsp;root&nbsp;root&nbsp;&nbsp;374&nbsp;7月&nbsp;&nbsp;18&nbsp;&nbsp;2020&nbsp;91-release-upgrade

-rwxr-xr-x&nbsp;1&nbsp;root&nbsp;root&nbsp;&nbsp;165&nbsp;2月&nbsp;&nbsp;17&nbsp;&nbsp;2020&nbsp;92-unattended-upgrades

-rwxr-xr-x&nbsp;1&nbsp;root&nbsp;root&nbsp;&nbsp;129&nbsp;11月&nbsp;12&nbsp;&nbsp;2018&nbsp;95-hwe-eol

-rwxr-xr-x&nbsp;1&nbsp;root&nbsp;root&nbsp;&nbsp;142&nbsp;11月&nbsp;12&nbsp;&nbsp;2018&nbsp;98-fsck-at-reboot

-rwxr-xr-x&nbsp;1&nbsp;root&nbsp;root&nbsp;&nbsp;144&nbsp;11月&nbsp;12&nbsp;&nbsp;2018&nbsp;98-reboot-required

image.png

可以随便看一个脚本文件的内容:

bob@ubuntu-20-04:~$&nbsp;cat&nbsp;/etc/update-motd.d/00-header

image.png

如何禁用脚本?

如果要禁用所有脚本,请运行以下命令:

bob@ubuntu-20-04:~$&nbsp;sudo&nbsp;chmod&nbsp;-R&nbsp;644&nbsp;/etc/update-motd.d/

如果要禁用单个脚本,请运行以下命令:

bob@ubuntu-20-04:~$&nbsp;sudo&nbsp;chmod&nbsp;-x&nbsp;/etc/update-motd.d/00-header

image.png

如何在 /etc/update-motd.d/ 目录中创建我自己的脚本?

只需创建一个 shell 脚本,名称自定义,名称前面的序号根据需要填写,数字越大优先级越低。如下所示:

bob@ubuntu-20-04:~$&nbsp;sudo&nbsp;touch&nbsp;/etc/update-motd.d/99-custom-msg

bob@ubuntu-20-04:~$&nbsp;sudo&nbsp;vim&nbsp;/etc/update-motd.d/99-custom-msg

Hello&nbsp;Ubuntu&nbsp;20-04

添加可执行权限:

bob@ubuntu-20-04:~$&nbsp;sudo&nbsp;chmod&nbsp;+x&nbsp;/etc/update-motd.d/99-custom-msg

image.png



/template/Home/8a/PC/Static