Operating System - HP-UX
1847063 Members
6511 Online
110261 Solutions
New Discussion

usermod -a equivalent under HP-UX 11.11 ?

 
SOLVED
Go to solution
Francis Noël
Regular Advisor

usermod -a equivalent under HP-UX 11.11 ?

Greetings

I have a few servers under 11.11 without NIS so we have to maintain /etc/group consistent by hand.

One thing I miss versus Linux is usermod -a -G .

That command would append the login to a new secondary group without removing it from any other group it might be in.

HP-UX does not do -a, so usermod -G would have the account wiped from every secondary group and added to .

How can I, under 11.11, add a user to a group without removing him from everything else. I know I can edit /etc/group by hand but doing it over and over for each server is a pain....I'd rather ssh a usermod command if thats possible.

Thank you for your time.
4 REPLIES 4
Court Campbell
Honored Contributor

Re: usermod -a equivalent under HP-UX 11.11 ?

i believe that you will have to put the new group plus any of the groups the users is already in at the command line:

# usermod -G newgroup,group1,group2,group3
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Jeff_Traigle
Honored Contributor
Solution

Re: usermod -a equivalent under HP-UX 11.11 ?

The -a option would be nice, but you can fudge it on HP-UX like this:

usermod -G $(groups -g login | sed 's/ /,/'),newgroup login
--
Jeff Traigle
Rasheed Tamton
Honored Contributor

Re: usermod -a equivalent under HP-UX 11.11 ?

Greetings

If you have ssh access why don't you scp /etc/group to all other servers from a main server to make it consistent.

You can just use a single (for-do-done)script and a file with the hostnames to do this. Or you can use rsync or rdist.

cat > myhostnames
host1
host2
host3


for i in `cat myhostnames`
do
echo $i
scp /etc/group $i:/etc/group
done

You can even do it on a cron.
Of course, make backup copies of /etc/group before you fire the script.

Regards.
Francis Noël
Regular Advisor

Re: usermod -a equivalent under HP-UX 11.11 ?

Thank you all for your comments

Court : Correct but that is precisely what I do not want to do as it requires me to have prior knowledge of all groups the user is in.

Jeff : Looks promising, I've been putting off learning the stream editor for a while but this looks like a good reason to get to it.

Rasheed : Very true...But the systems are not as consistent as they need to be ( working on it !) so that is not possible right now.

So I'll experiment with sed.

Thanks all!