LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 03-10-2009, 10:36 AM   #1
michalng
Member
 
Registered: Dec 2005
Distribution: Debian KDE / Fluxbox
Posts: 222

Rep: Reputation: 46
How to share files/folders ?


I've create a share partition (/mnt/sharing , ext3) on a desktop computer that is used by several users.

All users is having a common group "users"

However, when a user creates a file in the common folder, the file permissions is
Quote:
-rw-r--r--
What should I set so that the files created in the common folder will have the permission of
Quote:
-rw-rw-r--
 
Old 03-10-2009, 11:11 AM   #2
openSauce
Member
 
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Rep: Reputation: 39
Put the following in each user's .bashrc:

Code:
umask 0002
Alternatively, put the line in /etc/bashrc - you'll probably find there's a line in there atm setting umask 0022.

See man bash for how umask works.
 
Old 03-10-2009, 11:31 AM   #3
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
chmod g+w file would also work

002 is -------w-
you would want 660 to get rw-rw----
the default rw-r--r-- is 644

of course umask perhaps works in reverse of this?

Last edited by frieza; 03-10-2009 at 11:36 AM.
 
Old 03-10-2009, 12:00 PM   #4
openSauce
Member
 
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Rep: Reputation: 39
I think he wanted it so that rw-rw-r-- was the default, without having to chmod each new file. I should mention that my advice only applies if every user's login shell is bash (this is the usual). If they use different shells it'll be some other file you need to edit, hopefully the manpage will say which one.

I've just experimented and this may not work for other programs - I've changed my umask at the command line but gedit is still creating files with the old permissions. Possibly you need to log out and log back in again before it takes effect everywhere - let us know if you do this and it's still not working.

And thinking about it, this may not be exactly what you want - the umask applies to all newly created files, so new files in the users' home dirs will also be rw-rw-r--. There are a couple of different ways around this:
  • forget the umask and have an hourly cron job to chmod g+w the whole shared directory (inelegant but it'll work!)
  • create a group for each user of which they are the sole member. chown everything in their home dirs to their personal group, and set the setgid bit on the directories (see here for details of how/why). Then any file they create in their home dirs will not be writable by other users, but files they create in any other dir will be.

Unfortunately there doesn't seem to be any way to get new files to simply inherit permissions from their parent directory. Well, I saw something called "ACLs" in another post, but don't know how they work - look into them if you want.

@frieza: yes, umask inverts the octal permissions, "masking" the bits you don't want. Don't ask why!
 
  


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
Samba can create new files and folders but access denied in any new folders k.king Linux - Networking 2 01-15-2006 06:14 AM
share folders/files on LAN debian/MS computers. ecampii Linux - Networking 2 09-28-2005 08:05 AM
Share folders hylke Linux - Newbie 8 10-22-2004 01:32 PM
files&folders permissions under SAMBA share shani Linux - Software 2 11-20-2003 11:48 AM
How to share files,folders and printer on a LAN ? ZhiYi Linux - Networking 2 02-15-2003 06:14 AM

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

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