0

Is there any way to update the /etc/motd file on login? The /etc/profile and /etc/profile.d/*.sh scripts are executed after the motd is already displayed on login so these methods don't work.

I want to add dynamic details about the current IP address and display it in the motd. However, I can't find a way to update the motd before it gets displayed to the user logging in.

Thanks!

2
  • Edit the question to include what you see after login including what is there are a result of /etc/profile and the scripts in /etc/profile.d/. I can't reproduce what you are seeing in Alpine Linux. What I put in /etc/motd appears regardless of what is in those files. Commented Feb 23, 2024 at 22:27
  • 2
    Does this answer your question? How to set a dynamic Message of the Day (motd) in Debian Jessie 8.2 for ssh? Commented Feb 23, 2024 at 22:34

1 Answer 1

1

I had to rethink how to approach this problem.
I was trying to use a script in /etc/profile.d to update the /etc/motd file.
This was not working because the motd is displayed on login before /etc/profile.d scripts are executed - causing motd to be displayed then silently updated by the script after the fact.

I cleared the motd file and had the /etc/profile.d script directly echo what I wanted to display on user login instead.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.