LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 08-24-2006, 03:29 PM   #1
Palula
Member
 
Registered: May 2005
Location: Brazil
Distribution: Fedore Core 3
Posts: 138

Rep: Reputation: 15
Changing permission for folders only


Hi everybody!

I want to change permissions for files and folders, seperately. The problem is that IŽd like to give permissions to FILES as rw------- (600) and IŽd like to give permissions to FOLDERS as rwx------ (700). How can I do that?

Can I separate folders from files with chmod

For example:

chmod -R 700 * (just for folders)
chmod -R 600 * (just for files)

-R stands for recursively changing modes within subtrees...

Thank you!
 
Old 08-24-2006, 03:50 PM   #2
ramram29
Member
 
Registered: Jul 2003
Location: Miami, Florida, USA
Distribution: Debian
Posts: 848
Blog Entries: 1

Rep: Reputation: 47
I do the following.

chmod -R 0700 *
chmod 0600 $(find . ! -type d)

This basically changes all files to 0700 permissions recuresively (in Linux directories are pointers to groups of files); then I run another 0600 permission command of files found recursively except folders. Make sure you do it as root and make sure you are changed to the proper directory.

WARNING: Don't do this from the root directory! Run 'pwd' and make sure you are in a directory other than root '/'.
 
Old 09-02-2006, 10:10 PM   #3
vivo2341
LQ Newbie
 
Registered: Oct 2004
Location: New Hampshire
Posts: 8

Rep: Reputation: 0
Quote:
Originally Posted by ramram29
I do the following.

chmod -R 0700 *
chmod 0600 $(find . ! -type d)

This basically changes all files to 0700 permissions recuresively (in Linux directories are pointers to groups of files); then I run another 0600 permission command of files found recursively except folders. Make sure you do it as root and make sure you are changed to the proper directory.

WARNING: Don't do this from the root directory! Run 'pwd' and make sure you are in a directory other than root '/'.
Could you please help me? I installed a script which installed about 50 directorys on my hosts server in the public_html folder. What I would like to do is change the permissions on the folders only to 755 but no file permission changes at all.

Thanks in advance,

viv
 
Old 09-02-2006, 10:48 PM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,128

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
find . -type d -exec chmod 0755 {} \;

run in your public_html directory should do that.
 
Old 09-03-2006, 01:13 AM   #5
vivo2341
LQ Newbie
 
Registered: Oct 2004
Location: New Hampshire
Posts: 8

Rep: Reputation: 0
Quote:
Originally Posted by btmiller
find . -type d -exec chmod 0755 {} \;

run in your public_html directory should do that.
Thank you very much for your help.

I that the script needs to chmod 755 all of the '3cache' subfolders. So I have my main public_html with about 50 subfolders, inside these folders there is a folder called '3cache' I need to change to 755.

I tried the command "find 3cache -type d -exec chmod 0755 {} \;" but it does not seem to do it correctly.

Thanks again
 
Old 09-05-2006, 08:09 AM   #6
ramram29
Member
 
Registered: Jul 2003
Location: Miami, Florida, USA
Distribution: Debian
Posts: 848
Blog Entries: 1

Rep: Reputation: 47
Try this one:

chmod 0755 $(find . -type d)
 
Old 09-05-2006, 08:54 AM   #7
sysconfig
Member
 
Registered: Sep 2006
Location: (.)
Posts: 44

Rep: Reputation: 15
I think find command with exec parameter would be batter to use
 
Old 09-01-2008, 07:24 AM   #8
ezak
LQ Newbie
 
Registered: Sep 2008
Posts: 3

Rep: Reputation: 0
using vivo2341 way
for folder only to be 700 + sub dir
find . -type d -exec chmod 0700 {} \;

for file only to be 600 + sub dir
find . -type f -exec chmod 0600 {} \;
 
Old 02-19-2010, 03:22 PM   #9
oshanter
LQ Newbie
 
Registered: Feb 2010
Distribution: openSUSE
Posts: 1

Rep: Reputation: 1
I find it easier to use the special execute mode X (capital x).

chmod -R u=rwX,go= directory/

From Wikipedia:
Quote:
X (special execute) is not a permission in itself but rather can be used instead of x. It applies execute permissions to directories regardless of their current permissions and applies execute permissions to a file which already has at least 1 execute permission bit already set (either user, group or other).
So if you previously applied execute to all files, you'll first need to remove all rights:

sudo chmod -R 000 directory/
sudo chmod -R u=rwX,go= directory/

It's crucial to use sudo/root login, otherwise recursion will fail.
 
1 members found this post helpful.
  


Reply

Tags
chmod, subfolders


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
permission 775 to all folders and sub... amer_58 Linux - Newbie 3 04-23-2005 04:21 AM
Changing Access To Folders John_Emad Linux - Security 9 01-03-2005 01:52 AM
Changing ownership of folders Nurfen Linux - Newbie 1 08-01-2004 12:00 PM
Changing permission of folders and subfolders pablowablo Linux - Newbie 2 07-28-2004 12:11 AM
Changing kernel source folders chingasman Linux - General 2 01-07-2003 05:28 PM


All times are GMT -5. The time now is 07:29 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration