From owner-freebsd-questions Fri Jun 15 7: 3:48 2001 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-65-26-235-186.mmcable.com [65.26.235.186]) by hub.freebsd.org (Postfix) with SMTP id 1C85937B405 for ; Fri, 15 Jun 2001 07:03:45 -0700 (PDT) (envelope-from mwm@mired.org) Received: (qmail 17180 invoked by uid 100); 15 Jun 2001 14:03:38 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15146.5562.307909.668425@guru.mired.org> Date: Fri, 15 Jun 2001 09:03:38 -0500 To: Odhiambo Washington Cc: questions@freebsd.org Subject: Re: Changing Groups In-Reply-To: <128648822@toto.iv> X-Mailer: VM 6.90 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Odhiambo Washington 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. 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