Mount CIFS Permission Denied on Linux – Fixed!

I just spend way too much time figuring this out, no Tutorial mentions this. I show you how to fix the Mount CIFS Permission Denied error on Linux.

Mount CIFS Permission Denied Error

The error occurs mostly because you don’t provide sufficient credential information, specifically which Domain you are in. Most Tutorials out there only mention username and password when editing the .smbcredentials file. But let me take you through the process from the beginning.

Step 1 – Installing CIFS Utils

To mount a CIFS share on Linux, we first need to install cifs-utils. Let’s get started with that.

sudo apt-get install cifs-utils -y

It should probably be pre-installed in most distros anyway.

Step 2 – Creating a Mount Point

Next, we need to create the Directory where we want to Mount our Share in. You can later find the Share in this Directory. For this example, we will mount the imaginary “Photos” share.

sudo mkdir /media/share/Photos

Step 3 – Editing the fstab file

That we don’t have to mount our Share again after each reboot, we have to edit the fstab file to make the Share mount automatically after each reboot. But first, we make a Backup of this file in case something goes wrong.

sudo cp /etc/fstab /etc/fstab.old

That done, we edit our fstab file.

sudo gedit /etc/fstab

And paste this line at the end of the file (all in one line)

//YourServer/Photos /media/share/Photos/ cifs vers=2.0,credentials=/home/YourLinuxUsername/.smbcredentials,iocharset=utf8,gid=1000,uid=1000,file_mode=0777,dir_mode=0777 0 0

Of course, adjust accordingly to your own Server and YourLinuxUsername! We will create the .smbcredentials file next.

By Default, you will have the gid=1000 and uid=1000. That’s your Group & User ID, but to make sure that those values are the same in your System, double check it by typing:


mount cifs permission denied

If all is correct, hit CTRL+S to Save the fstab file and close it.

mount cifs permission denied

Step 4 – Creating the .smbcredentials file

We could enter our username directly into our fstab file, but that would not be safe as someone could clearly read our Username and Password in this unencrypted file. Therefore, we are going to create a separate file containing this information.

sudo gedit .smbcredentials

And here is the key point to fixing the Mount CIFS Permission Denied error. Most guides simply state to enter Username and Password into this file, but you also have to enter your Domain!

So paste this into your .smbcredentials file:


Save & Close the file.

Now we just make the .smbcredentials file so that only the root user can read its contents.

sudo chmod 600 ~/.smbcredentials

Step 5 – Mounting the Share

Now when everything is done, try to mount the share by typing

sudo mount -a

And your share should now be successfully mounted!  If there are still some errors, try rebooting your system and see again if the Share was mounted. The share should be located in your media/share/Photos folder.

Wrapping up

It took me a while to figure out this error. I use a Synology NAS and had to set vers=2.0 in the fstab file. If you still encounter Problems, try changing vers to 1.0 or 3.0. Let me know in the comments below if this solution worked for you!

3 thoughts on “Mount CIFS Permission Denied on Linux – Fixed!

  • July 7, 2020 at 11:13 pm

    Great article, I’m able to successfully create the mount and see files in the share, however; I am unable to create or write to the directory. Is there something else not included in the article which I need to configure?

  • November 3, 2019 at 10:26 am

    Thank you very much. this was solved my issue “mount error(13): permission denied” while running mount.cifs.

  • December 29, 2018 at 5:31 pm

    Good start/thinking about writing this. However 2 things: 1. when editing .smbcredidentials you should specify that it’s under ~ and 2. when mounting it asks for a root password. So even though your tutorial is nice it doesn’t work.


Tell us what you think!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: