LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 06-12-2005, 10:01 AM   #1
jogurt666
Member
 
Registered: Nov 2003
Location: Poland => Mazowieckie => Ok'a
Distribution: Gentoo
Posts: 176

Rep: Reputation: 30
how to retrieve original chmod of my home directory?


i've changed chmod of all files and directories in my home directory to 777 by an accident. is there a way of retrieving them their original chmods without changing each files chmod one by one. i can't just type chmod 644, because it'll make all the directories inaccessible.
 
Old 06-12-2005, 10:44 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
well each driectory will have the same mask, just a different owner. so just run "chmod 755 /home/*" and your done. that's if you want a 755 mask of course.
 
Old 06-07-2006, 08:45 PM   #3
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: Tupelo, MS
Distribution: Gentoo
Posts: 6,926

Rep: Reputation: 124Reputation: 124
Old thread, but perhaps:
Code:
root@silas:~# chown -R mingdao.users /home/mingdao
root@silas:~# chmod -R 644 /home/mingdao
Since I'm a n00b, it would be interesting what experienced users say...

jogurt666,

Why did you never post back what you did?
 
Old 06-07-2006, 09:36 PM   #4
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: Ubuntu, FreeBSD, NetBSD
Posts: 1,449

Rep: Reputation: 47
This is an old post but this would be the way I would handle such an issue.

Code:
cd $HOME
find ./ -type f -exec chmod 644 \{\} \;
find ./ -type d -exec chmod 755 \{\} \;
I am not in front of a Linux system at the moment but that should work in bash and on a linux system -- I've double checked the relevant man pages just to make sure.

Now, there are a couple of caveats. Do not run this as root. That alone will avoid 90% of the possible problems. Also, be aware that while find does not follow symbolic links by default... do not depend on that. You may want to make sure that the user doesn't have symbolic links to places outside their home directory or have anything mounted under it.

The second should be a very rare situation. Still, do not run it as root. Only run this as the user of the home directory.

Edit: Explanation, the first line changes into the current user's home directory. You should be here already and you should really make sure you're the user and not root or someone else. Not all users want all their files to be world readable and may have changed the permissions on some.

The second line finds all the physical files and changes their permissions to the default.

The third finds all the directories and changes their permissions to the default.

Note: This will break things. Some files and directories can not be world readable. "$HOME/.ssh/" for example and "$HOME/mbox", "$HOME/kde*", "$HOME/.gaim/", etc.

Almost all of these will warn you of this problem and suggest how to correct it. So if a program suddenly stops working... this is what to check. In the original problem, this problem would have already existed so it would not be a concern before running the original command(s). A little hand tweaking of a few things should be expected. But this gets the bulk of the work done.

Last edited by frob23; 06-07-2006 at 09:45 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Root/Home Directory and setting up FTP for home directories? Mankind75 Linux - Newbie 6 07-23-2006 03:37 PM
chmod directory help ycamera2mank Linux - Software 3 10-04-2005 12:43 AM
ProFTP problem: can login but not retrieve directory listing Singing Banzo Linux - Networking 4 03-23-2005 01:11 PM
Chmod = no access to home folder! DeathPrawn Linux - Newbie 4 02-12-2005 12:50 PM
How to retrieve my my /home/name Dir from lost+found? orranview Linux - Newbie 2 03-21-2004 05:49 AM


All times are GMT -5. The time now is 08:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration