安装samba
linuxidc@CentOS->~$ sudo yum install -y samba
linuxidc@CentOS->~$ sudo yum install -y samba-client
linuxidc@CentOS->~$ sudo yum install -y samba-common
linuxidc@CentOS->~$ sudo yum install -y samba-winbind
linuxidc@CentOS->~$ sudo yum install -y samba-winbind-clients
创建samba用户的方式1
[root@CentOS ~]# useradd share #创建系统用户
[root@CentOS ~]# smbpasswd -a share
New SMB password:share
Retype new SMB password:share
创建samba用户的方式2
[root@CentOS ~]# useradd samba_user1
[root@CentOS ~]# 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配置
[root@CentOS ~]# cp /etc/samba/smb.conf /etc/samba/smb.conf.install
[root@CentOS ~]# > /etc/samba/smb.conf
[root@CentOS ~]# 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服务
[root@CentOS ~]# chkconfig smb on
[root@CentOS samba]# service smb restart
Shutting down SMB services: [ OK ]
Starting SMB services:
#查看samba监听状态
[root@CentOS 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
[root@CentOS samba]#
iptables -F 关闭防火墙
#Windows登录samba服务器
创建文件,创建目录
Linux挂载samba服务器
linuxidc@CentOS->~$ sudo mount -t cifs //172.16.20.139/MyShare ~/samba/ -o username=samba_user1,password=samba_user1
linuxidc@CentOS->~$ mount | grep "172.16.20.139"
//172.16.20.139/MyShare on /home/linuxidc/samba type cifs (rw)
linuxidc@CentOS->~$ cd /home/linuxidc/samba/
linuxidc@CentOS->samba$ touch test.file
touch: 无法创建"test.file": 权限不够
用root用户可以执行挂载,root可以写入
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
长按识别二维码并关注微信
更方便到期提醒、手机管理