I've created a samba share on an ubuntu server (v22.04) called teslausb with the following lines specified in smbd.conf:

   comment = John's home share on Ubuntu
   path = /mnt/sdb1/teslausb
   browseable = yes
   writeable = yes
   valid users = john
   write list = john
   force user = john
   force group = john

john:john is the owner of /mnt/sdb1/teslausb and I've set permissions as chmod -R 755:

john@docker:/mnt/sdb1/teslausb$ ls -al
total 1600
drwxrwxr-x 2 john john    4096 Oct 18 14:17 .
drwxrwxr-x 4 john john    4096 Oct 18 02:38 ..
-rwxrwxr-x 1 john john    4096 Oct 18 03:20 ._10.11.12.11-netconsole.log
-rwxrwxr-x 1 john john 1608971 Oct 10 14:55
-rwxrwxr-x 1 john john    2653 Dec 13  2016 avrflash
-rwxrwxr-x 1 john john    4096 Oct 18 02:39 ._.DS_Store
-rwxrwxr-x 1 john john    6148 Oct 18 02:58 .DS_Store

When I connect to the share via Windows, there's no problems writing to the share, however, when I mount the share on an Ubuntu box using sudo mount -t cifs -o user=john //docker/teslausb /mnt/teslausb/, I can't write to the mounted share. I get a 'permission denied' error message.

For some strange reason, the mounted share also shows root as being the owner of the files in that share despite 'force user' being specified in the smbd.conf.

john@vm-ubuntu:/mnt/teslausb$ ls -al
total 1596
drwxr-xr-x 2 root root       0 Oct 18 14:17 .
drwxr-xr-x 6 root root    4096 Oct 18 12:25 ..
-rwxr-xr-x 1 root root    4096 Oct 18 03:20 ._10.11.12.11-netconsole.log
-rwxr-xr-x 1 root root 1608971 Oct 10 14:55
-rwxr-xr-x 1 root root    2653 Dec 13  2016 avrflash
-rwxr-xr-x 1 root root    4096 Oct 18 02:39 ._.DS_Store
-rwxr-xr-x 1 root root    6148 Oct 18 02:58 .DS_Store

If I mount the share and specify uid and gui in the mount command sudo mount -t cifs -o user=john,uid=john,gid=john //docker/teslausb /mnt/teslausb/ I can write to the samba share but I'm trying to avoid having to specify this in the mount command and thought that by using 'force user' this should achieve the same result.

I've also tried chmod -R 777 to the samba share but this didn't help.

I'm a little confused about how this should work. Why is this share being mounted with root as the user? Can someone please help me? Thanks in advance for any help, I really appreciate it.

  • Some necessary details are missing. What version of Ubuntu? About mid way down the question I see a command that includes the word docker. There is no mention of docker in the question. An answer is only as good and complete as the info given.
    – David
    Oct 18, 2022 at 8:05
  • @David Thanks for your comment. There's no docker commands in this question, the hostname of the server is 'docker'. I'm running Ubuntu 22.04 and I'll add the Ubuntu version to the question but I'm not sure if it makes a difference to the question?
    – gyrex
    Oct 18, 2022 at 12:39
  • May want to add that to the question. Very misleading choice of names.
    – David
    Oct 18, 2022 at 12:41

1 Answer 1


mount.cifs is a virtual filesystem that creates a "view" on the client machine of the SMB share with permissions unique to that client. To the server you are john (user=john) with all the permissions that john has on that server. The client however has it's own rules.

By default it will mount with owner=group=root with a mode of 755. But since it is a "view" you have control over how that "view" manifests itself on the client.

So a uid=john / gid=john will replace root as owner / group to you.

You can also change the mode. For example:


This will change permissions from 755 on the mount to 777 allowing everyone on the client to write to the share. Just remember that to the server all of these users will be "john".

  • Thanks for your answer. I've tried changing my smbd.conf file to: [teslausb] comment = TeslaUSB share path = /mnt/sdb1/teslausb browseable = yes writeable = yes force user = john create mask = 0777 directory mask = 0777 However, I'm still having the same issue. I can write files to the share if I use sudo but using my normal username I still get 'permission denied'...
    – gyrex
    Oct 18, 2022 at 13:00
  • Any changes you make for write-ability on the client have to be made on the client cifs mount statement: sudo mount -t cifs -o user=john,uid=john,gid=john,dir_mode=0777,file_mode=0666 //docker/teslausb /mnt/teslausb/
    – Morbius1
    Oct 18, 2022 at 17:42
  • Since dir_mode / file_mode will make it accessible to all users on the client you can omit the uid / gid parameters in the above cifs mount declaration.
    – Morbius1
    Oct 18, 2022 at 17:53

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.