[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
equalize permissions with chmod?
From: |
Martin Bernreuther |
Subject: |
equalize permissions with chmod? |
Date: |
Wed, 7 May 2008 00:22:59 +0200 |
User-agent: |
KMail/1.9.9 |
Hello,
is there an easy way (without writing a bash script) to copy
e.g. the group permissions of a file (or directory) to the other permissions
(maybe even recursively for a whole directory) with chmod?
E.g. a file with -rwxr-x--- should be changed to -rwxr-xr-x
and ----r----- should be changed to ----r--r--
The same should be possible for other combinations like granting
the group the same permissions like the owner etc.
I didn't find anything in the chmod man pages:
This is not like + - or =, which set directly a mask and also
not --reference, since this will refer to the same permissions
of another file.
A (not very elegant try for a) solution for a single file
"pathtotestfile/testfile" permission change:
find pathtotestfile -maxdepth 1 -name "testfile" -perm -g+r '!' -perm -o+r
-exec chmod o+r '{}' ';'
find pathtotestfile -maxdepth 1 -name "testfile" -perm -o+r '!' -perm -g+r
-exec chmod o-r '{}' ';'
find pathtotestfile -maxdepth 1 -name "testfile" -perm -g+w '!' -perm -o+w
-exec chmod o+r '{}' ';'
find pathtotestfile -maxdepth 1 -name "testfile" -perm -o+w !' -perm -g+w -exec
chmod o-r '{}' ';'
find pathtotestfile -maxdepth 1 -name "testfile" -perm -g+x '!' -perm -o+x
-exec chmod o+r '{}' ';'
find pathtotestfile -maxdepth 1 -name "testfile" -perm -o+x '!' -perm -g+x
-exec chmod o-r '{}' ';'
Check if a permission is set (or not set) for the group and missing (existant)
for the others
and correct that (only if necessary and try to avoid unnecessary searches)
Thanks,
Martin
P.S.:
BTW, Is "find" the only tool to directly determine, if permissions are set?
"test" seems not to offer much here.
--
_________________________________________
Martin Bernreuther address@hidden
- equalize permissions with chmod?,
Martin Bernreuther <=