LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-29-2006, 09:55 AM   #1
thejasondean
LQ Newbie
 
Registered: Apr 2006
Posts: 23

Rep: Reputation: 15
Question How to inherit permissions


i have changed permissions in /var/www into 775 with:
chmod -R 775 /var/www

however when i create a new file from nautilus it has permissions 500
this means that it's not available to the group and also that
i have to chmod all my php scripts when i create them. new files and dirs created from command line have 755

How can i do it so that every new file or dir created either from nautilus (or other software) or from the command line to have the /var/www's permissions (aka 775)

thanks
 
Old 08-29-2006, 11:09 AM   #2
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,596

Rep: Reputation: 80
Check that out :
http://blogs.gnome.org/view/cneumair/2005/12/26/0
http://blogs.gnome.org/view/cneumair/2005/12/28/0
 
Old 08-29-2006, 11:41 AM   #3
thejasondean
LQ Newbie
 
Registered: Apr 2006
Posts: 23

Original Poster
Rep: Reputation: 15
Nice link but not what i was looking for.
My problem is not how to change permissions recursively but also how to make all newly created dirs and files inherit permissions from the parent directory (like it happens in windows).

For example my /var/www is 775 and when i create a new file as a user of the group that owns /var/www it has permissions 644. I would expect (or wish at least) everything created inside /var/www to have 775 permissions...
 
Old 08-29-2006, 01:11 PM   #4
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
This is impossible, file permissions cannot be inherited in this way. You can set the default file permissions with an appropriate umask (012 or 002) but you cannot set execute permission with umask, you have to use chmod for this. If you're too lazy to type chmod after creating a script (as you should be, laziness in a programmer being a virtue of course), then you can write a wrapper script around your text editor to do it automatically based on file extension (.php, .sh etc).

Personally I write all my scripts in ~/src/sh, ~/src/python etc and install them with an 'installscript' script, which does a chmod +x and copies it to ~/bin or wherever. This lets me edit/test scripts without munging a working version, which may be still in use.

Last edited by soggycornflake; 08-29-2006 at 01:17 PM.
 
Old 08-29-2006, 05:51 PM   #5
thejasondean
LQ Newbie
 
Registered: Apr 2006
Posts: 23

Original Poster
Rep: Reputation: 15
omg ! It's a huge limitation for any OS and a pitty that linux can't inherit permissions.
However the 'installscript' script is a nice idea (or perhaps a 'newscript' script) and will make my life easier. Thanks
 
Old 08-30-2006, 04:43 AM   #6
jayakrishnan
Member
 
Registered: Feb 2002
Location: India
Distribution: Slacky 12.1, XP
Posts: 992

Rep: Reputation: 30
To set the default file permision to 775 use

umask 002
 
Old 08-31-2006, 05:57 AM   #7
thejasondean
LQ Newbie
 
Registered: Apr 2006
Posts: 23

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by jayakrishnan
To set the default file permision to 775 use

umask 002
Will that change the default file permissions globaly ? For all sessions ?
 
Old 08-31-2006, 10:32 AM   #8
magnus.therning
LQ Newbie
 
Registered: Jul 2006
Location: Gothenburg
Posts: 21

Rep: Reputation: 0
Quote:
Originally Posted by soggycornflake
This is impossible, file permissions cannot be inherited in this way. You can set the default file permissions with an appropriate umask (012 or 002) but you cannot set execute permission with umask, you have to use chmod for this. If you're too lazy to type chmod after creating a script (as you should be, laziness in a programmer being a virtue of course), then you can write a wrapper script around your text editor to do it automatically based on file extension (.php, .sh etc).

Personally I write all my scripts in ~/src/sh, ~/src/python etc and install them with an 'installscript' script, which does a chmod +x and copies it to ~/bin or wherever. This lets me edit/test scripts without munging a working version, which may be still in use.
I am fairly sure you can achieve it using ACLs:

http://www.vanemery.com/Linux/ACL/linux-acl.html
 
Old 08-31-2006, 02:18 PM   #9
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
Quote:
Originally Posted by magnus.therning
I am fairly sure you can achieve it using ACLs:
Oh, yeah, I expect so (never used them myself). I just meant you can't do it with the default unix permissions mechanism.

Quote:
Originally Posted by thejasondean
omg ! It's a huge limitation for any OS and a pitty that linux can't inherit permissions.
It would be handy in some situations, but I wouldn't call it an essential feature.

Quote:
Originally Posted by jayakrishnan
To set the default file permision to 775 use

umask 002
That won't automatically set execute permissions though, which is what thejasondean wanted.

Quote:
Originally Posted by thejasondean
Will that change the default file permissions globaly ? For all sessions ?
Unless otherwise specified, when a file is created the permissions are determined from the umask. The resulting permissions are 666 logically anded with the umask. Most distros use a default umask of 022, which results in 644 file permissions. This applies to the current shell, and will be inherited by processes spawned by the shell (though of course, processes can change their umask at will). As I mentioned before though, you cannot set execute permissions automatically via the umask. There is also no way to force particular file permissions globally with the standard unix permissions mechanism, though you should be able to achieve it with ACLs as magnus.therning pointed out.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: And the apathetic shall inherit the earth... LXer Syndicated Linux News 0 08-20-2006 07:21 PM
Samba - Inherit Permissions from Parent Directory bence8810 Linux - Software 6 08-03-2006 06:33 AM
How to make a file inherit script permissions antony.booth Linux - Security 4 03-11-2005 05:04 AM
Samba Won't Inherit Permissions blackrain69 Linux - Software 1 10-13-2004 01:46 AM
Inherit Permissions in Samba mslane Linux - Software 1 10-09-2003 05:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:21 AM.

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