I want to mount a Windows share using CIFS on my Ubuntu 17.04 machine. If I use the mount command below it works fine, and I can access the Windows share:

sudo mount -t cifs //servername/sharename /home/myuser/mediafolder -o credentials=/home/myuser/.smbcredentials,dir_mode=0777,file_mode=0777

If I attempt to make this permanent using the following entry in /etc/fstab I get a permissions error when I try to access the mount point at /home/myuser/mediafolder :

//servername/sharename /home/myuser/mediafolder cifs credentials=/home/myuser/.smbcredentials,gid=1000,uid=1000,iocharset=utf8,file_mode=0777,dir_mode=0 0 0

Why am I denied permissions with the 2nd approach?

  • just a thought - does root have read access to your credentials file (you're not logged in at boot; it'll be root that tries to mount the samba share & thus needs to read the credentials file)
    – guiverc
    Dec 1, 2017 at 11:02
  • probably a better guess.. don't mount to ~/mediafolder, but mount instead to /home/mediafolder and try it. (I forget where I read this; but as I recall there was a reason you couldn't mount to a home/user directory anymore documented in a samba updates years ago if my memory serves me)
    – guiverc
    Dec 1, 2017 at 11:04
  • Yes root does have access to my .smbcredentials file. I tried mounting to a /home/media/* folder instead but get the same error - "ls: cannot open directory '/home/Media/Videos': Permission denied"
    – Ian M
    Dec 1, 2017 at 11:31
  • did you sudo chmod a+rw /home/Media -R (or whatever permissions you want) before you tried to access it; as I'm assuming you created it with a 'sudo mkdir` & thus it'll be 'root' owned. Also I hope you didn't include a * in your mount point, nor a user directory; just a directory you created first (i used media as example instead of your mediafolder).
    – guiverc
    Dec 1, 2017 at 11:33
  • I used chmod -R 777. I use the same folder when mounting from the command line and don't get permissions issues, so I'm guessing there isn't a permissions issue with that folder?
    – Ian M
    Dec 1, 2017 at 12:16

1 Answer 1


I finally found the solution - this works in /etc/fstab:

//server/share /media/localdir cifs credentials=/home/myuser/.smbcredentials,,uid=1000,gid=1000 0 0

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.