Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have access to a cifs network drive. When I mount it under my OSX machine, I can read and write from and to it.

When I mount the drive in ubuntu, using:

sudo mount -t cifs -o username=${USER},password=${PASSWORD} //server-address/folder /mount/path/on/ubuntu

I am not able to write to the network drive, but I can read from it. I have checked the permissions and owner of the mount folder, they look like:

4.0K drwxr-xr-x  4 root root    0 Nov 12  2010 Mounted_folder

I cannot change the owner, because I get the error:

chown: changing ownership of `/Volumes/Mounted_folder': Not a directory

When I descend deeper into the network drive, and change the ownership there, I get the error that I have no permission to change the folder´s owner.

What should I do to activate my write permission?

share|improve this question
Is the file system listed in /etc/fstab? If so, what options does the entry have? – Jenny D Mar 15 '13 at 15:51
up vote 37 down vote accepted

You are mounting the CIFS share as root (because you used sudo), so you cannot write as normal user. If your Linux Distribution and its kernel are recent enough that you could mount the network share as a normal user (but under a folder that the user own), you will have the proper credentials to write file (e.g. mount the shared folder somewhere under your home directory, like for instance $HOME/netshare/. Obviously, you would need to create the folder before mounting it).

An alternative is to specify the user and group ID that the mounted network share should used, this would allow that particular user and potentially group to write to the share. Add the following options to your mount: uid=<user>,gid=<group> and replace <user> and <group> respectively by your own user and default group.

sudo mount -t cifs -o username=${USER},password=${PASSWORD},uid=<user>,gid=<group> //server-address/folder /mount/path/on/ubuntu
share|improve this answer
it worked for me! But we should add that if the shared folder is in a PC with a login domain you should add the option domain. Something like this: sudo mount -t cifs -o username=${USER},password=${PASSWORD},dom=${DOMAIN}, uid=<user>,gid=<group> //server-address/folder /mount/path/on/ubuntu In fact the domain can go in the "username" option, but remember that you have to use / instead of `, like username=DOMAIN/user.name`. – João Portela Dec 19 '14 at 9:17
Yes, that's correct. :-) One might need to specify the domain or workgroup (for older Windows version) via the "domain=" option or via the username, that's a good point. And sometimes it is even necessary to specify the encryption scheme or the CIFS version to be used. But all this was not part of this question, so I left it aside. :-) – Huygens Dec 20 '14 at 16:08
This is just what I needed. I had an entry in /etc/fstab to auto mount the network drive on startup. I could not write to the mount so I added ,uid=<myUserID> for a line that looks like this: // /colmustang cifs username=<uname>,password=<upassword>,uid=<myUserID> 0 0 – James May 22 '15 at 1:34
One question. Why do we specify user two times? First we have username=... and then uid=...? If I have created a new user like useradd -s/bin/bash -m -g users dijak on host, should I use gid=users? – 71GA Jan 12 at 9:04
@71GA username is the remote login to use for authentication. The uid is the local user ID you want to nap all files/folders. So the username is decoupled from the uid, the username is the remote user login while the uid is your local user id. Note that it could be the same thing if your server is Samba and you use an LDAP or other centralized account on both client and server :-). – Huygens Jan 12 at 12:51

The solution is effective, I tested the command succesfully:

sudo mount -t cifs -o username=miuser,password=patito,uid=1001,gid=1001 // /home/ususario/Documentos/benz-win
share|improve this answer
I am not sure if you the credentials you posted are genuine or not, but I strongly suggest to remove them from your post. – Vincent Aug 1 '13 at 23:32
Use "id -u <user>" and "id -g <user> to get the uid and gid respectively. – nvd Sep 16 '14 at 10:00
If the credentials are in the post then they are compromised. Deleting them now won't remove the history. – Stu Thompson Oct 15 '14 at 15:58
Credentials are compromised if somebody has access to private IP address – Dženan Aug 27 '15 at 15:29
And what is the added value of this answer compared with the accepted answer? Except you disclose your credentials (in case they are real). – ruffp Oct 21 '15 at 11:52

protected by Anthon Jan 21 at 10:22

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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