参考以下设置即可
(1)更新当前软件。
sudo apt-get upgrade
sudo apt-get update
sudo apt-get dist-upgrade
(2)安装samba服务器。
sudo apt-get install samba samba-common
sudo apt-get install smbclient (客户端,可选)`
(3)创建一个用于分享的samba目录。
sudo mkdir /home/hello/share
注:/home/hello/share为自己需要共享的目录
(4)给创建的这个目录设置权限
sudo chmod 777 /home/hello/share
(5)添加用户
(下面的hello是我的用户名,之后会需要设置samba的密码)。
sudo smbpasswd -a hello
(6)配置samba的配置文件。
先保存现有的配置文件(可选)
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
sudo vim /etc/samba/smb.conf
在配置文件smb.conf的最后添加下面的内容:
[share]
comment = share folder
browseable = yes
path = /home/hello/share
create mask = 0700
directory mask = 0700
valid users = hello
force user = hello
force group = hello
public = yes
available = yes
writable = yes
在上面valid users = hello中的 hello为用户名。
(6.5)Ubuntu关闭防火墙
关闭
sudo ufw disable
查看防火墙状态
sudo ufw status
Ensure your Ubuntu firewall allows incoming access to Samba ports.
Ensure Windows firewall allows outgoing access for the same ports.
(7)重启samba服务器。
sudo service smbd restart
(8)Windows徽标+R 在弹出的运行窗口中输入 \ip 即可访问。
如\192.168.182.188,输入samba用户名及密码访问即可看到共享,然后就可以在Linux系统与Windows系统直接进行文件共享了
Win+R:在弹出的运行窗口中输入\ip(在ubuntu中用ifconfig查看ip)即可访问。
(9)输入samba用户名及密码访问即可看到共享文件夹share。