Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-10-2009, 11:36 AM   #1
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
What should I set so that the files created in the common folder will have the permission of
Old 03-10-2009, 12:11 PM   #2
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

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

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, 12:31 PM   #3
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: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
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 12:36 PM.
Old 03-10-2009, 01:00 PM   #4
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!


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

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration