Google Answers Logo
View Question
 
Q: reverting to original permissions in linux ( No Answer,   10 Comments )
Question  
Subject: reverting to original permissions in linux
Category: Computers
Asked by: sunlinux-ga
List Price: $2.00
Posted: 16 Jan 2006 09:25 PST
Expires: 15 Feb 2006 09:25 PST
Question ID: 434022
this question is regarding Linux operating systtem.
suppose if you use the command chmod 777 / -R then it will change the
permission of every directiory or file in the system. what is the way
or any command to revert back to the original permissions.
Answer  
There is no answer at this time.

Comments  
Subject: Re: reverting to original permissions in linux
From: cruzinthegalaxie-ga on 16 Jan 2006 13:08 PST
 
The key would be to prevent that from happening, meaning Don't do
that! Or restore from a backup set.

If you knew what the permissions were sapposed to be, sappose files
were 644 and directories were 755 you could do the following from the
same directory.

!!!Note!!! This will not work for / because there are many root level
directories which have custom permissions. However for a simple
directory structure you could set all files to 644 by this command

find ./ -type f -exec chmod 644 {} \;

And then you could set all directories to 755 by this command

find ./ -type d -exec chmod 755 {} \;

Refer to Man - Find at www4devz.com
<a href=\"www.4devz.com/?p=4\">4devz</a>
Subject: Re: reverting to original permissions in linux
From: bozo99-ga on 16 Jan 2006 18:30 PST
 
If you have a Linux distreo with the rpm program it has a record of
the correct owner and mode of every packaged file (i.e. "rpm -Va" to
verify details will produce many complaints on a system wrongly
chmod-ed).   Of course not every file is packaged - "chmod go-w" will
be appropriate for most stuff if in doubt (which is similar to the
suggestion of cruzinthegalaxie-ga with modes 0644 and 0755).

"rpm -qa --dump" will show the intended mode (and other properties) of
every packaged file so it would be a few minutes work to apply that to
your system.
Subject: Re: reverting to original permissions in linux
From: sunlinux-ga on 17 Jan 2006 05:11 PST
 
thanks for reply
let us assume we dont have a backup. but the thing is that if somebody
has wrongly changed it being as a root it will also effect /proc file
system and will also change suid and guid like in passwd command etc.
okie for few imp files we are aware of the permissions but not all in
such scenario so are there some files which you can tell to boot the
system without any error. i.e. after correcting /proc or other imp
files required to boot till login. like if /etc/securetty permission
is not set properly root can not login.
Subject: Re: reverting to original permissions in linux
From: bozo99-ga on 17 Jan 2006 10:50 PST
 
Continuing to address your filemode problem, and assuming you have RPM:
I've added some detail and a script for converting a list of expected
modes into chmod execution to mostly restore the modes (at least where
packages are concerned) because as far as I have found RPM doesn't
seem to have this feature built-in.

http://www.notatla.org.uk/SOFTWARE/linux_filemode_recovery.txt


For getting root access in the current conditions provided your box
has a screen and keyboard and is in your presence you should be able
to reboot it using a variation in the init program (probably /bin/bash
or /bin/sash) and get a working root shell.   Your bootloader might be
GRUB or LILO, both of which allow that activity.

Here is an example using FC4, with GRUB.
Power on, wait till GRUB screen appears and starts to count down some seconds.
Before those seconds expire hit any key to interrupt it and get a menu.
At the menu type "a init=/bin/bash" and return.
Wait and expect a root shell prompt.

You might then need to do some work on mounting filesystems before you
proceed to corrective action on the filemodes.
Subject: Re: reverting to original permissions in linux
From: bozo99-ga on 17 Jan 2006 14:41 PST
 
I've just tested my partial recovery method on a FC4 box (near full
install) and it leaves nearly 5000 file objects (other than symlinks)
in mode 777.
These include the root directory which is not a member of any package.
Subject: Re: reverting to original permissions in linux
From: sunlinux-ga on 17 Jan 2006 18:49 PST
 
and what about /proc will it also be revert back to the original
permissions using this script......
Subject: Re: reverting to original permissions in linux
From: bozo99-ga on 18 Jan 2006 01:08 PST
 
In my test much of /proc never went wrong to begin with - it's not
made of normal files.

I think you should post details of your distro and what you can see of
/proc that looks wrong to you.
Subject: Re: reverting to original permissions in linux
From: sunlinux-ga on 18 Jan 2006 06:25 PST
 
i am also talking about red hat linux or fedora because in past i had
faced problem regarding /proc when somebody as root by mistake has
given 777 permissions to / on his personal system(rhel 3)
Subject: Re: reverting to original permissions in linux
From: sunlinux-ga on 17 Feb 2006 13:04 PST
 
why there is still no answer as it has already gone one month?
Subject: Re: reverting to original permissions in linux
From: joebravo-ga on 18 Feb 2006 00:03 PST
 
There's not really a good way to answer this. No, there's not an
'undo' button to restore your permissions. If you (or a user) has done
this, it's almost not worth the trouble to recover.

That being said, there have been a couple of informative comments
which should have pointed you in the right direction.

Regarding your /proc directory, you shouldn't need to worry about it,
being that it is a filesystem that is created upon boot and is handled
by the kernel.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy