环境:
主机:192.168.1.82
版本:samba-Version 4.1.6
安装目录:/usr/local/samba/
配置文件:/usr/local/samba/etc/smb.conf
服务启动命令:/usr/local/samba/sbin/smbd -D
一次完整的samba账号添加过程:
1.添加系统用户
useradd -g 571 -M bailu ##571为www组的ID -M不创建用户家目录
2.添加samba账户
/usr/local/samba/bin/pdbedit -a bailu ##会提示输入密码两次 /usr/local/samba/bin/pdbedit -L ##查看用户
3.创建共享目录
mkdir -pv /home/www/server/selfTest/bailu chown www.www /home/www/server/selfTest/bailu
4.修改samba配置文件添加共享
[bailu] comment = bailu path = /home/www/server/selfTest/bailu browseable = yes writable = yes valid users = bailu,@www
5.重启服务端
pkill -9 smdb;/usr/local/samba/sbin/smbd -D
在win8的文件夹上方输入\\192.168.1.82\bailu 测试
全局配置文件:
[global] workgroup = MYGROUP server string = Samba Server netbios name = DavidSamba server role = standalone server log file = /var/log/samba/log.%m directory mask = 0775 force directorymode = 0775 directorysecurity mask = 0775 force directorysecurity mode = 0775 create mask = 0775 force createmode = 0775 security mask = 0775 force securitymode = 0775 # Scurity can be set to user, share(deprecated) or server(deprecated) security = user passdb backend = smbpasswd# dns proxy = no[homes] comment = Home Directories browseable = no writable = yes valid users = %S valid users = MYDOMAIN\%S[bailu] comment = bailu path = /home/www/server/selfTest/bailu browseable = yes writable = yes valid users = bailu,@www
批量添加系统用户的脚本
#!/bin/bash####smaba user add######默认添加密码为username123######用户名放在同级目录下的user.line文件中,每行一个用户###sum=0Cur_Dir=$(pwd)for i in $(cat $Cur_Dir/user.line) do id $i >& /dev/null if [ $? -ne 0 ];thenuseradd -g 571 -M $i &>/dev/nullecho $i"123" | passwd --stdin $i >& /dev/nulllet sum+=1 elseecho " User $i already exists!" fidoneecho "$sum users add++"
windows访问samba共享有很慢卡死的现象,可能是DNS解析的问题,在centos上修改hosts文件
# cat /etc/sysconfig/network NETWORKING=yesHOSTNAME=vmWeb2# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6# vim /etc/hosts127.0.0.1 vmWeb2::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
两条命令清理windows上的缓存
net use ##查看有没有网络缓存记录 net use * /del ##删除网络链接缓存