在Ubuntu16.04下搭建samba,實現linux與windows之間的資源共享
阿新 • • 發佈:2018-12-10
轉載於http://www.linuxdiyf.com/linux/24260.html
1、開始需要我們做的是先在我們的ubuntu下安裝好samba:
安裝samba:sudo apt-get install samba
安裝smbclient:sudo apt-get install smbclient
2、修改配置檔案
vi /etc/samba/smb.conf 編輯smb.conf 檔案
在配置檔案的最末尾加上:
[share]
comment = Shared Folder require password
path = /home/share
public = yes
writable = yes
valid users = share
create mask = 0777
directory mask = 0777
force user = nobody
force group = nogroup
available = yes
browseable = yes
儲存後重新啟動samba:sudo /etc/init.d/samba restart
3、設定使用者和密碼
sudo smbpasswd -a share 接著俺提示輸入密碼。(前提是添加了此使用者:useradd share)
否則系統在沒有此使用者的前提下按預設操作是會報如下錯的:
增加samba使用者提示Failed to add entry for user
[email protected]:/home# smbpasswd -a share
New SMB password:
Retype new SMB password:
Failed to add entry for user share.
解決辦法:
這是因為沒有加相應的系統賬號,所以會提示Failed to add entry for user的錯誤,只需增加相應的系統賬號share就可以了:
[email protected]:/home# groupadd share -g 6000
[[email protected] :/home# useradd share -u 6000 -g 6000 -s /sbin/nologin -d /dev/null
4、最後計算機下右鍵新增一個網路位置
輸入 資料夾框 \\ip地址\share,按提示輸入使用者名稱密碼即可。
附加:
為了增加系統的安全性,該資料夾只想給share使用者有讀寫許可權即可!
[[email protected] ~]# chown -R share /home/share/
若不想讓另人訪問,只讓share使用者可以訪問,只需執行命令:
[ [email protected] ~]# chmod u+rwx,g+rwx,o-rwx /home/share