CentOS服务器如何挂载Samba?
安装sambalinuxidc@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
# useradd share #创建系统用户
# smbpasswd -a share
New SMB password:share
Retype new SMB password:share
创建samba用户的方式2
# useradd samba_user1
# pdbedit -a samba_user1
new password:samba_user1
retype new password:samba_user1
pdbedit -L #列出所有samba用户
pdbedit -L 查看samba用户
pdbedit -Lv 查看samba用户详细信息
pdbedit -X username删除一个用户
创建文件目录存放路径,修改权限
mkdir /opt/smb
chmod o+w /opt/smb/
#修改samba配置
# cp /etc/samba/smb.conf /etc/samba/smb.conf.install
# > /etc/samba/smb.conf
# 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
path = /opt/smb/
valid users = share,samba_user1
writable = yes
#重启samba服务
# chkconfig smb on
# service smb restart
Shutting down SMB services:
Starting SMB services:
#查看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
#
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可以写入
页:
[1]