LinuxQuestions.org
Review your favorite Linux distribution.
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 02-26-2006, 04:24 PM   #1
pcorajr
LQ Newbie
 
Registered: Apr 2004
Posts: 14

Rep: Reputation: 0
chmod help and permissions


Ok so I have a problem with setting specific permissions on one of my partitions.

I have a file system on my second partition that is basically where i keep all my files, its a total of 17 folders and those 17 folder have files and other foilder in it. here is a basic layout

hdb1
|
backups
|
17 folders (APPZ,MP3,Movies,ect.....)
|
More folders and file withing the above mention files.

So for example the MP3 folder has mp3 files and 3 sub-folders that have more Mp3.

What I want to be able to do is use chmod chgrp chown to set the following permission

755 for all folders

644 for all files

I will set the owner and group to root

this file system is used as a samba share and a ftp diretory eventually i want to manipulate permissions and group , users so i can allow certain users and groups to have access to certain folders.

i have tried using the -R switch in the following matter:

chmod -R 755 backups\ <-- but this makes files and folder 755 permissions

so after wards i have to go in and do

chmod -R 644 *.* < but i have to go into every single directory and do this which sucks when i have to do changes to all files.

Is there a easy way to do this?

thanks in advance.
 
Old 02-26-2006, 04:41 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
chmod -R u=rwX,go=rX ...



Cheers,
Tink
 
Old 02-26-2006, 07:46 PM   #3
pcorajr
LQ Newbie
 
Registered: Apr 2004
Posts: 14

Original Poster
Rep: Reputation: 0
That worked like a charm! Thanks very much now i just have to play around with it and figure out the sweet spot. Im guessing that letter permissions are more flexible than number ones? Thanks very much again
 
Old 02-26-2006, 08:16 PM   #4
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,125

Rep: Reputation: 165Reputation: 165
Yes, the letter permissions are more flexible. With the letters you can use + and - to change part of the permissions as well as = to set an absolute value. The numeric form is an absolute value only.
 
Old 02-27-2006, 03:43 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
pcorajr,

Another option is to use a pair of find commands like the ones below.

Code:
find top_dir -type d -exec chmod 755 {} \;
Sets the permissions on all directories below "top_dir" to 755.

Code:
find top_dir -type f -exec chmod 644 {} \;
Likewise, for files, permission 644.

A second tip for you would be to add setGID bit to the directory permissions. This will make any new files/directories in the directory be owned by the same group as the directory itself (kinda like "group inheritance"). This can help you in avoiding unnecessary chgrp's/chown's.
There is no similar trick for setting the owner, though.

Third tip, changing owner and group can be done with 1 command, chown. You don't need to use both chown and chgrp.
ie:
Code:
chown -R user:group /some/dir/
would change both user and group ownership in one go.
 
  


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
permissions not staying using chmod after reboot dr_zayus69 Linux - Software 6 08-20-2005 04:34 AM
chmod won't change the file permissions midtown266 Linux - Newbie 12 11-28-2004 08:46 PM
chmod shows change to permissions, but ls-l doesn't vdemuth Slackware 6 07-03-2004 05:29 AM
Changing permissions (chmod) teyesahr Linux - Newbie 1 07-31-2003 05:52 PM
chmod and file permissions help qages Linux - General 5 01-27-2003 07:08 AM

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

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