You are not logged in.

#1 2010-02-21 05:52:47

samdavid6
Member
Registered: 2008-09-18
Posts: 16

Disk Permissions

I've been using linux for about 3 years now, so by rights this isnt a newbie question, but I think its so basic that I should post this here.

I have 3 users on my system, and I have two hard disks.  One contains /root and /home and everything else, the other one is used primarily for storage, photos, music, movies etc.

Now the thing is, if I save a file on that storage disk, the other users cant access them until I go and manually chmod all the files on the disk to all users.

Is there a way to make one disk and all the files in it accessible by anyone?  The other disk with the home drives is fine the way it is, I just want to do this for the additional disk.

Here's my fstab, I'm thinking something could be the problem there, but on the other hand, maybe I need to change partitions on the disk or something.

#
# /etc/fstab: static file system information
# <file system>        <dir>         <type>    <options>          <dump> <pass>
devpts                 /dev/pts      devpts    defaults            0      0
shm                    /dev/shm      tmpfs     nodev,nosuid        0      0

/dev/sda1 /boot ext2 defaults 0 1
/dev/sda2 swap swap defaults 0 0
/dev/sda3 / ext4 defaults 0 1
/dev/sda4 /home ext4 defaults 0 1
/dev/sdb1 /media/Disk2 ext4 rw,auto,user 0 0

Offline

#2 2010-02-21 06:08:42

samdavid6
Member
Registered: 2008-09-18
Posts: 16

Re: Disk Permissions

update:

I managed to get all users "read" permissions by changing the fstab line to

/dev/sdb1 /media/Disk2 ext4 rw,user,umask=000 0 0

But I still dont know how to give everyone read AND write access for all the files in the disk..

Last edited by samdavid6 (2010-02-21 06:09:00)

Offline

#3 2010-02-21 06:11:57

Corex
Member
From: Sweden
Registered: 2010-01-31
Posts: 63

Re: Disk Permissions

Try /dev/sdb1 /media/Disk2 ext4 defaults,user,umask=000 0 0

Offline

#4 2010-02-21 06:17:22

vik_k
Member
From: Pune, India
Registered: 2009-07-12
Posts: 227
Website

Re: Disk Permissions

i've got abt the same setup as you (3 users, /home secure), i also share data with the help of a 3rd partition.
permissions of the filesystem are 1775 (note the sticky bit),

you can put all your users in "users" group & then "chgrp -R users <filesystem mount point>" to simplify permissions

so any user can read a file & can create their own files but they cannot tamper files owned by other users.
hope that helps

Last edited by vik_k (2010-02-21 06:19:24)


"First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack." ~ George Carrette

Offline

#5 2010-02-21 06:30:53

samdavid6
Member
Registered: 2008-09-18
Posts: 16

Re: Disk Permissions

Thanks for the help people.

Corex, changing "rw" to "defaults" didnt change anything.  The other users could read the files I saved on the drive, but they cant delete them or update them or change them.

vik_k, the others on the system can already read the files.  But they cant change them.  For example, my wife saves our photographs there, but when I login to the system, I can view the files, but I cant retouch them and save them or delete them.

Offline

#6 2010-02-21 06:39:52

vik_k
Member
From: Pune, India
Registered: 2009-07-12
Posts: 227
Website

Re: Disk Permissions

^ okay, might be you can then remove the sticky bit, the perms will be 775 & put all your users in "users" group.
then "chgrp -R users <filesystem mount point>".

you can edit files owned by other users now.


"First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack." ~ George Carrette

Offline

#7 2010-02-23 01:44:14

samdavid6
Member
Registered: 2008-09-18
Posts: 16

Re: Disk Permissions

Sorry guys.

vik_k, so I added all the users to a new group (called it storage instead of users), did a "chgrp -R storage /media/Disk2" and chmod'ed the permissions as well to 775.

Now I can read/write/edit all the files on the disk.

However anything I save there gets saved on the disk with the permissions showing as owned by "sam" (read and write), group of "sam" (read only).

"Others" has read permissions only too.

Offline

#8 2010-02-23 13:01:40

stryder
Member
Registered: 2009-02-28
Posts: 500

Re: Disk Permissions

I hope you find a real "linux" solution to this - I have long given up TBH. You can try to set the bash profile umask to 002 for everyone. You can try to make the group id of everybody common in /etc/passwd (I think). The default is username:username. This way whatever they save will have a common group and the group will have read/write privileges. BUT this will be so everywhere and not only on the partition you wish. Policykit seems to be something that can be explored. These are possibilities I thought of recently but have not tried.

