How to Change the Ownership of a CIFS Mount Point on Linux
When working with network-mounted storage on Linux, especially Azure Files or SMB/CIFS shares, administrators often notice something confusing: even after running chown, the mounted folder still shows as root:root.
This happens because CIFS mount points do not behave like normal local Linux filesystems such as ext4 or xfs. In most cases, ownership is controlled by the mount options, not by chown on the mounted directory.
This article explains why that happens and how to correctly change the ownership of a mounted CIFS share so it appears as a specific user, such as linuxadmin.
The Problem
Assume you have a mounted directory like this:
drwxrwx--- 2 root root 0 Feb 21 12:04 docs
You try to change it:
sudo chown linuxadmin:linuxadmin /azurefiles/docs
But when you check again, it still shows:
drwxrwx--- 2 root root 0 Feb 21 12:04 docs
That usually means the directory is a CIFS/SMB mount, and Linux is displaying ownership based on the mount settings.
Why chown Does Not Work
For local filesystems, chown updates filesystem metadata directly. But for CIFS mounts, ownership is often presented by the client according to how the share was mounted.
If the mount was created without uid and gid options, Linux commonly shows the owner as root:root.
So the correct fix is not to run chown on the mount point, but to mount the share with the correct user and group.
Step 1: Check the Current Mount
First, identify the mounted share and its mount options:
mount | grep /azurefiles/docs
Or review /etc/fstab:
cat /etc/fstab
You may see an entry like this:
//storageaccount.file.core.windows.net/docs /azurefiles/docs cifs credentials=/etc/smbcredentials/storageaccount.cred,vers=3.0,sec=ntlmssp,serverino,dir_mode=0770,file_mode=0660,nosharesock,_netdev 0 0
Notice that there is no uid= or gid= option.
Step 2: Find the UID and GID of the Target User
To assign ownership to a Linux user, first determine that user’s numeric UID and GID:
id linuxadmin
Example output:
uid=1000(linuxadmin) gid=1000(linuxadmin) groups=1000(linuxadmin)
In this case:
- UID =
1000 - GID =
1000
Step 3: Update /etc/fstab
Edit the CIFS mount entry and add the correct uid and gid values.
For example:
sudo vi /etc/fstab
Change the entry from:
//storageaccount.file.core.windows.net/docs /azurefiles/docs cifs credentials=/etc/smbcredentials/storageaccount.cred,vers=3.0,sec=ntlmssp,serverino,dir_mode=0770,file_mode=0660,nosharesock,_netdev 0 0
to:
//storageaccount.file.core.windows.net/docs /azurefiles/docs cifs credentials=/etc/smbcredentials/storageaccount.cred,vers=3.0,sec=ntlmssp,serverino,uid=1000,gid=1000,dir_mode=0770,file_mode=0660,nosharesock,_netdev 0 0
The important additions are:
uid=1000,gid=1000
This tells Linux to display the mounted files and folders as owned by linuxadmin.
Step 4: Remount the Share
After saving /etc/fstab, unmount and remount the share:
sudo umount /azurefiles/docs
sudo mount -a
If you only want to mount that single filesystem:
sudo mount /azurefiles/docs
Step 5: Verify the Result
Now check the directory again:
ls -ld /azurefiles/docs
You should now see something like:
drwxrwx--- 2 linuxadmin linuxadmin 0 Feb 21 12:04 /azurefiles/docs
That confirms the ownership display has changed successfully.
If the Unmount Fails Because the Directory Is Busy
Sometimes the share cannot be unmounted immediately because a process is using it. In that case, check what is holding the mount open:
sudo fuser -vm /azurefiles/docs
or:
sudo lsof +D /azurefiles/docs
Stop the relevant process, then try unmounting again.
Testing the Fix Before Changing /etc/fstab
If you want to test the new ownership settings before making them permanent, mount the share manually:
sudo umount /azurefiles/docs
sudo mount -t cifs //storageaccount.file.core.windows.net/docs /azurefiles/docs \
-o credentials=/etc/smbcredentials/storageaccount.cred,vers=3.0,sec=ntlmssp,serverino,uid=1000,gid=1000,dir_mode=0770,file_mode=0660,nosharesock,_netdev
Then verify:
ls -ld /azurefiles/docs
If the ownership appears correctly, update /etc/fstab with the same options.
Key Takeaway
If a mounted CIFS share shows as root:root, the solution is usually not chown. The real fix is to mount the share with the correct uid and gid.
In short:
chownworks normally on local Linux filesystems- CIFS mount ownership is typically controlled by mount options
- add
uid=andgid=in/etc/fstab - remount the share
- verify with
ls -ld
Example Final /etc/fstab Entry
//storageaccount.file.core.windows.net/docs /azurefiles/docs cifs credentials=/etc/smbcredentials/storageaccount.cred,vers=3.0,sec=ntlmssp,serverino,uid=1000,gid=1000,dir_mode=0770,file_mode=0660,nosharesock,_netdev 0 0
Conclusion
Changing ownership of a mount point on Linux depends on the filesystem type. For CIFS and Azure Files shares, ownership is usually controlled at mount time. Once you understand that, the fix becomes straightforward: set the correct uid and gid, remount, and confirm the result.
If you manage multiple shares such as docs, logs, or apps, apply the same pattern to each mount entry for consistent ownership and access control.

