Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible in ubuntu to print a different motd file based on the group of the user that is logging in?

I want to display different motd messages for admins and regular users when they login to my ubuntu 9.10 server.

I've looked at the PAM documentation and the documentation for the pam_motd module without any answers.

share|improve this question
up vote 7 down vote accepted

You're probably quicker adding a shell script onto the end of /etc/profile file to do a group check then spit out a message

Something like:

# script at /usr/local/bin/motdcheck
PGROUP=`groups|awk '{print $1}'`
cat /etc/motd.${PGROUP}

would run as a script which outputs a file named /etc/motd.groupname where groupname is the first group in the users group list.

Everything in /etc/profile is ran each time a new login shell is opened.

share|improve this answer
You're the best! Thank you! – Baversjo Oct 29 '09 at 16:30
This is my final script. If the user is of a certain group view the specified motd file, else use the regular file. PGROUP=groups|awk '{print $1}' if [ $PGROUP = "mygroup" ]; then cat /etc/motdspecial else cat /etc/motd fi – Baversjo Oct 29 '09 at 17:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.