[mdlug] a chown -R disaster recovery question
Aaron Kulkis
akulkis00 at gmail.com
Wed Dec 17 15:33:50 EST 2008
mdlug at wowway.com wrote:
> Hello, let's say I have a system where there are hundreds of users, with a
> system of NIS-mapped home dirs such as this:
>
> /filesystem/vol/users/user1
> /filesystem/vol/users/user2
> /filesystem/vol/users/user3
> ...
> /filesystem1/vol1/users/userX
>
> and each user is owner of their own home dir.
>
> Accidentally, I go through at the level of /filesystem/vol and
> I chmod -R user1 * (I know, that was a mistake).
>
> Is there a way to run back through that and chown everyone back?
>
Of course, you just use chown again.
#!/bin/bash
TRUNK=/filesystem/vol/users
chown __root?__ $TRUNK
cd $TRUNK
for USER in *
do
chown -R $USER $USER
done
# end of shellscript.
Put the above text in a file,
chmod that file to mode 755
and then execute that file
for example, say you put it in a file called "chownback"
(put this in some place like /root/bin or /local/bin or /usr/local/bin)
cd /usr/local/bin
cat > chownback ## cut & past the script text on the next line
# then use ctrl-D to end input
chmod 755 chownback
./chownback
More information about the mdlug
mailing list