4

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.

Baversjo
  • 143
  • 6

1 Answers1

7

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.

Ewan Leith
  • 1,705
  • 8
  • 7
  • 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