[root@localhost Desktop]# id leo 查看系统中有么有叫leo的用户
uid=1000(leo) gid=1000(leo) groups=1000(leo)
[root@localhost Desktop]# pdbedit -a -u leo 配置smb帐户数据库.用户名为leo
new password:自定义密码
retype new password:重复密码
Unix username:leo
NT username:
Account Flags:[U]
User SID:S-1-5-21-1592380922-1721486117-3131092003-1000
Primary Group SID:S-1-5-21-1592380922-1721486117-3131092003-513
Full Name:leo
Home Directory:\\localhost\leo
HomeDir Drive:
Logon Script:
Profile Path:\\localhost\leo\profile
Domain:LOCALHOST
Account desc:
Workstations:
Munged dial:
Logon time:0
Logoff time:Wed, 06 Feb 2036 23:06:39 CST
Kickoff time:Wed, 06 Feb 2036 23:06:39 CST
Password last set:Fri, 14 Dec 2018 14:50:53 CST
Password can change:Fri, 14 Dec 2018 14:50:53 CST
Password must change:never
Last bad password: 0
Bad password count: 0
Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF创建完成
[root@localhost Desktop]# mkdir /home/database 在/home目录下创建/database共享目录
[root@localhost Desktop]# chown -Rf leo:leo /home/database
将创建好的目录归入给leo用户使用
[root@localhost Desktop]# semanage fcontext -a -t samba_share_t /home/database 将目录定义为samba共享目录
[root@localhost Desktop]# restorecon -Rv /home/database/重启配置
unconfined_u:object_r:home_root_t:s0->unconfined_u:object_r:samba_share_t:s0
[root@localhost Desktop]# getsebool -a | grep samba 找出samba服务的selinux安全上下文
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
use_samba_home_dirs --> off
virt_sandbox_use_samba --> off
virt_use_samba --> off
[root@localhosDesktop]setsebool -P samba_enable_home_dirs=on
设置放行对应samba共享的安全上下文
lns'/usr/lib/systemd/system/smb.service''/etc/systemd/system/mu lti-user.target.wants/smb.service'
[root@localhost Desktop]# vim /etc/samba/smb.conf 配置samba主配置文件
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
log file = /var/log/samba/log.%m
max log size = 50
security = user
passdb backend = tdbsam
load printers = yes
cups options = raw
添加下列配置
[database]
comment = Do not arbitrarily modify the database file
path = /home/database
public = no
writable = yes
[root@localhost Desktop]# systemctl restart smb重启服务
[root@localhost Desktop]# systemctl enable smb将服务永久生效
[root@localhost Desktop]# cd /home/database/
[root@localhost database]# ls
leo.txt
[root@localhost database]# vim leo.txt