# porpose: shareing file system between windows and linux using network
protocol:
smb(service message block): shareing linux file system to windows
cifs(common internet file system): shareing windows file system to linux
software for smb: samba
samba is using 137/udp, 138/udp, 139/tcp, 445/tcp
netbios: windows基于于主機實作互相通信的機制;
15個字元
samba:
nmbd: netbios
smbd: cifs
winbindd:
unc路徑:\\server\shared_name
互動式資料通路:
# smbclient -l host -u username
擷取到共享資訊之後,
# smbclint //server/shared_name -u username
基于挂載的方式通路:
mount -t cifs //server/shared_name /mount_point -o username=username,password=password
伺服器:
# yum -y install samba
服務腳本:
/etc/rc.d/init.d/nmb
/etc/rc.d/init.d/smb
主配置檔案:
/etc/samba/smb.conf
samba使用者:
賬号:都是系統使用者, /etc/passwd
密碼:samba服務自有密碼檔案,
将系統使用者添加為samba的指令:smbpasswd
smbpasswd:
-a sys_user: 添加系統使用者為samba使用者
-d :禁用
-e: 啟用
-x: 删除
配置檔案:
smb.conf
全局設定
特定共享的設定
私有家目錄
列印機共享
自定義共享
自定義共享:
[shared_name]
path = /path/to/share_directory
comment = comment string
guest ok = {yes|no}
public = {yes|no}
writable = {yes|no}
read only = {yes|no}
write list = +group_name
測試配置檔案是否有文法錯誤,以及顯示最終生效的配置:
# testparm
建立samba共享,共享目錄為/data,要求:
1)共享名為shared,工作組為magedu;
2)添加組develop,添加使用者gentoo,centos和ubuntu,其中gentoo和centos以develop為附加組,ubuntu不屬于develop組;密碼均為使用者名;
3)添加samba使用者gentoo,centos和ubuntu,密碼均為“mageedu”;
4)此samba共享shared僅允許develop組具有寫權限,其他使用者隻能以隻讀方式通路;
5)此samba共享服務僅允許來自于172.16.0.0/16網絡的主機通路;