签到成功

知道了

CNDBA社区CNDBA社区

How to mount Windows share on Red Hat Enterprise Linux system using CIFS?

2022-01-10 22:14 1214 0 原创 Linux
作者: hbhe0316

Environment
Red Hat Enterprise Linux 8
Red Hat Enterprise Linux 7
Red Hat Enterprise Linux 6
Red Hat Enterprise Linux 5

Issue
How can Windows shares be mounted on Red Hat Enterprise Linux?
Resolution
To run the following commands, you need to install cifs-utils package which provides mount.cifs helper program. Some commands for mounting CIFS volume require the helper program to pre-process options before issuing a mount() syscall.
Windows share can be mounted on RHEL system using cifs option of mount command as :http://www.cndba.cn/hbhe0316/article/106556

Rawhttp://www.cndba.cn/hbhe0316/article/106556

# mount -t cifs -o username=<share user>,password=<share password> //WIN_PC_IP/<share name> /mnt

You can specify iocharset to convert local path names to/from UTF-8 if the server uses multi byte charset:http://www.cndba.cn/hbhe0316/article/106556

Raw

http://www.cndba.cn/hbhe0316/article/106556

# mount -t cifs -o iocharset=cp932,username=<share user>,password=<share password> //WIN_PC_IP/<share name> /mnt

In case your user is in windows domain then you can define the domain as follows:

Raw

# mount -t cifs -o username=<share user>,password=<share password>,domain=example.com //WIN_PC_IP/<share name> /mnt

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.

Raw

# mount -t cifs -o username=<share user>,password=<sharepassword>,dir_mode=0755,file_mode=0755 //WIN_PC_IP/<share name> /mnt

To make the mount persistent across reboots, make the below entry to the /etc/fstabhttp://www.cndba.cn/hbhe0316/article/106556

http://www.cndba.cn/hbhe0316/article/106556

Rawhttp://www.cndba.cn/hbhe0316/article/106556

//WIN_PC_IP/<share name>    /<mntpoint>   cifs  _netdev,username=<share user>,password=<share password>,dir_mode=0755,file_mode=0755,uid=500,gid=500 0 0

If a username/password/domain is needed, it is best not to leave it in fstab. In order to achieve this, the previous entry can be modified like so:http://www.cndba.cn/hbhe0316/article/106556http://www.cndba.cn/hbhe0316/article/106556

Raw

//WIN_PC_IP/<share name>    /<mntpoint>   cifs  _netdev,credentials=/root/.credfile,dir_mode=0755,file_mode=0755,uid=500,gid=500 0 0

and then create the file /root/.credfile, with the following content (domain might not be mandatory):

Raw

username=<share user>
password=<share password>
domain=<share domain>

If you receive the following error when try to mount the share folder from windows machineshttp://www.cndba.cn/hbhe0316/article/106556

Raw
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
Please verify the permission on the folder on you windows machine and try again mount the share folder.

版权声明:本文为博主原创文章,未经博主允许不得转载。

LINUX

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
hbhe0316

hbhe0316

关注

1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。

  • 889
    原创
  • 1
    翻译
  • 13
    转载
  • 24
    评论
  • 访问:1142789次
  • 积分:1523
  • 等级:核心会员
  • 排名:第6名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