Install Samba file server with yum under CentOS 6
安装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
Method 1 to create a samba user
[root@CentOS ~]# useradd share #Create a system user
[root@CentOS ~]# smbpasswd -a share
New SMB password:share
Retype new SMB password:share
Method 2 to create a samba user
[root@CentOS ~]# useradd samba_user1
[root@CentOS ~]# pdbedit -a samba_user1
new password:samba_user1
retype new password:samba_user1
pdbedit -L #List all samba users
pdbedit -L [username] View samba users
pdbedit -Lv [username] View samba user details
pdbedit -X username Delete a user
Create a file directory storage path, modify permissions
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:
#View samba listening status
[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 disable firewall
#Windows log in to the samba server
to create a file, create a directory
Linux mount samba server
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: cannot create "test.file" ": Insufficient permissions,
the root user can perform the mount, and root can write