良许Linux教程网 干货合集 Ubuntu 20.04中禁用motd欢迎消息

Ubuntu 20.04中禁用motd欢迎消息

本篇文章重点讲解一下在Ubuntu 20.04中禁用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:~$ ls -l /etc/update-motd.d/
total 44
-rwxr-xr-x 1 root root 1220 4月   9  2018 00-header
-rwxr-xr-x 1 root root 1157 4月   9  2018 10-help-text
-rwxr-xr-x 1 root root 5023 8月  17  2020 50-motd-news
-rwxr-xr-x 1 root root   96 6月  19  2020 85-fwupd
-rwxr-xr-x 1 root root  218 4月   2  2020 90-updates-available
-rwxr-xr-x 1 root root  374 7月  18  2020 91-release-upgrade
-rwxr-xr-x 1 root root  165 2月  17  2020 92-unattended-upgrades
-rwxr-xr-x 1 root root  129 11月 12  2018 95-hwe-eol
-rwxr-xr-x 1 root root  142 11月 12  2018 98-fsck-at-reboot
-rwxr-xr-x 1 root root  144 11月 12  2018 98-reboot-required

如何在 Ubuntu 中禁用 motd 欢迎消息如何在 Ubuntu 中禁用 motd 欢迎消息 可以随便看一个脚本文件的内容:

bob@ubuntu-20-04:~$ cat /etc/update-motd.d/00-header
如何在 Ubuntu 中禁用 motd 欢迎消息如何在 Ubuntu 中禁用 motd 欢迎消息

如何禁用脚本?

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

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

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

bob@ubuntu-20-04:~$ sudo chmod -x /etc/update-motd.d/00-header
如何在 Ubuntu 中禁用 motd 欢迎消息如何在 Ubuntu 中禁用 motd 欢迎消息

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

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

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

Hello Ubuntu 20-04

添加可执行权限:

bob@ubuntu-20-04:~$ sudo chmod +x /etc/update-motd.d/99-custom-msg
如何在 Ubuntu 中禁用 motd 欢迎消息如何在 Ubuntu 中禁用 motd 欢迎消息

以上就是良许教程网为各位朋友分享的Linu系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !

137e00002230ad9f26e78-265x300
本文由 良许Linux教程网 发布,可自由转载、引用,但需署名作者且注明文章出处。如转载至微信公众号,请在文末添加作者公众号二维码。
良许

作者: 良许

良许,世界500强企业Linux开发工程师,公众号【良许Linux】的作者,全网拥有超30W粉丝。个人标签:创业者,CSDN学院讲师,副业达人,流量玩家,摄影爱好者。
上一篇
下一篇

发表评论

联系我们

联系我们

公众号:良许Linux

在线咨询: QQ交谈

邮箱: yychuyu@163.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部