{"id":221804,"date":"2021-07-07T08:00:39","date_gmt":"2021-07-07T00:00:39","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=221804"},"modified":"2021-06-29T16:01:02","modified_gmt":"2021-06-29T08:01:02","slug":"ubuntu-forbidden-motd","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ubuntu-forbidden-motd.html","title":{"rendered":"\u5982\u4f55\u5728 Ubuntu \u4e2d\u7981\u7528 motd \u6b22\u8fce\u6d88\u606f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u672c\u6587\u4ecb\u7ecd\u5982\u4f55\u5728Ubuntu 20.04\u4e2d\u7981\u7528motd\u6b22\u8fce\u6d88\u606f<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

Ubuntu \u4f7f\u7528\u7684\u662fupdate-motd<\/code>\uff0c\u5b83\u662f\u4e00\u4e2a\u52a8\u6001 motd \u751f\u6210\u5de5\u5177\u3002\u4ece\u624b\u518c\u9875\uff1a
\nUNIX\/Linux \u7cfb\u7edf\u7ba1\u7406\u5458\u901a\u5e38\u901a\u8fc7\u5728\u6587\u4ef6 \/etc\/motd<\/code> \u4e2d\u7ef4\u62a4\u6587\u672c\u6765\u5411\u63a7\u5236\u53f0\u548c\u8fdc\u7a0b\u7528\u6237\u4f20\u8fbe\u91cd\u8981\u4fe1\u606f\uff0c\u8be5\u6587\u4ef6\u7531 pam_motd(8) \u6a21\u5757\u5728\u4ea4\u4e92\u5f0f shell \u767b\u5f55\u65f6\u663e\u793a\u3002<\/p>\n

\u4f20\u7edf\u4e0a\uff0c\u6b64\u6587\u4ef6\u662f\u9759\u6001\u6587\u672c\uff0c\u901a\u5e38\u7531\u53d1\u884c\u7248\u5b89\u88c5\u5e76\u4ec5\u5728\u7248\u672c\u5347\u7ea7\u65f6\u66f4\u65b0\uff0c\u6216\u8005\u7531\u672c\u5730\u7ba1\u7406\u5458\u4f7f\u7528\u76f8\u5173\u4fe1\u606f\u8986\u76d6\u3002<\/p>\n

Ubuntu \u5f15\u5165\u4e86update-motd<\/code>\u6846\u67b6\uff0c\u901a\u8fc7\u8be5\u6846\u67b6\uff0cmotd(5) \u5728\u767b\u5f55\u65f6\u4ece\u4e00\u7ec4\u811a\u672c\u4e2d\u52a8\u6001\u83b7\u53d6\u3002<\/p>\n

\/etc\/update-motd.d\/* \u4e2d\u7684\u53ef\u6267\u884c\u811a\u672c\u5728\u6bcf\u6b21\u767b\u5f55\u65f6\u7531 pam_motd(8) \u4f5c\u4e3a root \u7528\u6237\u6267\u884c\uff0c\u5e76\u4e14\u8fd9\u4e9b\u4fe1\u606f\u8fde\u63a5\u5728 \/var\/run\/motd \u4e2d\u3002<\/p>\n

\u5982\u4f55\u67e5\u770b\u5f53\u524d\u811a\u672c\uff1f<\/strong><\/div>\n

\u811a\u672c\u5b58\u653e\u7684\u4f4d\u7f6e\u5728\/etc\/update-motd.d<\/code>\u76ee\u5f55\u4e2d\uff1a<\/p>\n

\r\nbob@ubuntu-20-04:~$ ls -l \/etc\/update-motd.d\/\r\ntotal 44\r\n-rwxr-xr-x 1 root root 1220 4\u6708   9  2018 00-header\r\n-rwxr-xr-x 1 root root 1157 4\u6708   9  2018 10-help-text\r\n-rwxr-xr-x 1 root root 5023 8\u6708  17  2020 50-motd-news\r\n-rwxr-xr-x 1 root root   96 6\u6708  19  2020 85-fwupd\r\n-rwxr-xr-x 1 root root  218 4\u6708   2  2020 90-updates-available\r\n-rwxr-xr-x 1 root root  374 7\u6708  18  2020 91-release-upgrade\r\n-rwxr-xr-x 1 root root  165 2\u6708  17  2020 92-unattended-upgrades\r\n-rwxr-xr-x 1 root root  129 11\u6708 12  2018 95-hwe-eol\r\n-rwxr-xr-x 1 root root  142 11\u6708 12  2018 98-fsck-at-reboot\r\n-rwxr-xr-x 1 root root  144 11\u6708 12  2018 98-reboot-required\r\n<\/pre>\n

\"\"
\n\u53ef\u4ee5\u968f\u4fbf\u770b\u4e00\u4e2a\u811a\u672c\u6587\u4ef6\u7684\u5185\u5bb9\uff1a<\/p>\n

\r\nbob@ubuntu-20-04:~$ cat \/etc\/update-motd.d\/00-header \r\n<\/pre>\n

\"\"<\/p>\n

\u5982\u4f55\u7981\u7528\u811a\u672c\uff1f<\/strong><\/div>\n

\u5982\u679c\u8981\u7981\u7528\u6240\u6709\u811a\u672c\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\r\nbob@ubuntu-20-04:~$ sudo chmod -R 644 \/etc\/update-motd.d\/\r\n<\/pre>\n

\u5982\u679c\u8981\u7981\u7528\u5355\u4e2a\u811a\u672c\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

\r\nbob@ubuntu-20-04:~$ sudo chmod -x \/etc\/update-motd.d\/00-header \r\n<\/pre>\n

\"\"<\/p>\n

\u5982\u4f55\u5728 \/etc\/update-motd.d\/ \u76ee\u5f55\u4e2d\u521b\u5efa\u6211\u81ea\u5df1\u7684\u811a\u672c\uff1f<\/strong><\/div>\n

\u53ea\u9700\u521b\u5efa\u4e00\u4e2a shell \u811a\u672c\uff0c\u540d\u79f0\u81ea\u5b9a\u4e49\uff0c\u540d\u79f0\u524d\u9762\u7684\u5e8f\u53f7\u6839\u636e\u9700\u8981\u586b\u5199\uff0c\u6570\u5b57\u8d8a\u5927\u4f18\u5148\u7ea7\u8d8a\u4f4e\u3002\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n

\r\nbob@ubuntu-20-04:~$ sudo touch \/etc\/update-motd.d\/99-custom-msg\r\nbob@ubuntu-20-04:~$ sudo vim \/etc\/update-motd.d\/99-custom-msg \r\n\r\nHello Ubuntu 20-04\r\n<\/pre>\n

\u6dfb\u52a0\u53ef\u6267\u884c\u6743\u9650\uff1a<\/p>\n

\r\nbob@ubuntu-20-04:~$ sudo chmod +x \/etc\/update-motd.d\/99-custom-msg \r\n<\/pre>\n

\"\"<\/p>\n","protected":false},"excerpt":{"rendered":"

Ubuntu \u4f7f\u7528\u7684\u662fupdate-motd\uff0c\u5b83\u662f\u4e00\u4e2a\u52a8\u6001 motd \u751f\u6210\u5de5\u5177\u3002\u4ece\u624b\u518c\u9875\uff1a UNIX\/Linu […]<\/p>\n","protected":false},"author":309,"featured_media":221805,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-221804","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/309"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=221804"}],"version-history":[{"count":1,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221804\/revisions"}],"predecessor-version":[{"id":221810,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/221804\/revisions\/221810"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/221805"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=221804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=221804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=221804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}