samba是一种文件共享工具,也是常用的NAS工具之一。samba常用于linux和windows之间的文件共享。
安装方式
- yum方式安装
[root@server03 ~]# yum -y install samba samba-client samba-comman
- 启动进程
[root@server03 ~]# systemctl start nmb.service
[root@server03 ~]# systemctl start smb.service
[root@server03 ~]# ps -ef | grep smb
root 14956 1 0 19:19 ? 00:00:00 /usr/sbin/smbd --foreground --no-process-group
root 14958 14956 0 19:19 ? 00:00:00 /usr/sbin/smbd --foreground --no-process-group
root 14959 14956 0 19:19 ? 00:00:00 /usr/sbin/smbd --foreground --no-process-group
root 14960 14956 0 19:19 ? 00:00:00 /usr/sbin/smbd --foreground --no-process-group
root 15113 6485 0 19:23 pts/1 00:00:00 grep --color=auto smb
[root@server03 ~]# ps -ef | grep nmb
root 14948 1 0 19:19 ? 00:00:00 /usr/sbin/nmbd --foreground --no-process-group
root 15117 6485 0 19:23 pts/1 00:00:00 grep --color=auto nmb
smb进程:该进程负责建立主机与客户机之间的连接,实现文件共享,是samba的核心进程。端口:tcp-139,445
nmb进程:负责名称解析,将linux主机共享的目录与其IP对应起来。端口:udp-137,138
配置服务
[root@server03 samba]# cp smb.conf smb.conf.bak
[root@server03 samba]# > smb.conf
[root@server03 samba]# vim smb.conf
[share_test]
comment='for test'
path=/samba_dir
browseable=yes
public=yes
readonly=no
writeable=yes
write list=lzp
测试配置文件语法
[root@server03 samba]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[share_test]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
# Global parameters
[global]
idmap config * : backend = tdb
[share_test]
comment = 'for test'
guest ok = Yes
path = /samba_dir
read only = No
write list = lzp
- 添加samba用户(对其进行目录权限授权)、创建共享目录、重新启动服务。
添加用户
[root@server03 samba]# useradd lzp
加入smb
[root@server03 samba]# smbpasswd -a lzp
New SMB password:
Retype new SMB password:
创建共享目录
[root@server03 samba]# mkdir /samba_dir
目录对用户授权
[root@server03 samba]# setfacl -m u:lzp:rwx /samba_dir/
重启服务
[root@server03 samba]# systemctl restart smb
网友评论