系统相关
首页 > 系统相关> > Linux-SAMBA实现指定目录共享

Linux-SAMBA实现指定目录共享

作者:互联网

实验环境

centos7   10.0.0.27   samba服务器

centos7    10.0.0.7    客户端

windows                    客户端

samba服务器

安装samba包

[root@centos7-liyj ~]#yum -y install samba

创建samba用户和组

[root@centos7-liyj ~]#groupadd -r admin
[root@centos7-liyj ~]#useradd -s /sbim/nologin -G admin jeck
[root@centos7-liyj ~]#smbpasswd -a jeck
New SMB password:                          #设置密码
Retype new SMB password:                   #再次确认密码
Added user jeck. 
[root@centos7-liyj ~]#sueradd -s /sbim/nologin tom
-bash: sueradd: command not found
[root@centos7-liyj ~]#smbpasswd -a tom
New SMB password:
Retype new SMB password:
Failed to add entry for user tom.

samba服务器配置

[root@centos7-liyj ~]#vim /etc/samba/smb.conf

配置文件最后添加以下内容

[www]
        path = /data/www
        write list = @admin

启动服务

[root@centos7-liyj /data/www]#systemctl enable --now smb nmb

 

客户端配置

安装samba客户端

[root@centos7-liyj ~]#yum -y install cifs-utils

创建挂载目录

[root@centos7-liyj ~]#mkdir /mnt/jeck

临时挂载

[root@centos7-liyj ~]#mount -o user=jeck,password=123456 //10.0.0.27/www   /mnt/jeck
[root@centos7-liyj ~]#df
Filesystem      1K-blocks    Used Available Use% Mounted on
devtmpfs          1002948       0   1002948   0% /dev
tmpfs             1013928       0   1013928   0% /dev/shm
tmpfs             1013928    9736   1004192   1% /run
tmpfs             1013928       0   1013928   0% /sys/fs/cgroup
/dev/sda2       104806400 3620844 101185556   4% /
/dev/sr0          9961428 9961428         0 100% /mnt/cdrom
/dev/sda3        52403200 2916224  49486976   6% /data
/dev/sda1          999320  133872    796636  15% /boot
tmpfs              202788       0    202788   0% /run/user/0
//10.0.0.27/www  52403200   33024  52370176   1% /mnt/jeck
[root@centos7-liyj ~]#cd /mnt/jeck/
[root@centos7-liyj /mnt/jeck]#ll
total 0
drwxr-xr-x 2 root root 0 May 28 14:49 linux

测试

客户端创建文件

[root@centos7-liyj /mnt/jeck]#touch f1.txt
[root@centos7-liyj /mnt/jeck]#echo 'hello jeck' > f1.txt 
[root@centos7-liyj /mnt/jeck]#cat  f1.txt 
hello jeck

 

 samba服务端

 

 

 

 

Windows访问  

 

 在Windows上创建文件夹

 

 samba服务

[root@centos7-liyj /data/www]#ll
total 0
drwxr-sr-x 2 jeck admin 6 May 28 14:49 linux

 

标签:SAMBA,mnt,centos7,samba,liyj,Linux,jeck,共享,root
来源: https://www.cnblogs.com/lyj1023/p/16320764.html