此shell/ target=_blank class=infotextkey>shell脚本要求:
1,创建三个用户分别为:alins jim user1
2,配置samba服务,共享名为RHCA 路径为/share/rhca 在此目录下创建一个文件 权限为rwx
user1在此目录下创建文件 名称为ps1
3,当用户alins访问共享时 权限为只读
4,当用户为Jim访问共享时权限为读写且不可以删除user1创建的文件
5,执行前请保证有yum源
执行时,请给alins jim user1 统一设置密码为redhat执行脚本的时候会提示输入;
please input passwd for alins:
请输入:redhat
脚本如下:
#!/bin/bash
#Filename:samba.sh
ip=`ifconfig eth0 |grep 'inet addr' |linuxjishu/13830.html target=_blank class=infotextkey>awk -F '[ :]+' '{print $4}'`
useradd alins
useradd jim
useradd user1
mkdir /share/rhca -p
chmod 777 /share/rhca -R
setfacl -m u:alins:r-x /share/rhca/
chmod o+t /share/rhca -R
yum -y install samba samba-client
setenforce 0
echo "please input passwd for alins:"
smbpasswd -a alins
echo "please input passwd for jim:"
smbpasswd -a jim
echo "please input passwd for user1:s"
smbpasswd -a user1
echo "[RHCA]" >>/etc/samba/smb.conf
echo "path = /share/rhca" >>/etc/samba/smb.conf
echo "browseable = yes" >> /etc/samba/smb.conf
echo "writable = yes" >>/etc/samba/smb.conf
echo "write list = alins jim user1 " >>/etc/samba/smb.cof
service smb restart
echo "//$ip/RHCA /mnt cifs username=user1,password=redhat 0 0 " >>/etc/fstab
mount -a
touch /mnt/ps1
iptables -F