Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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:

#!/bin/bash
# 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

 
discard

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.