在Ubuntu20.04上安装samba服务,实现Linux与Windows文件共享。
apt install samba smbclient |
sambclient是客户端程序,用于在本机测试服务是否可用。
打开/etc/samba/smb.conf,增加以下配置:
[global] .... ntlm auth = yes [homes] comment = Home Directories browseable = no writable = yes public = yes guest ok = yes writable = yes printable = no create mode = 0644 directory mode = 0775 valid users = %S [share] path = /home/share writeable = yes browseable = yes guest ok = yes share modes = yes create mask = 7777 directory mask = 7777 |
共享了两个目录,一个是home目录,对应挂载路径为//主机名/用户名,另一个是/home/share目录,对应挂载路径为//主机名/share。
添加samba用户和密码:
sampasswd -a xxx |
启动samba服务:
/etc/init.d/samba-ad-dc restart |
本机测试samba是否共享成功:
smbclient -L //localhost/share smbclient -L //localhost/用户名 |
这里的//localhost/share就是前面smb.conf里的[share]的挂载路径。
在windows上挂载:
输入smbpasswd -a时指定的用户名和密码即可。