Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hey im trying to make a bash script to protect the files on my NAS . I would just do a chmod -R 555 / but that prevents me or anyone else from uploading any files .
Is there any way to just chmod all the folders on the NAS to 777 so that new files can be uploaded but the folders or files cant be deleted ?
Hey im trying to make a bash script to protect the files on my NAS . I would just do a chmod -R 555 / but that prevents me or anyone else from uploading any files .
Is there any way to just chmod all the folders on the NAS to 777 so that new files can be uploaded but the folders or files cant be deleted ?
Thanks
Use "find".
Code:
find /dir/to/ -type d | xargs chmod 777
find /dir/to/ -type d | xargs chmod u+x
find /dir/to/ -type d -exec chmod u+x '{}' \;
Just some examples. The first will chmod all the dirs to 777, the second and the third one are equivalent, they will chmod the directories adding +x for their owner only.
find /dir/to/ -type d | xargs chmod 777
find /dir/to/ -type d | xargs chmod u+x
find /dir/to/ -type d -exec chmod u+x '{}' \;
Just some examples. The first will chmod all the dirs to 777, the second and the third one are equivalent, they will chmod the directories adding +x for their owner only.
This is a much more rationale way to do what that script I wrote does. It did seem like something a wheel would have already been invented for. :-) I should study the find man page one of these days and invest some time to committing things other than -i?name and -i?regex.
Last edited by jhwilliams; 07-16-2009 at 10:38 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.