1

I have a windows machine locally connected to my linux machine. There is a shared folder on the windows machine, which I mounted on my linux machine using sudo mount -t cifs -o username=myuser //xxx.xxx.xx.xx/myfolder /mnt/windowsshare/ and it's mounted successfully and I can see the files and folders.

The problem now is that I'm trying to create a folder inside the mounted share but I can't. I've checked the permissions of the mounted folder and it says

"You are not the owner, so you cannot change these permissions"

as shown below:

enter image description here

I've tried running sudo chmod -R 777 /mnt/windowshare and sudo chown -R isa /mnt/windowshare but it says chmod:

changing permissions of '/mnt/windowshare/.?00000002202011111110e5(and many other chars)': No such file or directory

then I stop the command using ctrl+c

Any advice how I can have control access over this folder on my linux machine?

  • can you create a file on the share with root ? – D'Arcy Nader Apr 9 '18 at 10:37
  • @D'ArcyNader How I can do that? – Tak Apr 9 '18 at 10:37
  • use this command sudo touch /mnt/windowshare/testfilename – D'Arcy Nader Apr 9 '18 at 10:40
  • @D'ArcyNader I just tested and yes, I can create a file on the share with root. But it's read only like everything in the shared folder. – Tak Apr 9 '18 at 10:56
  • i'm writing an answer for you. – D'Arcy Nader Apr 9 '18 at 10:56
1

It is not possible to change permissions on a windows share when it's already mounted, but it is possible to change them during the mount.

first unmount your share with:

sudo umount /mnt/windowshare/

then mount the share again with these new arguments:

sudo mount.cifs -o username=myuser,uid=youruser,gid=yourgroup //xxx.xxx.xx.xx/myfolder /mnt/windowsshare/

quoting from the mount.cifs man

uid=arg sets the uid that will own all files or directories on the mounted filesystem when the server does not provide ownership information. It may be specified as either a username or a numeric uid. When not specified, the default is uid 0. The mount.cifs helper must be at version 1.10 or higher to support specifying the uid in non-numeric form.

gid=arg sets the gid that will own all files or directories on the mounted filesystem when the server does not provide ownership information. It may be specified as either a groupname or a numeric gid. When not specified, the default is gid 0. The mount.cifs helper must be at version 1.10 or higher to support specifying the gid in non-numeric form.

link to the mount.cifs man

to find your user open a terminal and run this command:

whoami

to find your group run this command: ( in this case the right group will be the first from the left )

groups
  • Thanks for that. When I try do this sudo mount.cifs -o username=myuser,uid=youruser,gid=yourgroup //xxx.xxx.xx.xx/myfolder /mnt/windowsshare/ it asks for the password of the network share and then it works, but when I tried doing this sudo mount.cifs -o username=myuser,password=mypassword,uid=youruser,gid=yourgroup //xxx.xxx.xx.xx/myfolder /mnt/windowsshare/ by adding the password, it says permission denied, not sure why? Also when how I can make this permenant so that I don't have to rewrite the command every time I lose connection or restart the computer? – Tak May 2 '18 at 9:35
  • hi @Tak i'm at work right now and i don't have time to help you. i'm sorry, perhaps if you open another question someone will help you faster than me. – D'Arcy Nader May 2 '18 at 11:03

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.