# 掛載安裝光碟作為 YUM 源(離線環境)
mount /dev/cdrom /media/
# 安裝 samba 核心套件與 SWAT 管理介面
yum install -y samba samba-client samba-common samba-swat
若提示缺少 perl(Convert::ASN1),YUM 會自動解決相依性。
service smb start
service nmb start
chkconfig smb on
chkconfig nmb on
CentOS 7+ 請改用 systemctl enable --now smb nmb。
Samba 使用者需先存在於系統帳號:
useradd -M -s /sbin/nologin oracle
smbpasswd -a oracle # 設定 Samba 專用密碼
/etc/samba/smb.conf[oracle_share]
comment = Oracle Project Share
path = /home/oracle/share
browseable = yes
writable = yes
valid users = oracle
create mask = 0664
directory mask = 0775
force group = oracle
修改後執行 testparm 驗證語法,再 service smb reload 重載配置。
# SELinux 允許 Samba 共享家目錄
setsebool -P samba_enable_home_dirs on
semanage fcontext -a -t samba_share_t "/home/oracle/share(/.*)?"
restorecon -Rv /home/oracle/share
# 防火牆開放 139/445 (SMB) 及 137/138 (NMB)
firewall-cmd --permanent --add-service=samba
firewall-cmd --reload
Win+R → \\IP\oracle_share → 輸入 oracle/密碼smbclient //IP/oracle_share -U oracle 或掛載 mount -t cifs //IP/oracle_share /mnt -o username=oraclechown -R oracle:oracle /home/oracle/share)、SELinux 標籤、smb.conf writable 設定。nmb 服務運行(負責 NetBIOS 名稱解析)、防火牆 UDP 137/138。xinetd 管理的 swat 服務,瀏覽 https://IP:901。