LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 07-15-2009, 09:45 PM   #1
LooieENG
LQ Newbie
 
Registered: Jul 2009
Posts: 1

Rep: Reputation: 0
CMOD all folders but not any files ?


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
 
Old 07-15-2009, 09:59 PM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 210Reputation: 210Reputation: 210
I wanted to do something similar once upon a time. You could adapt this short script I wrote...

http://www.jamesonwilliams.com/chpwn

And set the "sticky bit" if you're going to 777. See man sticky.
Or maybe this too: http://www.linuxsa.org.au/pipermail/...er/049071.html

What you're describing sounds like /tmp.

However, I don't think this is the best approach.

Last edited by jhwilliams; 07-15-2009 at 10:03 PM.
 
Old 07-15-2009, 11:43 PM   #3
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Quote:
Originally Posted by LooieENG View Post
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.
 
Old 07-16-2009, 11:37 AM   #4
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 210Reputation: 210Reputation: 210
Quote:
Originally Posted by i92guboj View Post
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.
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 11:38 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
find -exec command to recursively delete files and folders in folders with X name Joan Murt Linux - Newbie 2 07-08-2009 05:35 PM
syncing two folders where files sourcefiles without brackets[] and target files with Byenary Linux - Networking 0 04-08-2008 03:14 AM
permissions using cmod/chgrp not changing heyme Linux - Newbie 5 11-18-2007 06:46 PM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 03:27 PM
Samba can create new files and folders but access denied in any new folders k.king Linux - Networking 2 01-15-2006 07:14 AM


All times are GMT -5. The time now is 02:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration