我正在尝试显示 motd 用户的详细信息(用户和实际日期)
这是我迄今为止采取的步骤:
sudo nano /etc/update-motd.d/00-welcome #(script)
#!/bin/sh
echo "Welcome user: ${USER}. Today is $(date)" #(save the file)
sudo chmod +x /etc/update-motd.d/00-welcome
但成功登录后,motd 不会出现。我应该尝试什么?
答案1
您读过全部吗man update-motd
?接近尾声时,它说:
Scripts should emit a blank line before output, and end with a newline
character. For instance:
因此,将您的脚本更改为:
#!/bin/sh
echo
echo "Welcome user: ${USER}. Today is $(date)"