You are not logged in.
Hello.
It kinda makes me angry, that so basic situation needed in many families, where single pc is shared between multiple users, and I can't find easy and elegant solution on linux as long as I'm using it.
I have 2 users on same notebook, and I want to share single folder that both can easily and without restrictions access. Both should have permissions to add, rename and remove files and folders.
There is problem with default umask, users share same group, but newly created files and folders don't have write permission for group. Therefore file/folder created by user one can't be modified by user two.
Best solution I ever come upon was to run samba server on box and both users have mounted samba share where single user:group was forced. But various issues there.
How do you solve such a situation ? Any hits will be appreciated.
Offline
Well you can achieve this by simply chmod g+s (u+s [explore those options well before use]) ~/Public ( or ~/Pictures) and mount it with -o bind ( example /home/Public )
This is 1st thing comes in mind, there can be a lot better solutions but this will do thee trick. Good luck ![]()
O' rly ? Ya rly Oo
Offline
Well you can achieve this by simply chmod g+s (u+s [explore those options well before use]) ~/Public ( or ~/Pictures) and mount it with -o bind ( example /home/Public )
This is 1st thing comes in mind, there can be a lot better solutions but this will do thee trick. Good luck
Well, thank you for your quick reply. I tried some scenarios, but it's not working. So looks like I'm doing something wrong.
/home/user1/photos
/home/user2/photos
/home/share/photos
then
chmod g+s /home/share/photos
mount --bind /home/share/photos /home/user1/photos
mount --bind /home/share/photos /home/user2/photosDid I get you right ?
Offline
is your data ( pictures ) inside /home/share/photos ?
if so give us little info ( like ls -la /home/share/photos | head -n 5 )
as for binding you can use symlinks if it is your preference
Last edited by cybertorture (2011-09-30 22:11:16)
O' rly ? Ya rly Oo
Offline
is your data ( pictures ) inside /home/share/photos ?
if so give us little info ( like ls -la /home/share/photos | head -n 5 )
as for binding you can use symlinks if it is your preference
Easiest scheme would be photos are in home folder of user1 and user2 only has mount/symlink to folder, in his own home folder.
Example with symlinks and chmod g+s /home/kraken/photos:
kraken@gorgoroth ~ $ ls -la | grep photos
drwxrwsr-x 2 kraken users 4096 Oct 1 00:19 photos
kraken@gorgoroth ~/photos $ ls -la
total 8
drwxrwsr-x 2 kraken users 4096 Oct 1 00:19 .
drwxrwx--- 58 kraken users 4096 Oct 1 00:12 ..
-rw-r--r-- 1 kraken users 0 Oct 1 00:19 photo.jpg
kraken@gorgoroth /home/ivka $ ls -la | grep photos
lrwxrwxrwx 1 root root 16 Oct 1 00:18 photos -> ../kraken/photos
kraken@gorgoroth /home/ivka/photos $ ls -la
total 8
drwxrwsr-x 2 kraken users 4096 Oct 1 00:19 .
drwxrwx--- 58 kraken users 4096 Oct 1 00:12 ..
-rw-r--r-- 1 kraken users 0 Oct 1 00:19 photo.jpgThis does not work at all, file created in photos has no write for group, therefore only for reading for ivka user.
Example with mount --bind /home/kraken/photos /home/ivka/photos:
kraken@gorgoroth /home/ivka $ ls -l | grep photos
drwxrwsr-x 2 kraken users 4096 Oct 1 00:19 photosSame here.
Offline
There is one thing that I need to add:
- newly created file needs to have attributes, that both users can read/write
- also files copied/moved into that folder need to have same attributes, read/write for both users
Offline
This post http://www.linuxquestions.org/questions … te-782258/ deals exactly with my problem. So far 4th post is closest to what I need. All works nicely, but only for newly created files. When file is moved/copied to dest folder, it's permissions are not chaged. Therefore when file has missing write permission for group, it will break it's removal for the other user.
Offline
The following has been working fine for me for the last 30 minutes.
# mkdir /home/pictures ### Create the shared directory.
### Add a new group, 'ourshared', just for sharing the directory.
# groupadd ourshared
### Create an owner/administrator, 'shadmin', for the shared directory.
# useradd -d /home/pictures -g ourshared -m shadmin
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
# passwd shadmin
...
### Add existing users to the group,
# gpasswd -a casey ourshared ### Me
Adding user casey to group ourshared
### or add a new user.
# useradd -d /home/pictures -g ourshared -G GROUP1,GROUP2 -m usr2
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
# passwd usr2
...
### Set up the owner and group for the shared directory.
# chown -R shadmin.ourshared /home/pictures/
### Give the owner and group full permissions for the directory.
# chmod -R 770 /home/pictures/
### Forgot to set the sgid bit -
### all new files will now belong to the 'ourshared' group.
# chmod -R 2770 /home/pictures/With the default umask of 0022, only the owner of the file has write permissions.
$ umask 0022
$ > /home/ourshared/FILE1
$ ls -l /home/ourshared/
total 0
-rw-r--r-- 1 casey ourshared 0 Sep 30 22:16 FILE1You can change the umask, as a member of the 'ourshared' group, so that files in the /home/pictures directory will be writeable by the group members.
$ umask 0002
$ > /home/ourshared/FILE2
$ ls -l /home/ourshared/
total 0
-rw-r--r-- 1 casey ourshared 0 Sep 30 22:16 FILE1
-rw-rw-r-- 1 casey ourshared 0 Sep 30 22:22 FILE2You can use the wiki to read more on umask and how to set it globally.
Last edited by thisoldman (2011-10-01 02:37:30)
Offline
Invariably I find that the most effective solution is to use a partition that is formatted in vfat or ntfs. This is because those file systems have no permission bits. I may be wrong as I have not done this more recently but the problem with bash umask is that it works when you are using bash but programs writing to the folder seem to follow their own rules.
Last edited by stryder (2011-10-01 04:19:46)
Offline
i think samba can fit the bill here (a bit overkill but transparent when working correctly.).
a) SETTING UP SAMBA
- create the shared folder with permissions where one of the users can rw in it (this will be the samba user too)
- use smbpasswd to add a samba password to the user. (you need the samba daemon running).
- add a samba share with sufficient permissions for that user (man smb.conf)
example:
[pictures]
comment = john and mary's pcitures
writable = yes
path = /home/john/shared_pictures
create mask = 0664
directory mask = 0775b) create 2 different mount points in both users's home where they need it.
example fstab line:
//myhost/pictures /home/john/Pictures cifs user=john,uid=john,gid=users,passwd=not_so_secret_password,iocharset=utf8 0 0
//myhost/pictures /home/mary/Pictures cifs user=john,uid=mary,gid=users,passwd=not_so_secret_password,iocharset=utf8 0 0with this, you will achieve:
one fisical mount point. everything written to the smb shares will have the same owner / group rw permissions in the filesystem
both users will see the same folder, but with THEIR ownership / group, when they write to the folder...the actual ownership is the one of the samba user used to mount the filesystem.
PLEASE use the samba man page to see what your options are. this is JUST AN EXAMPLE. it will work, but you might open the share to everyone!
i hope it helps
Last edited by eldragon (2011-10-01 14:31:50)
Offline