#查看防火墙和selinux是否关闭,没有关闭要关闭。
[root@weblamp ~]# iptables -nLChain INPUT (policy ACCEPT)target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destinationChain OUTPUT (policy ACCEPT)
target prot opt source destination [root@weblamp ~]# getenforceDisabled#安装smaba
yum install samba samba-client samba-swat -y#查看安装的包
[root@weblamp ~]# rpm -qa|grep sambasamba-winbind-3.6.23-45.el6_9.x86_64samba-winbind-clients-3.6.23-45.el6_9.x86_64samba-client-3.6.23-45.el6_9.x86_64samba-3.6.23-45.el6_9.x86_64samba-common-3.6.23-45.el6_9.x86_64samba-swat-3.6.23-45.el6_9.x86_64#启动并查看samba运行状态
[root@weblamp ~]# service smb startStarting SMB services: [ OK ][root@weblamp ~]# service smb statussmbd (pid 5349) is running...#重新加载(如果修改了配置文件)
[root@weblamp ~]#service smb reload#新建文件夹
[root@weblamp ~]# mkdir /company -p[root@weblamp ~]# cd /company/[root@weblamp company]# lltotal 0[root@weblamp company]# mkdir DSCS FLCG FM GYL HR KA SHARE TS WPCG ZMCS[root@weblamp company]# lltotal 40drwxr-xr-x 2 root root 4096 Dec 21 14:45 DSCSdrwxr-xr-x 2 root root 4096 Dec 21 14:45 FLCGdrwxr-xr-x 2 root root 4096 Dec 21 14:45 FMdrwxr-xr-x 2 root root 4096 Dec 21 14:45 GYLdrwxr-xr-x 2 root root 4096 Dec 21 14:45 HRdrwxr-xr-x 2 root root 4096 Dec 21 14:45 KAdrwxr-xr-x 2 root root 4096 Dec 21 14:45 SHAREdrwxr-xr-x 2 root root 4096 Dec 21 14:45 TSdrwxr-xr-x 2 root root 4096 Dec 21 14:45 WPCGdrwxr-xr-x 2 root root 4096 Dec 21 14:45 ZMCS#创建共享目录
[root@weblamp company]# cd SHARE/[root@weblamp SHARE]# lltotal 0[root@weblamp SHARE]# mkdir DSCS FLCG FM GYL HR KA TOOLS TS WPCG ZMCS[root@weblamp SHARE]# lltotal 40drwxr-xr-x 2 root root 4096 Dec 21 15:15 DSCSdrwxr-xr-x 2 root root 4096 Dec 21 15:15 FLCGdrwxr-xr-x 2 root root 4096 Dec 21 15:15 FMdrwxr-xr-x 2 root root 4096 Dec 21 15:15 GYLdrwxr-xr-x 2 root root 4096 Dec 21 15:15 HRdrwxr-xr-x 2 root root 4096 Dec 21 15:15 KAdrwxr-xr-x 2 root root 4096 Dec 21 15:15 TOOLSdrwxr-xr-x 2 root root 4096 Dec 21 15:15 TSdrwxr-xr-x 2 root root 4096 Dec 21 15:15 WPCGdrwxr-xr-x 2 root root 4096 Dec 21 15:15 ZMCS[root@weblamp SHARE]# cd ..#创建用户
[root@weblamp company]# useradd -s /sbin/nologin zmcsadmin[root@weblamp company]# useradd -g zmcsadmin -s /sbin/nologin zmcsuser[root@weblamp company]# useradd -s /sbin/nologin hradmin[root@weblamp company]# useradd -g hradmin -s /sbin/nologin hruser[root@weblamp company]# useradd -s /sbin/nologin fmadmin[root@weblamp company]# useradd -g fmadmin -s /sbin/nologin fmuser[root@weblamp company]# useradd -s /sbin/nologin dscsadmin[root@weblamp company]# useradd -g dscsadmin -s /sbin/nologin dscsuser[root@weblamp company]# useradd -s /sbin/nologin tsadmin[root@weblamp company]# useradd -g tsadmin -s /sbin/nologin tsuser[root@weblamp company]# useradd -s /sbin/nologin flcgadmin[root@weblamp company]# useradd -g flcgadmin -s /sbin/nologin flcguser[root@weblamp company]# useradd -s /sbin/nologin kaadmin[root@weblamp company]# useradd -g kaadmin -s /sbin/nologin kauser[root@weblamp company]# useradd -s /sbin/nologin gyladmin[root@weblamp company]# useradd -g gyladmin -s /sbin/nologin gyluser[root@weblamp company]# useradd -s /sbin/nologin wpcgadmin[root@weblamp company]# useradd -g wpcgadmin -s /sbin/nologin wpcguser[root@weblamp company]# useradd -s /sbin/nologin administrator#添加虚拟用户的登录密码
[root@weblamp company]# smbpasswd -a zmcsadminNew SMB password:(123)Retype new SMB password:Added user zmcsadmin.[root@weblamp company]# smbpasswd -a zmcsuserNew SMB password:(321)Retype new SMB password:Added user zmcsuser.#其他在依次添加
#设置管理员密码
[root@weblamp company]# smbpasswd -a administratorNew SMB password:(设置密码:12345....)Retype new SMB password:Added user admin.#设置目录属组
[root@weblamp company]# chown zmcsadmin.zmcsadmin ZMCS[root@weblamp company]# chown hradmin.hradmin HR && chown fmadmin.fmadmin FM && chown dscsadmin.dscsadmin DSCS[root@weblamp company]# chown flcgadmin.flcgadmin FLCG && chown gyladmin.gyladmin GYL && chown kaadmin.kaadmin KA[root@weblamp company]# chown tsadmin.tsadmin TS && chown wpcgadmin.wpcgadmin WPCG && chown administrator.administrator SHARE[root@weblamp company]# lltotal 40drwxr-xr-x 2 dscsadmin dscsadmin 4096 Dec 21 14:45 DSCSdrwxr-xr-x 2 flcgadmin flcgadmin 4096 Dec 21 14:45 FLCGdrwxr-xr-x 2 fmadmin fmadmin 4096 Dec 21 14:45 FMdrwxr-xr-x 2 gyladmin gyladmin 4096 Dec 21 14:45 GYLdrwxr-xr-x 2 hradmin hradmin 4096 Dec 21 14:45 HRdrwxr-xr-x 2 kaadmin kaadmin 4096 Dec 21 14:45 KAdrwxr-xr-x 12 admin admin 4096 Dec 21 15:16 SHAREdrwxr-xr-x 2 tsadmin tsadmin 4096 Dec 21 14:45 TSdrwxr-xr-x 2 wpcgadmin wpcgadmin 4096 Dec 21 14:45 WPCGdrwxr-xr-x 2 zmcsadmin zmcsadmin 4096 Dec 21 14:45 ZMCS#修改目录权限
[root@weblamp company]# chmod 1770 DSCS FLCG FM GYL HR KA TS WPCG ZMCS[root@weblamp company]# chmod -R 0775 SHARE/[root@weblamp company]# lltotal 40drwxrwx--T 2 dscsadmin dscsadmin 4096 Dec 21 14:45 DSCSdrwxrwx--T 2 flcgadmin flcgadmin 4096 Dec 21 14:45 FLCGdrwxrwx--T 2 fmadmin fmadmin 4096 Dec 21 14:45 FMdrwxrwx--T 2 gyladmin gyladmin 4096 Dec 21 14:45 GYLdrwxrwx--T 2 hradmin hradmin 4096 Dec 21 14:45 HRdrwxrwx--T 2 kaadmin kaadmin 4096 Dec 21 14:45 KAdrwxrwxr-x 12 admin admin 4096 Dec 21 15:16 SHAREdrwxrwx--T 2 tsadmin tsadmin 4096 Dec 21 14:45 TSdrwxrwx--T 2 wpcgadmin wpcgadmin 4096 Dec 21 14:45 WPCGdrwxrwx--T 2 zmcsadmin zmcsadmin 4096 Dec 21 14:45 ZMCS-------------------------------------------------------------#设置共享目录属组[root@weblamp company]#cd SHARE[root@weblamp SHARE]# chown zmcsadmin.zmcsadmin ZMCS[root@weblamp SHARE]# chown hradmin.hradmin HR && chown fmadmin.fmadmin FM && chown dscsadmin.dscsadmin DSCS[root@weblamp SHARE]# chown flcgadmin.flcgadmin FLCG && chown gyladmin.gyladmin GYL && chown kaadmin.kaadmin KA[root@weblamp SHARE]# chown tsadmin.tsadmin TS && chown wpcgadmin.wpcgadmin WPCG && chown administrator.administrator TOOLS[root@weblamp SHARE]# lltotal 40drwxr-xr-x 2 dscsadmin dscsadmin 4096 Dec 21 15:15 DSCSdrwxr-xr-x 2 flcgadmin flcgadmin 4096 Dec 21 15:15 FLCGdrwxr-xr-x 2 fmadmin fmadmin 4096 Dec 21 15:15 FMdrwxr-xr-x 2 gyladmin gyladmin 4096 Dec 21 15:15 GYLdrwxr-xr-x 2 hradmin hradmin 4096 Dec 21 15:15 HRdrwxr-xr-x 2 kaadmin kaadmin 4096 Dec 21 15:15 KAdrwxr-xr-x 2 admin admin 4096 Dec 21 15:15 TOOLSdrwxr-xr-x 2 tsadmin tsadmin 4096 Dec 21 15:15 TSdrwxr-xr-x 2 wpcgadmin wpcgadmin 4096 Dec 21 15:15 WPCGdrwxr-xr-x 2 zmcsadmin zmcsadmin 4096 Dec 21 15:15 ZMCS#修改共享目录权限
[root@weblamp SHARE]# chmod 1775 CGFL[root@weblamp SHARE]# chmod 0775 TOOLS[root@weblamp SHARE]# lltotal 40drwxrwxr-t 2 dscsadmin dscsadmin 4096 Dec 21 15:15 DSCSdrwxrwxr-t 2 flcgadmin flcgadmin 4096 Dec 21 15:15 FLCGdrwxrwxr-t 2 fmadmin fmadmin 4096 Dec 21 15:15 FMdrwxrwxr-t 2 gyladmin gyladmin 4096 Dec 21 15:15 GYLdrwxrwxr-t 2 hradmin hradmin 4096 Dec 21 15:15 HRdrwxrwxr-t 2 kaadmin kaadmin 4096 Dec 21 15:15 KAdrwxrwxr-x 2 admin admin 4096 Dec 21 15:15 TOOLSdrwxrwxr-t 2 tsadmin tsadmin 4096 Dec 21 15:15 TSdrwxrwxr-t 2 wpcgadmin wpcgadmin 4096 Dec 21 15:15 WPCGdrwxrwxr-t 2 zmcsadmin zmcsadmin 4096 Dec 21 15:15 ZMCS#修改samba的配置文件
[root@weblamp SHARE]# cd /etc/samba/[root@weblamp samba]# cp smb.conf smb.conf.ori[root@weblamp samba]# lltotal 32-rw-r--r-- 1 root root 20 Sep 21 18:38 lmhosts-rw-r--r-- 1 root root 9778 Sep 21 18:38 smb.conf-rw-r--r-- 1 root root 9778 Dec 21 15:59 smb.conf.ori-rw-r--r-- 1 root root 97 Sep 21 18:38 smbusers#最后编辑samba的配置文件,添加如下内容(部分实例)
[root@weblamp samba]#vim smb.conf[CGFL]
comment = This is a directory of DSCS. path =/company/ DSCS/ public = no admin users = dscsadmin valid users = @dscsadmin veto files = /*.mp3/*.mp4/*.rmvb/*.wma/*.exe/*.bat/*.dll/*.avi #不允许上传的文件后缀 writable = yes create mask = 0750 directory mask = 0750 [SHARE] comment = This is a share directory. path =/company/SHARE/ public = no valid users = administrator,@dscsadmin veto files = /*.mp3/*.mp4/*.rmvb/*.wma/*.bat/*.dll/*.avi writable = yes create mask = 0755 directory mask = 0755__________________________________________#修改配置文件后,重启samba[root@weblamp ~]# service smb reload#添加samba服务,开机自启动[root@weblamp ~]# chkconfig --level 2345 smb on[root@weblamp samba]# netstat -lntup |grep smb
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 5349/smbd tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 5349/smbd tcp 0 0 :::445 :::* LISTEN 5349/smbd tcp 0 0 :::139 :::* LISTEN 5349/smbd效果图如下: