samba服务命令

grep -v “^#” /etc/samba/smb.conf.example | grep -v “^;” | grep -v “^$”

[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
printers = yes
cups options = raw
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes

-----------------以上是默认的samba配置文件------------

----------------------配置匿名共享---------------------
systemctl stop firewalld
setenforce 0

vi /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0

vi /etc/fstab
/dev/cdrom /mnt iso9660 defaults 0 0

mount -a
---------------以上上配置yum仓库---------------
yum install -y samba

mkdir /opt/aa

vi /etc/samba/smb.conf
security = share

[database]
comment = this is test file
path = /opt/aa
public = yes

testparm

systemctl start smb
systemctl enable smb

测试:
windows:运行里面输入\192.168.80.110

——————————配置用户密码验证——————————
vi /etc/samba/smb.conf
security = user

[database]
comment = this is test file
path = /opt/aa
public = yes
writable = yes

testparm

useradd -s /sbin/nologin jack

–注意:SMABA用户是系统用户,但是密码不是系统密码,是SAMBA服务器的密码-

pdbedit -a -u jack
pdbedit -L

systemctl restart smb

测试:
windows:运行里面输入\192.168.80.110
net use /d * //清除微软系统的共享访问缓存,让用户可以切换其它账号登录
————————————————————————————
----------------以下是配置对共享目录的权限-------------
vi /etc/samba/smb.conf
security = share

[database]
comment = this is test file
path = /opt/aa
public = yes
read only = yes
writable = yes
valid users = jack,tom //可以通过 @test 加组名
write list = jack
directory mask = 0700
create mask = 0640
hosts deny = 192.168.80.6
hosts allow = 192.168.80.0 173.11.0.0
0可以省略,多个网段可以以空格做间隔符

PS: write list = … > read only = yes > writable = yes

“;”是注释

只有某某有写权限,只需 write list = 用户或组名(基本组)

//注意一下系统目录本身的权限对用户是否有读写执行

————————————————————————————

----------------------配置共享帐号映射(别名)---------
vi /etc/samba/smbusers
hunter = sunboy player

vi /etc/samba/smb.conf

[global]
username map = /etc/samba/smbusers

systemctl restart smb


------------------windows共享目录,linux去连接-------
yum install cifs-utils -y
yum install samba-client -y

smbclient -L 192.168.80.6
smbclient -L 192.168.80.6 -U jack

mount.cifs //192.168.80.6/ISO-all /media/ 匿名共享直接挂载 要有mount.cifs命令

yum provides mount.cifs

mount -o username=jack //192.168.80.6/ISO-all /media/

-----------------以上临时的-------------

vi /etc/fstab
//192.168.80.10/共享文件 /opt/bb cifs username=administrator,password=123 0 0
-----------------------永久挂载-----------------
vim auth.smb
username=jack
password=123
domain=MYGROUP

vi /etc/fstab
//192.168.80.110/test /opt/dd cifs credentials=/root/auth.smb 0 0

注意:cifs:是samba的共享文件的格式

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值