how to restore deault file permisions of home directory?

Hi,

I used this command in suse 11.1

chmod -R 777 “user directory”

where “user directory” is the name of my home directory. Is there anyway to restore the default permissions of s home directory?

Who is listed as the owner currently?

> chmod -R 777 “user directory”

i have to wonder who (and where) you picked up the idea that doing
that was a good thing to do? and, tell us what you were trying to
‘fix’ by doing it…

and, can you ask him/her what to do now since you system is toast??

at the very least you should let us know where it came from so we can
put the word out that that person/site/mail list/blog whatever is
killing linux systems (probably intentionally…it is kinda like that
‘virus’ that went around giving step by step directions to clean a
non-existent virus by deleting the C:\Windows directory–thousands of
folks killed their own system)…

i can’t do better for you because i’ve never actually used chmod,
ever…but, stick around, someone must know how to recover short of
the Redmond Cure-ALL (reinstall)


platinum

chmod -R 755 /home/username

or, same thing

chmod u=rwx,g=rx,o=rx /home/username

Reference: Notes on chown and chmod

That will revert 99% of them. The other 1%, well, a bit of a security flaw but nothing to worry over.

I don’t know of any undo commands for chmod, but I would advise removing write and execute permissions for other and group

chmod 'chmod -R go-wx "user directory"

and remove read permissions for documents directory

chmod 'chmod -R go-r "user directory"/Documents

This isn’t a perfect solution, but will get the permissions quite close to correct.

If you have another user account, from the home directory of the other user use:

ls -l

and make a note of the permissions, then go to your account and chmod on User Group Other to + or - Read Write eXecute to match the other account.

if you get stuck use:

chmod --help

Good luck,
Barry.

For only the home directory it should be drwxr-xr-x (or chmod 755). But for the -R option you can’t.

The thing that comes nearest to it is using your latest backup and looking in there what the directories/files you had at the time of backup had as access bits at the time of backup. When you belong to those that never take backups because they never do anything stupid (like rm -r or chmod -R) and will never will have a faulty disk, you do not even have that possibility.

Apart from the advices given by others above, you must be aware of the fact that e.g. the x-bits are set for user/group for each and every file. So in places where you have only data files (like your pictures or your music) you could do a

chmod a-x *.mp3

as an example.

More intelligent guessing (and checking by e.g. doing first an *ls -r *.dontknow *BEFORE doing *chmod -R g-w .dontknow) from your side may improve the situation over time.

Be glad you did not do this as root in / (there is always a bright side lol! )

find ~ -type d -exec chmod 755 {} \;

find ~ -type f -exec chmod 644 {} \; 

And then maybe also (if one has scripts/executables in $HOME/bin which is also in $PATH):


find ~/bin/ -type f -exec chmod 755 {} \;

platinum wrote:
>> chmod -R 777 “user directory”
>
> i have to wonder who (and where) you picked up the idea

i really would like to know where s/he got the idea to enter that
command…(i’m just enough a conspiracies searcher to believe it could
be our friends from Redmond sowing their FUD in yet another way…)

well, this is mtataol’s first and only posting here, maybe he just
came (from a Washington State campus) to see how many of us were
stupid enough to do that command on our system to see what happened…

a non-exhaustive review of the results of googling “chmod -R 777”
indicates lots of folks trying to ‘fix’ access permission problems in
various areas with it, and failing…


platinum