LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to share files/folders ? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-share-files-folders-710510/)

michalng 03-10-2009 10:36 AM

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--

openSauce 03-10-2009 11:11 AM

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.

frieza 03-10-2009 11:31 AM

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?

openSauce 03-10-2009 12:00 PM

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! :rolleyes:


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