标签:samba 批量添加系统用户脚本 useradd script 共享
环境:
主机: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 # 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=0 Cur_Dir=$(pwd) for i in $(cat $Cur_Dir/user.line) do id $i >& /dev/null if [ $? -ne 0 ];then useradd -g 571 -M $i &>/dev/null echo $i"123" | passwd --stdin $i >& /dev/null let sum+=1 else echo " User $i already exists!" fi done echo "$sum users add++"
本文出自 “铜锣湾” 博客,请务必保留此出处http://wuhf2015.blog.51cto.com/8213008/1716480
标签:samba 批量添加系统用户脚本 useradd script 共享
原文地址:http://wuhf2015.blog.51cto.com/8213008/1716480