Score:2

No write permission on mounted CIFS drive

ni flag

I'm on a Linux machine trying to mount an SMB share inside a big network via my Active Directory username:

mount -t cifs -o username=myuser,domain=mydomain //server/share /mount/path

After the password + succesful mount I try touch /mount/path/test.txt, but I get permission denied. So many search results (this one is the biggest in terms of upvotes) suggest that because of using sudo mount the write permissions are only granted to root and not your normal user. But in my case, I am root because I use sudo -i first, everything happens on root console. /mount/path belongs to root and everything below it too (the content of the mounted drive). I've tried to solve this for 2 hours now but I'm so stuck. Does anyone know why I can not even write to the drive as root?

Score:3
cn flag

CIFS share will be mounted as root using your command, so normal user not able write anything there. You need to specify the user and group ID for whom you want to assign read/write permission. You can try with below command.

sudo mount -t cifs -o username=myuser,password=yourpassword,domain=mydomain,uid=yourUID,gid=yourGID,forceuid,forcegid //server/share /mount/path

Also you can use id command to get uid and gid automatically like below.

sudo mount -t cifs -o username=myuser,password=yourpassword,domain=mydomain,uid=$(id -u),gid=$(id -g),forceuid,forcegid //server/share /mount/path
R-obert avatar
ni flag
But why would I need to do that? I am root, I'm on the root console! Shouldn't I be able to write to the drive if everything on the mount point belongs to root?
Vaibhav Panmand avatar
cn flag
@R-obert did you cross check if your user is included in 'write list' of samba share
R-obert avatar
ni flag
I'm not using 'my' user! I use my user only to login and then I switch to ´sudo -i´. Or do you mean that root user? Is that 'write list' something on my Linux machine (/etc/sambda/smb.conf?) or on the machine that is providing the share (SMB server)? I feel like I need to read a tutorial about where my Linux user (root) comes into play and where my AD user comes into play which I'm using to connect the drive.
R-obert avatar
ni flag
I forgot to say that using your command from the answer also results in permission denied.
R-obert avatar
ni flag
Does the AD name and the Linux username have to be the same or something?
Vaibhav Panmand avatar
cn flag
@R-obert it not needed to be same, but the username you are using to mount drive must have write permission in samba server share configuration.
tsc_chazz avatar
vn flag
What Vaibhav is asking is that, since you have specified `username=myuser` in the mount command, have you verified that the Samba user `myuser@mydomain` has write permissions to the share `//server/share`?
R-obert avatar
ni flag
My username on the Linux machine is the same as my Active Directory account name. When I log into a Windows PC in our company via my AD account, I can attach the drive and write to it. So "myuser" must have the permission by the SMB server...
tsc_chazz avatar
vn flag
I'm sure you've looked in `/etc/fstab` to confirm that the CIFS mount is not defined there, or if it is, it's not defined as being readonly. If `//server` is a Windows machine, I have few other ideas.
R-obert avatar
ni flag
Yes, there's nothing ! I'm trying to mount it manually before I tell the system to mount it upon boot. I do not know the OS of the server unfortunately.
R-obert avatar
ni flag
I'm so sorry, my AD account seems to no longer have write permissions for the share. I do not know why that is no longer the case but I'm very sorry for having given wrong information here! I have just rechecked my write permission on a Windows PC just to make sure. Thank you for your help, I'll post again upon success.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.