LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 06-21-2012, 05:16 AM   #1
tqz
Member
 
Registered: Jan 2008
Posts: 67

Rep: Reputation: 15
Setting read only on files within directory but not directory itself...


hELLO ALL

I need to mark all the files within a dir as read only, but not set the dir as being read only (I still need to be able to move files into the folder).

How can this be done? Also, if a file is moved into this folder, I would like the read only setting to be automatically set to this file - can this be done - or would i need a script of some sort.

Thanks

t.
 
Old 06-21-2012, 05:18 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
Well you just chmod the files... "chmod a-w file" Not sure if I'm missing something there...

as for automatically, yeah a cron job is probably the way forward.
 
Old 06-21-2012, 05:28 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
In the directory:
chmod -w * ...This acts on everything in the directory---if you want only certain types of files then--e.g.:

chmod -w *.jpg ....acts only the the jpeg files
 
1 members found this post helpful.
Old 06-21-2012, 05:46 AM   #4
tqz
Member
 
Registered: Jan 2008
Posts: 67

Original Poster
Rep: Reputation: 15
Hi Thanks for both of your responses!

chmod -w * when I am in the directory marks all the files as read only. But lets say a user moves a file within this folder - i want it to also be marked as read only - automatically. So I guess I will have to set up a cron job to do this.

Also chmod -w * doesnt work on the files within the subdirectories???
 
Old 06-21-2012, 05:59 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
chmod takes a -R switch http://linux.die.net/man/1/chmod
 
1 members found this post helpful.
Old 06-21-2012, 06:22 AM   #6
tqz
Member
 
Registered: Jan 2008
Posts: 67

Original Poster
Rep: Reputation: 15
Thanks - I should know all this....but it has been some time and I am v forgetful!
 
Old 06-21-2012, 06:37 AM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by tqz View Post
Thanks - I should know all this....but it has been some time and I am v forgetful!
Join the club!!

what I do --whenever I have not used a command in a while-- is to skim the man page---often this will remind me of some key aspect of the syntax.
 
  


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
Shell script to read all files from a directory and print the documents for_u_day@yahoo.com Linux - Newbie 1 02-16-2012 02:28 PM
Setting Read permissions of a directory for root user only BlueSkull Linux - Newbie 4 03-23-2010 12:31 PM
Setting up a daemon to access files in the /dev directory. yankeeinga Linux - Server 2 12-19-2008 10:10 AM
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 11:55 PM
setting a group for new files in a directory eantoranz Linux - Security 2 01-18-2005 02:44 PM


All times are GMT -5. The time now is 08:36 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