公司要在工作组company中添加一台Samba服务器作为文件服务器。 把需要公开的信息发布在一个名为public的共享目录/share中。 为实现集中管理,还要为公司各部门建立相应的目录。 比如销售部的资料存放在Samba服务器的/cmpdata/sales目录下,要求只允许销售部员工和总经理访问,并且只允许销售部经理对数据进行维护。

xxxxxxxxxxgroupadd salesxxxxxxxxxxuseradd -g sales saler_auseradd -g sales saler_b# 销售部经理useradd -g sales dm_${姓名}# 总经理useradd -G sales gm_${姓名}# 其他部门员工useradd testxxxxxxxxxxsmbpasswd -a saler_asmbpasswd -a saler_bsmbpasswd -a dm_${姓名}smbpasswd -a gm_${姓名}smbpasswd -a testtouchmkdir -pxxxxxxxxxxmkdir -p /samba/sharecd /samba/sharetouch shareFile.txtcd /sambamkdir -p ./cmpdata/salestouch salesData.txt/cmpdata/sales
ls -l 查看权限
修改目录权限:chown ${目录所有者}:${组名} ${目录名}
xxxxxxxxxx# 设置组外人员不能访问chmod 750 /samba/cmpdata/saleschown dm_${姓名}:sales /samba/cmpdata/salescd /samba/cmpdata/salestouch salesFile.txt完整的配置文件
service smb restartxxxxxxxxxx# /etc/samba/smb.conf[global] workgroup = MYGROUP server string = Samba Server security = user map to guest = bad user load printers = yes cups options = raw log file = /var/log/samba/%m.log max log size = 50 dns proxy = no
#============================ Share Definitions ==============================[homes] comment = Home Directories browseable = no writable = yes
[printers] comment = All Printers path = /usr/spool/samba browseable = no guest ok = no writable = no printable = yes
[public] path = /samba/share guest ok = yes writable = no printable = no
[sales] path = /samba/cmpdata/sales valid users = @sales write list = dm_${姓名} # 不能无登录访问 public = no printable = noLinux作为服务器,IP地址是192.168.${学号}.210,服务器上有一个目录/hello_${姓名},里面包含share_${姓名}文件。
实现/hello_${姓名}文件夹的只读共享,客户机分别是windows和Linux,给出过程和验证结果截图。
在Linux服务器上创建一个/home/samba目录,目录里有一个welcome_${姓名}文件。
只允许192.168.${学号}.8的主机去访问,只允许某组用户(组名为${姓名缩写})对其维护(读写),其他用户(如other)只能访问,不能写入。
给出过程和验证结果截图,包括能正常访问和访问被拒绝。客户机分别是windows和Linux,给出过程和验证结果截图。
xxxxxxxxxx# /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0ONBOOT=yesBOOTPROTO=noneHWADDR=00:0c:29:39:c8:08# 修改此行IPADDR=192.168.40.210GATEWAY=192.168.40.254
# 修改完后重启网卡service network restartxxxxxxxxxx# 添加用户组groupadd ${姓名缩写}
# 添加用户到用户组useradd -g ${姓名缩写} allowUser
# 无权限访问的用户useradd otherUser
# 添加 Samba 用户并设置密码smbpasswd -a allowUsersmbpasswd -a otherUsershown ${目录所有者}:${组名} ${目录名}chmod 770xxxxxxxxxx# 只读共享mkdir /hello_${姓名}touch /hello_${姓名}/share_${姓名}# 组内共享mkdir -p /home/sambatouch /home/samba/welcome_${姓名}chmod 775 /home/sambachown allowUser:nck /home/sambahosts allowservice smb restartxxxxxxxxxx# /etc/samba/smb.conf[global] workgroup = MYGROUP server string = Samba Server security = user map to guest = bad user load printers = yes cups options = raw log file = /var/log/samba/%m.log max log size = 50 dns proxy = no
#============================ Share Definitions ==============================[homes] comment = Home Directories browseable = no writable = yes
[printers] comment = All Printers path = /usr/spool/samba browseable = no guest ok = no writable = no printable = yes
[hello_${姓名}] path = /hello_${姓名} guest ok = yes writable = no printable = no
[home_samba] path = /home/samba public = no hosts deny = all hosts allow = 192.168.${学号}.8 write list = @${姓名缩写} printable = no公开只读的目录:hello_${姓名}
192.168.${学号}.8的组内用户才能读写的目录:home_samba
其他用户无法访问目录:home_samba

公开只读的目录:hello_${姓名}
192.168.${学号}.8的组内用户才能读写的目录:home_samba
IP不符合的用户无法访问目录:home_samba
