0

I want to share folder for myself and another user with samba. I have created smb.conf like this:

[global]
        workgroup = WORKGROUP
        server role = standalone server
        map to guest = never
        usershare allow guests = no 
        hosts allow = 192.168.0.0/16
        hosts deny = 0.0.0.0/0

[movies-library-share]
        comment = share of movies in local network
        path = /media/user1/multimedia/video/movies-library
        browseable = yes
        writeable = yes
        valid users = user1,user2

user1 is me and I can access to this share and see everything and I can write so it works fine, but user2 can only log in, everything else is not accessible, even reading files. My question is how to make it readable and writable for user2? I assume that this could be related with permissions to access movies-library folder for user2. I'm not sure how should I assign proper permissions or group.

0

Your two users are by default in their own groups: user1:user1 and user2:user2.

The files are likely owned by user1:user1 with no access to 'other' users.

Solutions range from simplest to most robust:

  1. Pretend everyone is user1 by adding force user = user1 to the share.
    • user2 now has all the rights and permissions that user1 has.
  2. Pretend everyone is group user1 by adding force group = user1 to the share.
    • Same caveat as above but you can remove group write access with chmod g-w ...
  3. Grant EVERYONE read/execute access.
    • This including user2
    • Everyone on the system will have access to the files as they exist now, though not via samba.
    • Future additions will need this run each time.
    • chmod -R o+rx /media/user1/multimedia/video/movies-library
  4. Share group
    • Create a group that user1 and user2 are both members of and set ownership of the files to that group.
    • Add that group to both users.
    • Set the group ownership of the share to that group.
    • Make sure everything in that directory is group accessible.
    • SetGID on the directory so future additions inherit the group.
    • sudo groupadd media-share
      sudo usermod -a -G media-share user1
      sudo usermod -a -G media-share user2
      chown -R user1:media-share /media/user1/multimedia/video/movies-library
      chmod -R g+rx /media/user1/multimedia/video/movies-library
      chmod -R g+s /media/user1/multimedia/video/movies-library```
      
    • If you add files via samba then you can set the directory and file mask to ensure group permissions by adding create mask = 0750 and directory mask = 0770 to the share.
  • I chose option 1. and it works perfectly in this situation :) Thanks for making this guide I will use other options in future for sure. – s-kaczmarek May 22 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.