Ultimately what I did was to use 1 partition as FAT32. With FAT32 you can set umask and gid in your fstab line. You cannot do so for other linux file systems. You can use ntfs as well if you want a journaled file system. Those days the linux ntfs driver was unreliable. What I did was to use another partition with ext3 (so I can have files above the 4g limit) but on every boot up I will chmod and chgrp the partition to set the proper permissions. Not really a "linux" solution, but works for me.

Offline

#9 2010-02-23 13:20:17

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: Disk Permissions

The 'proper' unix solution is to have a umask of 002 _and_ to have all the appropriate users in the _same_ group.
We've been doing this for years - and on unix before linux.
Then at some point, redhat (in all their corporate wisdom) decided that as per default, each user should have their own group.
Now where the heck is the sense of that?
Groups are there for the sharing!!

Obviously (I hope) this means that you use 'useradd' instead the (more or less) fancy gui's ...
Note that it is the main group that has to be the same ... just to add another group membership does not quite cut it.

Last edited by perbh (2010-02-23 13:23:06)

Offline

#10 2010-02-23 13:34:38

Surgat_
Member
Registered: 2007-08-08
Posts: 317

Re: Disk Permissions

Here in Arch, creating users with the adduser script creates them that way:

$  LANG=C id
uid=1000(quique) gid=100(users) groups=100(users),10(wheel),91(video),92(audio),93(optical),95(storage),98(power)

However, it is an interactive script (you launch it just 'adduser' and it prompts for every detail on the user creation) and cannot be used in scripts or so.

Offline

#11 2010-03-03 05:36:29

samdavid6
Member
Registered: 2008-09-18
Posts: 16

Re: Disk Permissions

Thanks guys for all the help, sorry I couldnt come here earlier.  I somehow managed to crash my disk and had to do a reinstall.

So I made my fstab like so:

UUID=215fca37-45aa-44e8-a15d-414180d5a17c /media/Storage ext4 defaults,umask=002,gid=homestore 0 1

umask=002 didnt work since I got an error saying

Unrecognized mount option "umask=002" or missing value

and if I remove that

Unrecognized mount option "gid=121" or missing value

Add to that I now find that apparently ext3 and ext4 do now support umask values. 

Please help..?

Offline

#12 2010-03-03 13:23:51

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: Disk Permissions

The 'umask'-values in this case is in each users .bashrc - at least _that_ was what I meant with a umask of 002
The 'umask,gid,uid'-entry in the mount-command is for ntfs only - since windows does not use the uid/gid combination
For any non-windows filesystem, you mount the drive on a directory with 'rwx'-access for everyone.

Also note that the different users should have the same 'gid' as their main group.

Last edited by perbh (2010-03-03 13:25:17)

Offline

#13 2010-03-04 13:31:53

tresende
Member
Registered: 2010-03-04
Posts: 1

Re: Disk Permissions

stryder wrote:

You can try to set the bash profile umask to 002 for everyone. You can try to make the group id of everybody common in /etc/passwd (I think). The default is username:username. This way whatever they save will have a common group and the group will have read/write privileges. BUT this will be so everywhere and not only on the partition you wish.

There's a way around this problem. If you leave the user's default group as username and run umask 002, you'll have group write permission everywhere, but the user will be the only one on that group. Then you can chgrp your mount point and  turn on the setgid bit so all files and dirs in there will have the common group, so everything will be writable by everyone on that partition, but not outside.

chgrp -R users /media/Storage
chmod -R g+s /media/Storage

Offline

#14 2010-03-04 13:51:59

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: Disk Permissions

There are two ways to do this:

1: Traditional unix groups

chgrp -R storage /media/Storage
find /media/Storage -type d -exec chmod g+s {} \;

This however relies on the users umask being 00X


Approach 2: unix acls
mount your fs with option acl and then do

find /media/Storage -type d -exec setfacl -m 'group:storage:rwx' {} \;
find /media/Storage -type f -exec setfacl -m 'group:storage:rw' {} \;
find /media/Storage -type d -exec setfacl -d -m 'group:storage:rwx' {} \;

The first to statements just set the current acls so that members of storage have rwx on dirs / rw on files
The third one makes those the default rules for all newly created files and folders

Regards,

raf

Offline

#15 2010-03-04 14:27:14

aion
Member
Registered: 2008-07-15
Posts: 12

Re: Disk Permissions

What about noacl mount option?

Offline

Board footer

Powered by FluxBB