安装samba
[email protected]>~$ sudo yum install -y samba [email protected]>~$ sudo yum install -y samba-client [email protected]>~$ sudo yum install -y samba-common [email protected]>~$ sudo yum install -y samba-winbind [email protected]>~$ sudo yum install -y samba-winbind-clients
创建samba用户的方式1
[[email protected] ~]# useradd share #创建系统用户 [[email protected] ~]# smbpasswd -a share New SMB password:share Retype new SMB password:share
创建samba用户的方式2
[[email protected] ~]# useradd samba_user1 [[email protected] ~]# pdbedit -a samba_user1 new password:samba_user1 retype new password:samba_user1
pdbedit -L #列出所有samba用户
pdbedit -L [username] 查看samba用户
pdbedit -Lv [username] 查看samba用户详细信息
pdbedit -X username 删除一个用户
创建文件目录存放路径,修改权限
mkdir /opt/smb chmod o+w /opt/smb/
#修改samba配置
[[email protected] ~]# cp /etc/samba/smb.conf /etc/samba/smb.conf.install [[email protected] ~]# > /etc/samba/smb.conf [[email protected] ~]# vim /etc/samba/smb.conf log file = /var/log/samba/log.%m max log size = 50 security = user smb passwd file = /etc/samba/smbpasswd load printers = yes cups options = raw create mode = 0644 force create mode = 0644 directory mode = 0755 force directory mode = 0755 [MyShare] path = /opt/smb/ valid users = share,samba_user1 writable = yes
#重启samba服务
[[email protected] ~]# chkconfig smb on [[email protected] samba]# service smb restart Shutting down SMB services: [ OK ] Starting SMB services:
#查看samba监听状态
[[email protected] samba]# netstat -utnlp | grep smb tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 10510/smbd tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 10510/smbd tcp 0 0 :::139 :::* LISTEN 10510/smbd tcp 0 0 :::445 :::* LISTEN 10510/smbd [[email protected] samba]#
iptables -F 关闭防火墙
#windows登录samba服务器
创建文件,创建目录
Linux挂载samba服务器
[email protected]>~$ sudo mount -t cifs //172.16.20.139/MyShare ~/samba/ -o username=samba_user1,password=samba_user1 [email protected]>~$ mount | grep "172.16.20.139" //172.16.20.139/MyShare on /home/chunli/samba type cifs (rw) [email protected]>~$ cd /home/chunli/samba/ [email protected]>samba$ touch test.file touch: 无法创建"test.file": 权限不够 用root用户可以执行挂载,root可以写入
时间: 2024-10-17 10:53:50