Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Jun 2001 09:03:38 -0500
From:      Mike Meyer <mwm@mired.org>
To:        Odhiambo Washington <wash@FreeBSD.or.ke>
Cc:        questions@freebsd.org
Subject:   Re: Changing Groups
Message-ID:  <15146.5562.307909.668425@guru.mired.org>
In-Reply-To: <128648822@toto.iv>

next in thread | previous in thread | raw e-mail | index | archive | help
Odhiambo Washington <wash@FreeBSD.or.ke> types:
> I am now looking at a way of changing each user's group to 'users'. Since
> staff users are only a handful, I can take care of that manually since I
> know each other byname.
> 
> I could think harder to get this done - remove the thousands of groups
> from /etc/group and even run a small script that would do recursive chown
> user:$group in /home but when it comes to the master passwd file I am
> thoroughly stumped!

Why not just use vipw and a good editor? You're going to be doing the
staff accounts by hand, they can be fixed later. That means all you
have to sort out are the system accounts, which should be less than
1000 where the user and staff accounts should be greater than 1000.
If there's no way to distinguish them, you may have a problem. If
there is, all you need is an editor commend (I used ex) like:

	g/:\([0-9]\{4\}\):\1:/s//:\1:NEWGROUP:/p

should do the trick, except that you want to replace "NEWGROUP" with
your new group number.

Since the RE matches only lines with identical user and group ids,
system ids greater than 1000 should be save if they don't have the
same group id, as should your staff userids if you fix them first and
none of them happens to have the same userid as the staff groupid.

	<mike
--
Mike Meyer <mwm@mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15146.5562.307909.668425>