33

I want to create a Public folder that has full RW access. The problem with my configuration is that Windows users have no issues as guests (they can RW and Delete), my Ubuntu client can't do the same. We can only write and read, but not create or delete.

Here is the my smb.conf from my server:

[global]
    workgroup = WORKGROUP
    netbios name = FILESERVER
    server string = TurnKey FileServer

    os level = 20
    security = user
    map to guest = Bad Password
    passdb backend = tdbsam
    null passwords = yes

    admin users = root
    encrypt passwords = true
    obey pam restrictions = yes
    pam password change = yes
    unix password sync = yes
    passwd program = /usr/bin/passwd %u
    passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .

    add user script = /usr/sbin/useradd -m '%u' -g users -G users
    delete user script = /usr/sbin/userdel -r '%u'
    add group script = /usr/sbin/groupadd '%g'
    delete group script = /usr/sbin/groupdel '%g'
    add user to group script = /usr/sbin/usermod -G '%g' '%u'

    guest account = nobody

    syslog = 0
    log file = /var/log/samba/samba.log
    max log size = 1000

    wins support = yes
    dns proxy = no

    socket options = TCP_NODELAY
    panic action = /usr/share/samba/panic-action %d


[homes]
    comment = Home Directory
    browseable = no
    read only = no
    valid users = %S

[storage]
    create mask = 0777
    directory mask = 0777
    browseable = yes
    comment = Public Share
    writeable = yes
    public = yes
    path = /srv/storage

The following FSTAB entry doesn't yield full R/W access to the share.

//192.168.0.5/storage /media/myname/TK-Public/ cifs rw 0 0

This doesn't work either

//192.168.0.5/storage /media/myname/TK-Public/ cifs rw,guest,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm 0 0

Using the following location in Nemo/Nautilus w/o the Share being mounted does work:

smb://192.168.0.5/storage/

Extra info. I just noticed that if I copy a file to the share after mounting, my Ubuntu client immediately make "nobody" be the owner, and the group "no group" has read and write, with everyone else as read-only.

enter image description here

What am I doing wrong?

  • So, let me see: you can mount the share from your Ubuntu client (as root I assume given your fstab entries), you can then read and write, but you cannot delete or create? How come then that you can copy (for copying, creating a file is a must)? – January Jun 27 '13 at 5:23
56

Turns out that I need to add a local (client) UID to the mount line in FSTAB to make this work. I arrived at this via sheer brute force:

//192.168.0.5/storage /media/myname/TK-Public/ cifs guest,uid=myuser,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm 0 0
  • 3
    A common problem, and no answer at all... Amazing! – dan3 Nov 20 '13 at 10:39
  • Ohhh, just what I needed ... thanks a lot - looking for this for hours! – pkdkk Aug 22 '14 at 21:42
  • 1
    Another gotcha: Make sure cifs-utils is installed (for me it wasn't installed under 16.04 after installing "main" samba pkg). If you don't have it installed, you will get 'bad fs / bad option' error. – bshea Sep 24 '16 at 17:07
  • After I installed that I used perms in other answer and added: //10.20.30.40/share/mysharedir /mnt/mymountpoint cifs guest,uid=nobody,iocharset=utf8,noperm 0 0 to /etc/fstab then sudo mount -a. Seems to mount/write fine now. – bshea Sep 24 '16 at 17:29
  • For me, a slightly simpler version (without uid) worked to mount properly R/W for all users a public share from another linux machine: //server_name/share_name /media/local_mountpoint cifs guest,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm 0 0 – woohoo Feb 17 '18 at 18:02
6

CIFS does not generally have any concept of user and group, so mounting a cifs share will default to showing user and group as 'nobody':

drwxdrwxdrwx. 3 nobody nobody 0 Sep 29 09:00 .
drwxdrwxdrwx. 9 nobody nobody 0 Sep 29 09:00 ..

Since you are not 'nobody' Linux will not let you write to anything that doesn't have 0777 permission unless you use sudo. To fix this, add uid=mylogin,gid=mygroup to fstab and it will make the share appear as if it is your own directory:

drwxdrwxdrwx. 3 mylogin mygroup 0 Sep 29 09:00 .
drwxdrwxdrwx. 9 mylogin mygroup 0 Sep 29 09:00 ..

You now have full control without the need for sudo.

This not not actually changing anything on the server, since the server is not enforcing anything. It is telling Linux to pretend that you are the owner and give you unrestricted access.

  • 1
    Yes if using guest/nobody/etc. Make sure parent folders have full read/write/execute. I use this perm on some internal network shares - so it's not a security issue. Upvoted – bshea Sep 24 '16 at 17:35
  • But contrary to your post - I was able to use userid 'nobody' (for mounting) when it had correct options for mounting. See my other comments.. – bshea Sep 24 '16 at 17:39
  • This is a far better solution than setting extensive permissions for everyone on the mounted files. And it works. – j08lue Jan 29 '17 at 14:13
5

You are almost there. Open FSTAB by using:

sudo nano /etc/fstab

In the last line ( or on of the last lines) place:

//192.168.0.5/storage /media/myname/TK-Public/ cifs username=YOURUSERNAME,password=YOURPASSWORD,iocharset=utf8,file_mode=0777,dir_mode=0777

*** (this is all one long line)

Ctrl-X to close, Y to save and Enter to seal the deal.

Now reboot by:

sudo reboot

And you should have full control of the network share on your Linux device!

  • 1
    You might want to replace that password with an example password. – Spotlight Apr 27 '16 at 22:51
  • 9
    One doesn't need to reboot to mount fstab entries. Just mount <DEVICE> or mount <MOUNTPOINT> or even mount -a do the job just fine. – David Foerster Apr 27 '16 at 23:07
1

I had this problem and it was because the user of the share did not own it. I fixed it with "sudo chown {username}:{username} /{share}/{path}" after that I could move and delete files.

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.