You are not logged in.
I have some files that are in a complex dir tree under:
/media/data
/media/data/project1
/media/data/project1/sub1
/media/data/project1/sub2
...
/media/data/project1/sub100
/media/data/project2
...etc. etc.
Basically, I need all the dirs to be 755 but all the files to be 644. Obviously I can `chmod -R 755 /media/data` but how can cause all the files to be 644 while retaining the dirs as 755?
Last edited by graysky (2010-02-14 21:34:43)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
chmod 755 $(find /media/data -type d)
chmod 644 $(find /media/data -type f)
Offline
chmod 755 $(find /media/data -type d) chmod 644 $(find /media/data -type f)
find /media/data -type d -exec chmod 755 {} ;\
find /media/data -type f -exec chmod 644 {} ;\
Last edited by SemiBz (2010-02-14 21:13:20)
Offline
Thanks Allan, that works partially. Some of the files contain spaces and the chmod chokes on them.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Thanks Allan, that works partially. Some of the files contain spaces and the chmod chokes on them.
Shouldn't choke if used as a string ( {} ), which is why I quoted him with a more flexible command.
Offline
@SemiBz - Thanks! I didn't even see your reply... we must have posted nearly simultaneously
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
find /media/data -type d -exec chmod 755 {} ;\ find /media/data -type f -exec chmod 644 {} ;\
Oops... the ;\ should be \;
find /media/data -type d -exec chmod 755 {} \;
find /media/data -type f -exec chmod 644 {} \;
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
find /media/data -type d -exec chmod 755 {} \; find /media/data -type f -exec chmod 644 {} \;
Or
find /media/data -type d -exec chmod 755 {} +
which will be much faster (it groups the files into batches instead of chmodding them one at a time.
Offline
# recursive chmod
$ chmod 700 **/(.) # Only files
$ chmod 700 **/(/) # Only directories
If you have zsh
Offline