[global]
workgroup = SAMBA
security = user
username map = /etc/samba/smbusers
//添加此行内容
//创建一个共享目录wangqing
[root@Locathost ~]# mkdir /opt/ wangqing
[root@Localhost ~]# chown -R wangq ing. wangqing /opt/ wangqing/
[root@locathost ~]# Il /opt/
total 0
drwxr-xr-x.2 wangqing wangqing 15 Aug 4 15:05 wangqing
//配置共享
[root@locathost ~]# cat >> /etc/ samba/ smb. conf <<EOF
[wangqing]
comment = wangqing
path = /opt/wangqing
browseable = yes
guest ok = yes
writable = yes
write list = share
public = yes
EOF
[root@localhost ~]# tail -8 /etc/ samba/ smb . conf
[wangqing]
comment = wangqing
path = /opt/ wangqing
browseable = yes
guest ok = yes
writable = yes
write list = share
public = yes
//启动smb服务:
[root@locathost ~]# sys temctl start smb
//重启smb服务:
[root@localhost ~]# systemctl restant smb
//重新加载smb服务:
[root@locathost ~]# sys temctl reload smb
//设置s mb服务随系统启动而启动:
[root@localhost ~]# systemctl enable smb
//在客户机查看samba服务器有哪些共享资源
[root@Locathost ~]# smbclient -L 172.16.12.128 -U share
//将s amba服务器的共享资源wangqing挂载到客户机本地
[root@localhost ~]# mount -t cifs //172. 16.12.128/wangqing /opt/smb/ -0 username=share, password=redhat
[root@localhost ~]# df -h
//在客户机上进入共享目录创建新文件
[root@localhost smb]# ls
[root@localhost smb]# touch a
[root@localhost smb]# mkdir abc
[root@localhost smb]# ls
abc
//到服务器上验证
[root@locahost ~]# cd /opt/wangqing/
[root@LocaLhost wangqing]# Ls
abc
入
配置匿名共享:
//使用yum命令安装s amba服务器:
[root@localhost ~]# yum -y install samba-*
//在全局配置中添加如下内容:
[root@localhost ~]# vim /etc/ samba/ smb. confSee smb. conf. example for a more detailed config file or
read the smb. conf manpage.
Run ‘testparm‘ to verify the config is correct after
you modified it.
[global]
workgroup = SAMBA
security = user
map to guest = Bad User
//添加此行内容
//创建-个共享目录wangqing
[root@localhost ~]# mkdir /opt/wangqing
[root@localhost ~]# chmod 777 /opt/wangqing/
[root@localhost ~]# II /opt/
total 0
drwxrwxrwx.3 root root 26 Aug 4 15:17 wangqing
//配置共享
[root@localhost ~]# cat >> /etc/ samba/ smb.conf <<E0F
[wangqing]
comment = wangqing
path = /opt/ wangqing
browseable = yes
guest ok = yes
writable = yes
public = yes
EOF
[root@localhost ~]# tail -7 /etc/ samba/ smb. conf
[wangqing]
comment = wangqing
path = /opt/wangqing
browseable = yes
guest ok = yes
writable = yes
public = yes
//启动s mb服务:
[root@localhost ~]# systemctl start smb
//在客户机查看s amba服务器有哪些共享资源
[root@localhost ~]# smbclient -L 172.16.12.128 -U ‘Bad User‘
Enter SAMBA\root‘s password:
//这里直接敲回车键即可,不用输入密码
0S= [Windows 6.1] Server= [Samba 4.6.2]
//将s amba服务器的共享资源wangqing挂载到客户机本地
[root@localhost ~]# mount -t cifs //172. 16.12.128/wangqing /opt/smb/ -0 user
name= ‘ Bad User‘
[root@localhost ~]# df -h
//在客户机上进入共享目录创建新文件
[root@localhost smb]# Is
[root@localhost smb]# touch wanglaoji
[root@localhost smb]# mkdir jiaduobao
[root@localhost smb]# Is
j iaduobao wanglaoj i
//到服务器上验证
[root@localhost ~]# cd /opt/wangqing/
[root@localhost wangqing]# ls
j iaduobao wanglaoj i
原文:https://blog.51cto.com/14766460/2482281