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-11-2008, 09:23 PM   #1
replica9000
Senior Member
 
Registered: Jul 2006
Distribution: Debian Unstable
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 260Reputation: 260Reputation: 260
default file permissions in a folder


Is there a way to set default file permissions in a folder?

Basically this is what I have:

a shared folder /home/me/shared
this folder is shared between NFS and Samba

now this folder i would use "chmod -R a=rwx /home/me/shared"

but when i create or copy files to this folder from the host, the permissions are
-rw-r--r-- me me

and when i do this from another location, the permissions are
-rwxr--r-- nobody nogroup

I want all the files and folders created or copied to this folder to automatically inherit the -rwxrwxrwx

And what effect does the nobody and nogroup have on the files?
 
Old 08-11-2008, 11:13 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
All files are created initially with rxxrwxrwx permissions. Then the permissions are masked with the umask value. There is no reason to have the X bit set on files by default. Only executable file should have the x bit set, and you shouldn't allow executing files (at least accidentally) on a world writable share. A world writable share should be have it's own partition mounted with the noexec and nodev options. Also set the sticky bit on the directory being shared. E.G. chmod a=rwxt <directory>.

For a world writable share, the Samba server probably has an option to map a bad user to Guest. Guest is the windows equivalent of "Nobody". The directory being shared should be owned by Root. You don't want a regular user to be able to delete the entire directory. If an unauthenticated user saves a file in the share, the file will be owned by the "nobody" user. If the user is authenticated it will be owned by that user (Unless you use the Force User option).

The sticky bit protects files from being deleted by any user with write access to the directory. Deleting files writes to the directory and not to the file. If a user wants to protect a file from being altered or overwritten then they need to change the permissions to read only. The user needs to be an authenticated user however, so that the file isn't owned by nobody.
 
Old 08-11-2008, 11:34 PM   #3
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
A minor clarification in an area that often confuses new users. All files are created with the modes specified in open() or creat() calls, which are then subject to umask. This is only really relevant to programs that provide a mechanism for specifying default file / directory creation modes.
 
  


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
Applying default permissions for newly created files within a specific folder mattydee Linux - Desktop 29 10-30-2016 09:55 PM
Setting default permissions for folder dickohead Linux - General 1 04-17-2006 09:55 AM
Default permissions of files and folder maginotjr Slackware 2 07-29-2005 03:52 AM
default files and folder acl permissions Baltasar Fedora 4 08-30-2004 12:50 PM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 02:26 AM

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

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