LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-29-2005, 02:41 PM   #1
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Rep: Reputation: 15
Question How to Recursively Set Permissions for Directories Only


Hi all,

My problem is as such:
I have a directory that contains files as well as other directories (may be nested).
Currently, the files have permission 400 (r--------),
and the directories have permission 500 (dr-x------).

What i want to do, is to chmod the files and directories such that
the files have permission 644 (rw-r--r--),
and the directories have permission 755 (drwxr-xr-x).

Now, i have easily set the permission of all files AND directories to 644 by doing:
chmod -R u+w *
chmod -R ugoa+r *

The remaining step will be to set the permissions for the directories to 755, while leaving the permissions for the files at 644.

Any suggestion?



TIA and Regards,
Edwin
 
Old 12-29-2005, 02:51 PM   #2
mikedeatworld
Member
 
Registered: Nov 2003
Location: Farmington Michigan
Distribution: UBUNTU - Slackware - SuSE 9.1 - Knoppix - Fedora
Posts: 828

Rep: Reputation: 30
So you want the files to be seen by all users but not excutable by all?
 
Old 12-29-2005, 03:40 PM   #3
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
The find command is a real Swiss Army Knife of file management. Here is a command to do what you said was the remaining step, changing the permissions of the directories to 755 while leaving the regular files alone. Just as in the example that you provided I will start with the current working directory at the top of the tree to be changed.

find . -type d -exec chmod 755 {} \;

The find command will see the . and .. directories in your current working directory. The command may change the permission on the current working directory and its parent. Check the permission on the current working directory and its parent after running the command.

Last edited by stress_junkie; 12-29-2005 at 03:45 PM.
 
Old 12-29-2005, 11:29 PM   #4
edwin11
Member
 
Registered: Dec 2005
Distribution: Linux Mint 13 MATE
Posts: 120

Original Poster
Rep: Reputation: 15
Smile

Quote:
Originally Posted by stress_junkie
find . -type d -exec chmod 755 {} \;
Thanks! This is just what i need! Just need to understand something further.

I just read through the man page for find, and understand most of what the command does:
You're looking for all "files" below the current directory, that are of type directories, and executing the command on the found filenames by substituting the "{}" with each filename.

However, i don't understand what the last two characters, the slash and the semi-colon (\; ) are for...



Thanks Again,
Edwin

Last edited by edwin11; 12-29-2005 at 11:30 PM.
 
Old 12-30-2005, 09:54 AM   #5
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
The slash and the semicolon are part of the secret knowledge to keep newbies frustrated.

I'm not 100% sure about the next four statements but here goes. The slash is an escape character telling the bash shell to not interpret the next character. The semicolon designates the end of the find command. It is only necessary in the case where you use the -exec <command> option of the find command. It probably helps the shell parser to figure out where your find command ends.

Last edited by stress_junkie; 12-30-2005 at 09:57 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
Remove directories recursively with same name cboyd Linux - Newbie 5 01-14-2007 09:48 PM
Can ls recursively list only directories? Vosper Linux - General 3 07-16-2005 03:57 AM
set file permissions for 100 directories & its files cevjr Linux - Security 6 01-06-2005 10:23 AM
tar, excluding directories recursively towlie Linux - Newbie 3 06-17-2004 12:32 PM
recursively listing directories full paths kubicon Linux - Newbie 2 02-22-2004 03:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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