安装samba
#!/bin/bash #SAMBA install script #Create by wellpan #20110109 password=88888888 yum install samba -y #rpm -qa | grep samba #samba-common-3.0.33-3.29.el5_5.1 #samba-client-3.0.33-3.29.el5_5.1 #samba-3.0.33-3.29.el5_5.1 groupadd marking useradd -s/sbin/nologin -g marking tom (echo $password ; echo $password) | smbpasswd -s -a tom; #设置密码 groupadd sales useradd -s/sbin/nologin -g sales wellpan (echo $password ; echo $password) | smbpasswd -s -a wellpan; groupadd it useradd -s/sbin/nologin -g it jake (echo $password ; echo $password) | smbpasswd -s -a jake; mkdir -p /home/shichangbu chgrp -R marking /home/shichangbu chmod 770 /home/shichangbu mkdir -p /home/xiaoshoubu chgrp -R sales /home/xiaoshoubu chmod 770 /home/xiaoshoubu mkdir -p /home/xinxijisbu chgrp -R it /home/xinxijisbu chmod 770 /home/xinxijisbu #用户能访问目录的最终权限是被文件目录的权限和samba权限的最小权限交集所控制 cd /etc/samba mv smb.conf smb.conf.bak grep -v "#" smb.conf.bak > smb.conf #显示去掉前面“#”说明,并显示文件的内容重定向导到当前目录的smb.conf文件中
smb.conf配置内容
#======================= Global Settings ===================================== [global] workgroup = MDBQ netbios name = MDBQ server string = This is MDBQ samba server #-----------------------languages Setting----------------------------------- unix charset = utf8 display charset = utf8 dos charset = utf8
# --------------------------- Logging Options ----------------------------- log file = /var/log/samba/%m.log max log size = 50
security = user passdb backend = tdbsam
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 dns proxy = no template shell = /bin/false winbind use default domain = no
#============================ Share Definitions ============================== [shichangbu] comment = shichangbu path = /home/shichangbu public = no #禁止匿名访问 browseable = yes vaild users = @marking write list = @marking create mask = 0770 directory mask = 0770
[xiaoshoubu] comment = xiaoshoubu path = /home/xiaoshoubu public = no browseable = yes vaild users = @sales write list = @sales create mask = 0770 directory mask = 0770
[ITbu] comment = ITbu path = /home/ITbu public = no browseable = yes vaild users = @it write list = @it create mask = 0770 directory mask = 0770
[public] comment = publice path = /home/public public = no browseable = yes #表示不隐藏该目录 vaild users = @it @sales @marking write list = @it create mask = 0775 directory mask = 0775
测试配置文件testparm 使用smbstatus观察samba的状态