LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 08: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, 08:59 PM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
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 09:03 PM.
 
Old 07-15-2009, 10:43 PM   #3
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
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, 10:37 AM   #4
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
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 10:38 AM.
 
  


Reply



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 04:35 PM
syncing two folders where files sourcefiles without brackets[] and target files with Byenary Linux - Networking 0 04-08-2008 02:14 AM
permissions using cmod/chgrp not changing heyme Linux - Newbie 5 11-18-2007 05:46 PM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 02:27 PM
Samba can create new files and folders but access denied in any new folders k.king Linux - Networking 2 01-15-2006 06:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:31 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
Open Source Consulting | Domain Registration