From owner-freebsd-questions Fri Nov 16 0:15:10 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mip.co.za (puck.mip.co.za [209.212.106.44]) by hub.freebsd.org (Postfix) with ESMTP id 3984137B405 for ; Fri, 16 Nov 2001 00:15:04 -0800 (PST) Received: from patrick (patrick.mip.co.za [10.3.13.181]) by mip.co.za (8.9.3/8.9.3) with SMTP id KAA09637; Fri, 16 Nov 2001 10:15:05 +0200 (SAST) (envelope-from patrick@mip.co.za) From: "Patrick O'Reilly" To: , Subject: RE: help on system accounts Date: Fri, 16 Nov 2001 10:19:29 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) In-Reply-To: <9t2g7m+mj09@eGroups.com> X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal 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 > From: jessie@power-jessie.net > > 2. i've accidentally chowned some user files to root and > i want to put them back to their respective user's ownership. > how can i easily change the ownership/group of files/dirs? > > i.e > > drwx--x--- 2 root wheel 512 Oct 10 23:16 gates > drwxr-xr-x 7 root wheel 1536 Nov 13 11:36 jessie > . > . > drwx--x--- 2 root wheel 512 Oct 10 23:16 zeus > > i want it to be like this: > > drwx--x--- 2 gates gates 512 Oct 10 23:16 gates > drwxr-xr-x 7 jessie jessie 1536 Nov 13 11:36 jessie > . > . > drwx--x--- 2 zeus zeus 512 Oct 10 23:16 zeus > try something along these lines: # cd /home # for dir in `ls` # list all the directories ... > do # and for each directory ... > echo $dir # display the directory name ... > chown -R $dir:$dir $dir # and set the owner:group ... > done # until they are all done. # Note 1: If you have 13,000 directories that need fixing, then this process is likely to take some time. That's why I included the "echo $dir" line, so that you will be able to see how the script is progressing. Note 2: I've written this to work in the bash (and similar) shells. I think 'csh' syntax will be different. Note 3: It looks like you might be wanting to clean up the permission settings too? 'gates' and 'jessie' have 710 and 755 respectively. Is that by design or by accident? Patrick. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message