chmod only immediate directory?

 
Thread Tools Search this Thread
Operating Systems Linux Red Hat chmod only immediate directory?
# 1  
Old 02-03-2011
chmod only immediate directory?

I am having trouble figuring out how to do a "chmod o-w" for all files under a certain directory, while excluding directories under that certain directory.

I can do

Code:
chmod -R o-w /thisdirectory

but that changes permissions of all directories under the directory as well as files. I just want files immediately under 'thisdirectory'... Thanks in advance.

-Austin
# 2  
Old 02-03-2011
You could do
Code:
find /thisdirectory -type f -exec chmod o-w '{}' ';'

to run it only on files.

If you're on a platform that supports the syntax, a minute change will make it run much faster by putting as many arguments into chmod at once as it safely allows:
Code:
find /thisdirectory -type f -exec chmod o-w '{}' '+'

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 02-03-2011
Quote:
Originally Posted by Corona688
You could do
Code:
find /thisdirectory -type f -exec chmod o-w '{}' ';'

to run it only on files.

If you're on a platform that supports the syntax, a minute change will make it run much faster by putting as many arguments into chmod at once as it safely allows:
Code:
find /thisdirectory -type f -exec chmod o-w '{}' '+'

Ah thanks, I'll just use -maxdepth 1 to get files only immediately under it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

excluding a directory with chown, chmod

does anyone know how to exclude a directory with chown or chmod? im trying to do something like this chown $username:$username $directory/* chown $username:$username $directory/.* chown $username:$username $directory and find $directory/* -type f -exec... (1 Reply)
Discussion started by: vanessafan99
1 Replies

2. UNIX for Dummies Questions & Answers

chmod

Hi I tried to use chmod in unix to change my file's permission. chmod 701 hello.cgi And it did change my desired file's permission. Yet, the name of the file is changed to hello.cgi* . And therefore I cannot compile it after that. So, I just wondering why there is an extra '*' in the file's... (2 Replies)
Discussion started by: alvin8906
2 Replies

3. UNIX and Linux Applications

What is the difference between chmod in solaris and chmod in Linux?

i think it is the same in both... Iam i right? (1 Reply)
Discussion started by: sumaiya
1 Replies

4. Programming

chmod:No such file or directory

sprintf(fname, "core.%d", pid); (void) unlink(fname); if (ttrace(TT_PROC_CORE, pid, 0, 0, 0, 0) != 0) { perror("TT_PROC_CORE pass"); Fail(); } if (chmod(fname, 0) != 0) { perror("chmod"); Fail(); } Hi, If i execute above code,everytime am getting below... (1 Reply)
Discussion started by: mansa
1 Replies

5. Solaris

Unable to chmod a file/directory

This is Solaris 10, by the way. I am aware of ACLs or something like that in Solaris 10 where you can change who can access directories and such that goes beyond the standard permisisons (chmod and rwxrwxrwx). Although I thought when these were being used, the permissions listing would show a... (12 Replies)
Discussion started by: lyonsd
12 Replies

6. UNIX for Dummies Questions & Answers

chmod erased a directory(?)

I was attempting to change permissions on a directory, used a 'chmod -rwrwrw DirectoryName' command, and hit enter. Now, that directory shows that it's empty! How could this be? Any Ideas? Thanks (1 Reply)
Discussion started by: SmooBG
1 Replies

7. UNIX for Dummies Questions & Answers

what to chmod to write in a directory?

i am unable to write to some .php files in the following directory: drwxr-xr-x 3 headroom max 448 Jun 6 2004 Docs i already tried this: chmod +777 Docs chmod: changing permissions of `Docs': Operation not permitted thanks for your help! (2 Replies)
Discussion started by: phonedog365
2 Replies

8. UNIX for Dummies Questions & Answers

chmod...

Hey everyone, I was wondering if there was a quicker way to chmod a lot of files than doing what im currently doing. At the moment, im doing chmod 777 *filename* - but I have a lot of files, sub-directories, sub-files etc etc. And at the moment I see I have to chmod every single file... (3 Replies)
Discussion started by: mo0ness
3 Replies

9. UNIX for Dummies Questions & Answers

directory permissions and CHMOD

I am working on a new UNIX box that has been delivered to us, and noticed that the /home directory has 555 permissions on it (dr-xr-xr-x). Any attempt to create write permissions fails on this directory (such as chmod 777), responding only with a message; chmod: WARNING: can't change home ... (3 Replies)
Discussion started by: ncarmstrong
3 Replies

10. UNIX for Dummies Questions & Answers

CHMOD Help!!

Ok, listen.........I was using FTP Works to remove and add some files to a domain server. I messed with chmod button and made it so that no-one could access or their browsers could execute files and 2 or three certain directories. If anyone knows how to use this command and will give me a heads up... (2 Replies)
Discussion started by: jarrell
2 Replies
Login or Register to Ask a Question