一、环境准备
1. 卸载原有samba
[root@localhost ~]# rpm -qa|grep samba
[root@localhost ~]# rpm -e —nodeps samba-x.x.x-10.el7_7.x86_64
2. 关闭selinux和防火墙
[root@localhost ~]# sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/sysconfig/selinux
[root@localhost ~]# sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/selinux/config
[root@localhost ~]# sestatus
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
二、安装samba
[root@localhost ~]# yum install -y samba
[root@localhost ~]# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
[root@localhost ~]# vim /etc/samba/smb.conf
[global]workgroup = SAMBAsecurity = userpassdb backend = tdbsamprinting = cupsprintcap name = cupsload printers = yescups options = raw[homes]comment = Home Directoriesvalid users = %S, %D%w%Sbrowseable = Noread only = Noinherit acls = Yes[printers]comment = All Printerspath = /var/tmpprintable = Yescreate mask = 0600browseable = No[print$]comment = Printer Driverspath = /var/lib/samba/driverswrite list = @printadmin rootforce group = @printadmincreate mask = 0664directory mask = 0775[tomcat]comment = tomcat logpath= /soft/apache-tomcat7-8089/logswritable = yespublic = no
[root@localhost ~]# useradd -d /soft/apache-tomcat7-8089/logs -s /sbin/nologin tomcat
(创建tomcat用户,指定其目录为/soft/apache-tomcat7-8089/logs,且不可登陆操作系统)
[root@localhost ~]# passwd tomcat
(给tomcat用户创建密码)
备注:
path= /soft/apache-tomcat7-8089/logs :共享目录的路径
writable = yes :用户可写权限,yes为可写
public = no 为匿名用户访问权限,no为不可访问
三、将创建的系统用户映射为samba用户
[root@localhost ~]# pdbedit -a -u tomcat
new password:
retype new password:
[root@localhost ~]# pdbedit -L (查看samba的所有用户)
四、启动samba
[root@localhost ~]# systemctl start smb
[root@localhost ~]# systemctl enable smb
[root@localhost ~]# systemctl status smb
五、测试
Windows电脑上输入:\10.6.5.112
六、补充
pdbedit 和smbpasswd 命令都可用户将系统用户映射为samba用户
1. pdbedit 命令
pdbedit -L :查看samba用户
pdbedit -a -u user:添加samba用户
pdbedit -r -u user:修改samba用户信息
pdbedit -x -u user:删除samba用户
2. smbpasswd 命令
smbpasswd -a user:添加一个samba用户
smbpasswd -d user:禁用一个samba用户
smbpasswd -e user:恢复一个samba用户
smbpasswd -x user:删除一个samba用户
