I mounted windows share to linux(rhel7) using

mount -t cifs -o username=<share user>,password=<share password> //WIN_PC_IP/<share name> /mnt

I successfully mounted it. From Linux I tried to change permissions on the mounted folder then it gave me the error.

chmod: changing permissions of ‘/mnt/’: Permission denied

chmod -R 777 /mnt

How can I change permissions of the mounted folder in Linux?

Is it possible to change permission on the mounted windows folder from Linux command(chmod)?


Is it possible to change permission on the mounted windows folder from Linux command(chmod)?

No. CIFS much like NTFS is a virtual filesystem so chmod has no affect. And changing the permission of the mount point before anything is mounted to it will have no affect either since the permissions after a mount always replace the permissions before the mount.

If the desired permissions is 777 change your mount command to include those permissions: dir_mode=0777,file_mode=0777. I would also get in the habit of adding the nounix option although for a Windows share it won't do much.

So try this instead:

mount -t cifs -o username=<share user>,password=<share password>,dir_mode=0777,file_mode=0777,nounix //WIN_PC_IP/<share name> /mnt

And I would agree that a better mount point would be something under /mnt rather than /mnt itself.

  • It I tries to change permissions on /mnt/ using chmod 777 /mnt it is giving error permission denied. But If I make new folder in /mnt say /mnt/share then If I tries to change permissions using chmod 777 /mnt/share It is not theowing any error but permissions were not getting changed. Why is this happening? – harish chava Dec 27 '18 at 13:34
  • /mnt Which I mentioned in the question is in /home/mnt not directly /mnt. – harish chava Dec 27 '18 at 13:42
  • @Morbius1 What does , do? I can't find dir_mode or file_mode or nounix in manual pages of mount – Shayan Oct 15 '19 at 15:47
  • Ohhhh... I should separate the options with ,. I found it in man mount.cifs. I first had to find which manpage, man -K file_mode worked nicely. – Shayan Oct 15 '19 at 16:09
  • i just added dir_mode=0777,file_mode=0777 as instructed and my mount folder is now writable. [+1] – kapitan Aug 12 '20 at 8:20

Firstly, only root (by default) may change permissions to the /mnt directory itself since it's owned by root:root - so attempting to modify it's permissions will fail as non-root.

You likely want to make this easier on yourself by creating a subdirectory inside /mnt, changing it's permissions, then mounting there.

First unmount anything already:

sudo umount /mnt

Next create a subdirectory where you will mount the share

sudo mkdir /mnt/share

Now change the permissions to be owned by the user you want to modify it:

sudo chown foo:foo /mnt/share

Where foo:foo is for the user foo, which should be your username.

Lastly mount to the /mnt/share location instead:

sudo mount -t cifs -o username=xxx,password=xxx //WIN_PC_IP/<share name> /mnt/share

If you still have problems with the files inside /mnt/share not being owned by the correct user you might need to specify the uid=xxx,gid=xxx in the mount options.

  • I am trying to change permissions using the root user only – harish chava Dec 27 '18 at 13:29
  • @what's xxx in uid and gid? – Shayan Oct 15 '19 at 15:52
  • 1
    Ohhh it's user id and group id. id -u and id -g. works nicely – Shayan Oct 15 '19 at 16:22
  • You can just use set the uid and gid to the actual name of the user and group respectively, you don't have to manually resolve this to a number. It's not 1978. – Evan Carroll Oct 20 '20 at 2:28

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