RE: chown command goof up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



> -----Original Message-----
> From: centos-bounces@xxxxxxxxxx 
> [mailto:centos-bounces@xxxxxxxxxx] On Behalf Of Ross S. W. Walker
> Sent: Monday, February 12, 2007 4:58 PM
> To: CentOS mailing list
> Subject: RE:  chown command goof up
> 
> > -----Original Message-----
> > From: centos-bounces@xxxxxxxxxx 
> > [mailto:centos-bounces@xxxxxxxxxx] On Behalf Of David A. Woyciesjes
> > Sent: Monday, February 12, 2007 3:35 PM
> > To: CentOS
> > Subject:  chown command goof up
> > 
> > 	Basically, what I typed was:
> > chown -R user2:user2 *
> > chown -R user2:user2 .*
> > chown -R user2:user2 *.*
> > ...all in /home. Duh. I forgot which way recursive went.
> > So, I then did:
> > chown -R root:root *
> > chown -R root:root .*
> > chown -R root:root *.*
> > ...this time in / to try and f things. Duh again. Other 
> items need to 
> > have other owners & groups.
> > 
> > 	So, how can I fix this? In MacOSX, there is a utility 
> > to fix all 
> > permissions on the system. Is there a similar item in CentOS?
> > 
> > 	Here's what I originally wanted to do:
> > Started with user1. Got everything setup just right. Then 
> > created user2. 
> > I wanted to use all the settings, mail, etc. from user1 for 
> user2. My 
> > thought was to just copy everything in /home/user1 to 
> > /home/user2, then 
> > use chown on all of the files. This is where I got myself into this 
> > pickle...
> > 
> > 	Any ideas?
> 
> To fix the home dirs:
> 
> # getent passwd | awk -F: '{system("if [ -d "$6" ]; then chown -R
> "$3":"$4" "$6"; chmod -R 700 "$6";fi")}}'
> 
> This should set perms for all users (and services!) home directories,
> make sure the 700 is adequate for service accounts, which is 
> probably is
> not.

To avoid service account fubar:

# getent passwd | awk -F: '{system("if [ -d /home/"$1" ]; then chown -R
"$3":"$4" /home/"$1"; chmod 700 /home/"$1"; fi")}'

That'll restrict it to just home directories in /home, if they are named
after the usernames, if not, well you will need to write your own test
case.

-Ross

______________________________________________________________________
This e-mail, and any attachments thereto, is intended only for use by
the addressee(s) named herein and may contain legally privileged
and/or confidential information. If you are not the intended recipient
of this e-mail, you are hereby notified that any dissemination,
distribution or copying of this e-mail, and any attachments thereto,
is strictly prohibited. If you have received this e-mail in error,
please immediately notify the sender and permanently delete the
original and any copy or printout thereof.

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux