文件内容
# See 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 = WORKGROUP
security = user
passdb backend = tdbsam
disable spoolss = yes
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes
[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = @printadmin root
force group = @printadmin
create mask = 0664
directory mask = 0775
[share]
comment = do not modify the share file
path = /home/share
public = No
writable = Yes
Linux操作
# 编辑文件
[root@localhost ~]# vi /etc/samba/smb.conf
# 启动服务
[root@localhost ~]# systemctl restart smb
[root@localhost ~]# systemctl restart nmb
# 设置共享源
[root@localhost ~]# cd /data
[root@localhost data]# ls
nfsfile share share1
[root@localhost data]# mkdir an
[root@localhost data]# ls -la
总用量 0
drwxr-xr-x. 6 root root 58 10月 13 11:03 .
dr-xr-xr-x. 19 root root 286 10月 10 14:53 ..
drwxr-xr-x 2 root root 6 10月 13 11:03 an #共享文件
drwxr-xr-x. 2 root root 6 10月 9 18:27 nfsfile
drw-rw-rw-. 3 root root 15 10月 11 11:42 share
drwxrwxrwx. 2 root root 20 10月 9 17:49 share1
# 创建用户
[root@localhost data]# pdbedit -a -u an
new password:
retype new password:
Unix username: an
NT username:
Account Flags: [U ]
User SID: S-1-5-21-3583617392-2483211555-2162720809-1000
Primary Group SID: S-1-5-21-3583617392-2483211555-2162720809-513
Full Name: an
Home Directory: \\localhost\an
HomeDir Drive:
Logon Script:
Profile Path: \\localhost\an\profile
Domain: LOCALHOST
Account desc:
Workstations:
Munged dial:
Logon time: 0
Logoff time: 三, 06 2月 2036 23:06:39 CST
Kickoff time: 三, 06 2月 2036 23:06:39 CST
Password last set: 五, 13 10月 2023 11:03:48 CST
Password can change: 五, 13 10月 2023 11:03:48 CST
Password must change: never
Last bad password : 0
Bad password count : 0
Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
#赋权限
[root@localhost data]# chmod 777 /data/an
[root@localhost data]# ls -ls
总用量 0
0 drwxrwxrwx 2 root root 6 10月 13 11:03 an
0 drwxr-xr-x. 2 root root 6 10月 9 18:27 nfsfile
0 drw-rw-rw-. 3 root root 15 10月 11 11:42 share
0 drwxrwxrwx. 2 root root 20 10月 9 17:49 share1
# 关闭防火墙
[root@localhost data]# systemctl stop firewalld.service
[root@localhost data]# setenforce 0
setenforce: SELinux is disabled
# 查看连接IP地址
[root@localhost data]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.85.113 netmask 255.255.255.0 broadcast 192.168.85.255
inet6 fe80::3d50:2820:f9dd:b8a0 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:57:40:60 txqueuelen 1000 (Ethernet)
RX packets 15088 bytes 12754052 (12.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2796 bytes 271033 (264.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 467 bytes 39556 (38.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 467 bytes 39556 (38.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:1b:ea:d3 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
---------------------------------
如果连接不上?
1. 修改Host 添加Linux IP等一系列
2. 配置:网络连接,这里是win下的Linux的网络配置(这个是在配置静态网络就搞定的,应该问题不是这里)
3.换成同一个工作组(win和Linux)
4. win中要打开SMB
5.参考已解决:Win10无法访问Samba共享文件夹_windows访问samba共享文件夹_Jyoung-Chen的博客-优快云博客
6.win10不能访问samba共享问题的解决_爱快 smb共享-优快云博客
7.参考:Windows访问CentOS搭建的Samba文件共享服务 · OdinXu的博客
使用wwsd