How To Change CIFS Share Mount Permissions Linux

I came across one requirement is to mount windows CIFS shares to Linux and this CIFS shares should have full access to local Linux user. In fact there is no mapping in between windows user and Linux user. Even Linux server is not integrated with Active Directory services. How To Change CIFS Share Mount Permissions Linux.

Change CIFS Share Mount Permissions Linux

Using below command you can mount CIFS Share to Linux but user should have write access to share.

# mount -t cifs -o username=arkitadmin "//TestServer/TestDir" /home/mountpoint

Permissions of mount point would be below

# ls -ld /home/mountpoint
drwxr-xr-x 1 root root 4096 Feb 26 00:50 /home/mountpoint

as shown above mount point can’t access writable to other users, root user can only write the data to it.

Oops something went wrong. I need to access mount point data using other Linux user even if i mount using root user. How.?

Using chown on a mounted CIFS share will not work. The command will execute successfully even after no ownership will change. Ownership can only be assigned at mount time. Be ready to UN-mount the share you wish to change ownership

# umount /home/moutpoint

Mount CIFS share again with proper UID and GID

# mount -t cifs -o username=arkitadmin,domain=arkit,dir_mode=0777,file_mode=0777,uid=920,gid=202 "//192.168.2.3/Testdir" /home/mountpoint
  • UserName = arkitadmin is windows admin user name
  • dir_mode = Directory permissions as 0777 (Full permissions)
  • file_mode = File Permissions as 0777 (Full Permissions)
  • uid = User Identification Number of Linux user (In this case my Linux UID is 920)
  • gid = Primary group id of Linux user
# ls -ld /home/mountpoint
drwxrwxrwx 1 ravik finance 4096 Feb 26 00:50 /home/mountpoint

After mount with uid and gid above is the results

Mount CIFS Share as Permanent

To mount CIFS share as permanent, we have to add entry into FSTAB file as mentioned below

//TestServer/Testdir /home/mountpoint cifs dir_mode=0777,file_mode=0777,uid=920,gid=202 0 0

That’s it. Now Linux user can write and data to CIFS share and same data can be accessed and writable to windows user.

Related Articles

User Branch Cache NetApp

Simple way to create Single user access Samba Share

Samba Share Multiple user access from Linux to windows

Read more

Thanks for your wonderful Support and Encouragement

Ravi Kumar Ankam

My Name is ARK. Expert in grasping any new technology, Interested in Sharing the knowledge. Learn more & Earn More

Leave a Reply

Your email address will not be published. Required fields are marked *