1

Is there a way to go into my home directory and recursively set files and directories to match my umask setting? The issue is, way back when I started using linux, I didn't understand permissions. In order to make stuff work, I set a lot of things to 777 just to keep moving and get stuff done.

Now that I understand a bit more, I've modified my umask setting to give me the permissions I actually need along with setting my primary group the way I need it to be. All is good moving forward, but I still need to deal with a large number of files and directories.

Anyway, I would like to be able to set the files to rw-rw-r-- and the directories to rwxrwxr-x and do that recursively from the home directory.

Any help would be appreciated.

2 Answers 2

1

This example of using the find command with chmod might be useful:

https://superuser.com/questions/91935/how-to-chmod-755-all-directories-but-no-file-recursively

1
  • I haven't tried it yet, but it certainly looks like it will do what I need. I'l get back to it later today. Thanks!
    – Don Fink
    Jan 3, 2015 at 21:46
1

Alan's answer above gave me the information I needed to figure this out, but I had to drill down through the comments to find my best solution. The solution I ended up using looked like this:

sudo chmod -R u=rw,g=rw,o=r,a+X /path/to/target

The idea in my case was to have users and groups read and write and others read only. Specifically setting users and groups to rw and others to r effectively removed the 777 permissions I had on pretty much all my files. Then, setting all to X (uppercase X) went back and added execute permission to directories.

1
  • Nice thanks! and I leave this comment for myself sudo chmod -R a=-x,u=rwX,g=,o= folder owner rw, others no access, directory with rwx. This will clear existing x on files :) Jan 31, 2021 at 6:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .