[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wish: chmod -R to handle directories and files differently
From: |
Richard Neill |
Subject: |
wish: chmod -R to handle directories and files differently |
Date: |
Tue, 15 Apr 2014 12:43:39 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 |
Dear All,
May I suggest an enhancement to chmod? The problem is that, when using
chmod -R, the permissions we want to apply to files are usually not the
same as for directories, especially regarding the executable state.
Here are a few ideas for how this could work...
1.
Add a "-d" option that specifies a different permission for directories. Eg:
chmod -R 644 -d 755 path/to/dir
#This sets everything to 644 (as normal for chmod), but treats
#directories specially, setting them to 755.
2.
Add a "-u" option for using the umask. E.g:
chmod -R -u path/to/dir
#This applies my standard umask, for both files and dirs. It would be
#useful for fixing up broken permissions quickly.
3.
Add "-D" and -"F" options to mean "apply to directories only" or "apply
to files only"
E.g.:
chmod -RD 755 /path/to/dir
recursively sets directories 755, (and leaves files unaltered).
chmod -RF 644 /path/to/dir
recursively sets files to 644, (and leaves directories unaltered).
Typical use-cases:
(a) I have several nested directories of photos that originated from a
digital camera with a FAT filesystem. Therefore all the directories,
subdirectories and files are mode 777. I want to remove the executable
permission from the files, but not the directories.
=> chmod -Ru my/photos/
(alternative is some ugliness with "find -type d")
(b) I want to fix up my ~/ssh permissions:
=> chmod -R 600 -d 700 ~/.ssh
(alternative is two invocations of chmod)
Thanks for your time - I hope you like my idea.
Richard
- wish: chmod -R to handle directories and files differently,
Richard Neill <=