1、 安裝samba軟體 (部分Ubuntu版本有自帶)
sudo apt-get install samba
sudo apt-get install smbclient
安裝完成後執行确認已經正确安裝完成, 使用指令:
samba -V
2、 配置samba伺服器,使用如下指令打開samba的配置檔案
sudo vi /etc/samba/smb.conf
在檔案最後添加如下配置資訊:
[share]
comment = share floder
browseable = yes
path = /home/hpf/share
create mask = 0777
directory mask = 0777
valid user = hpf
force user = nobody
force group = nogroup
public = yes
writable = yes
available = yes
browsable = yes
其中,
Path後需要加上自己想要共享的目錄(我在目錄下/home/hpf/下mkdir了share檔案夾)
valid user 自定義的samba使用者名
3、 通過如下指令來為samba添加此使用者并設定密碼
sudo smbpasswd -a hpf
4、 配置完成後需要重新開機samba伺服器,使用如下指令重新開機samba伺服器
sudo /etc/init.d/samba restart (service samba restart)
5、 接下來就可以在windows上通路samba伺服器了,通過 \+ ip 通路到共享檔案夾
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnLyEjN5QTM1kDMwEDOwkTMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
後面發現紮樣可以讀取檔案,但是不能進行寫入操作
是以還需第6步:
6、 去掉Ubuntu防火牆
① setenforce 0 (這隻是暫時去掉這個防火牆)
要永久去掉需要在/etc/selinux/config 檔案中将 SELINUX=enforcing改成 SELINUX=disabled
② iptables –F (同樣也隻是暫時去掉這個防火牆)
永久去掉執行 service iptables save 就可以将配置資訊寫入 /etc/sysconfig/iptables 配置檔案中。
最後完美完成, OK