Mount Windows Folder Sharing on RHEL 6/CentOS 6

-Mount Windows Folder Sharing (CIFS) on RHEL 6/CentOS 6.
-Set only Linux user >> user1 that have RWX access.
-Hide sharing credentials from other Linux users.
-Mount permanent at boot.

System: CentOS 6

1) Edit /etc/fstab
# vi /etc/fstab

2) Type mount command in fstab.
Note: By default windows share mounted with the full permission (777) in Linux. To change the default permission use the dir_mode and file_mode options to set directory and file permission.

//WIN_PC_IP/[share name] /[mount point] cifs _netdev,credentials=/root/.filepassw,password>,dir_mode=0755,file_mode=0755,uid=500,gid=500 0 0

in this scenario,only Linux user user1 have read write access on /winshare.

// /winshare cifs _netdev,credentials=/root/.winpasw,dir_mode=0700,file_mode=0700,uid=user1,gid=user1 0 0

3) Create folder sharing credential file.
# touch /root/.winpasw


4) Run mount command to /winshare
# mount -a

Test Result:

login as: user1
user1@'s password:
Last login: Sun Oct 31 11:09:45 2017 from
[user1@svrtest ~]$ cd /winshare/
[user1@svrtest winshare]$ mkdir okttest
[user1@svrtest winshare]$ ls
oke okttest folder test
[user1@svrtest winshare]$ su test
[test@svrtest winshare]$ ls
ls: cannot open directory .: Permission denied
[test@svrtest winshare]$ cd /
[test@svrtest /]$ cd /winshare/
bash: cd: /winshare/: Permission denied
[test@svrtest /]$

How to temporary mount Windows File sharing and moount to a directory
# mkdir /WinFolder
# mount -t cifs -o username=myusername,password=mypassword, // /WinFolder

How to umount and delete directory
# umount /WinFolder
# rm -rf /WinFolder

Leave a Reply

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