Linux – No write permission on mounted CIFS drive

active-directorycifslinuxmountserver-message-block

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?

Best Answer

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