
我正在嘗試顯示 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)"