Samba主要用于windows與Linux之間的文件共享,使用SMB/CIFS協議。CentOS 6默認安裝不包括samba軟件包,所以需要我們手動進行安裝。
Step 1 >> 安裝samba
[root@localhost ~]# yum install samba -y
Step 2 >> 創建一個共享用戶名和密碼
[root@localhost ~]# useradd shareuser -s /sbin/nologin
現在創建samba密碼用戶shareuser使用smbpasswd命令
[root@localhost ~]# smbpasswd -a shareuser
New SMB password:
Retype new SMB password:
Added user shareuser.
Step 3 >> 創建一個名為共享的文件夾的根目錄
[root@localhost ~]# mkdir /share
并且更改共享文件夾的所有權
[root@localhost /]# chown -R shareuser:root /share/
Step 4 >> 添加配置信息
[root@localhost /]# vim /etc/samba/smb.conf
在文件末行添加如下,保存退出。
[share]
comment = Share
path = /share
writable = yes
valid users = shareuser
Step 5 >> 啟動samba服務
[root@localhost /]# service smb start
Starting SMB services: [ OK ]
系統引導時自動啟動samba服務
[root@localhost /]# chkconfig –levels 235 smb on
Step 6 >> 檢查配置,使用 testparm
[root@localhost /]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[share]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
idmap config * : backend = tdb
cups options = raw[homes]
comment = Home Directories
read only = No
browseable = No[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
print ok = Yes
browseable = No[share] #看這
comment = Share
path = /share
valid users = shareuser
read only = No
Step 7 >> 關閉防火墻
[root@localhost /]# chkconfig –level 35 iptables off #永久性關閉
[root@localhost /]# /etc/init.d/iptables stop #普通關閉
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
Step 8 >> 關閉selinux
[root@localhost /]# vim /etc/selinux/config
編輯config文件,找到SELINUX行修改為:SELINUX=disable
[root@localhost ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
SELINUXTYPE=targeted
Step 9 >> 重啟系統
最后補上成果圖
原創文章,作者:黑白子,如若轉載,請注明出處:http://www.www58058.com/13126
寫的不錯。關于samba可以再從介紹些