← 返回命令列表

Linux command

motd 命令

安全

权限或系统影响较大,执行前请核对目标。

常用示例

Edit static MOTD

sudo nano /etc/motd

View MOTD

cat /etc/motd

Add dynamic MOTD script

sudo nano /etc/update-motd.d/[99-custom]

Make dynamic script executable

sudo chmod +x /etc/update-motd.d/[99-custom]

Regenerate dynamic MOTD

run-parts /etc/update-motd.d/

说明

motd (Message of the Day) is displayed to users upon login. It can be a static text file or dynamically generated from scripts. The contents of /etc/motd are displayed by login(1) after a successful login but just before executing the login shell. On systems with PAM, the pam_motd module handles display and can show files from multiple locations. Dynamic MOTD systems run scripts from /etc/update-motd.d/.

FAQ

What is the motd command used for?

motd (Message of the Day) is displayed to users upon login. It can be a static text file or dynamically generated from scripts. The contents of /etc/motd are displayed by login(1) after a successful login but just before executing the login shell. On systems with PAM, the pam_motd module handles display and can show files from multiple locations. Dynamic MOTD systems run scripts from /etc/update-motd.d/.

How do I run a basic motd example?

Run `sudo nano /etc/motd` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more motd examples?

This page includes 5 examples for motd, plus related commands for nearby Linux tasks.