1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - Linux系统 - centos - 正文

君子好学,自强不息!

这里以VMWARE与主控真机来做实现实现

由于SMB在centos中自带,所以,无需像网上说的样子,要这删除,那卸载,直接搜索是否存在SAMBA的安装文件

一 查询包是否存在

[root@localhost ~]# rpm -qa|grep samba
samba-client-libs-4.4.4-9.el7.x86_64
samba-common-libs-4.4.4-9.el7.x86_64
samba-client-4.4.4-9.el7.x86_64
samba-common-4.4.4-9.el7.noarch

二  编辑  配置文件,设置共享时的信息

[root@localhost samba]# vi smb.conf

[global]
workgroup = WORKGROP
security = user

passdb backend = tdbsam
map to guest=Bad User
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[FileShare]
path=/home/zabbixserver
public=yes
writeable=yes
create mask=0644
directory mask=0755

 

 修改这两个地方的配置,只需要注意红色的部分就好

三 测试配置的文件是否正确:

[root@localhost samba]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section “[FileShare]”
Processing section “[homes]”
Processing section “[printers]”
Processing section “[print$]”
Loaded services file OK.

四  安装包

smb:[root@localhost samba]# yum install samba
Loaded plugins: fastestmirror, langpacks

Yes…

五 打开服务并关键访问策略

[root@localhost samba]# systemctl start smb
[root@localhost samba]# setenforce 0

[root@localhost samba]# systemctl status smb
● smb.service – Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2019-04-16 18:38:36 PDT; 2min 27s ago
Docs: man:smbd(8)
man:samba(7)
man:smb.conf(5)
Main PID: 28414 (smbd)
Status: “smbd: ready to serve connections…”
Memory: 16.6M
CGroup: /system.slice/smb.service
├─28414 /usr/sbin/smbd –foreground –no-process-group
├─28416 /usr/sbin/smbd –foreground –no-process-group
├─28417 /usr/sbin/smbd –foreground –no-process-group
└─28418 /usr/sbin/smbd –foreground –no-process-group

Apr 16 18:38:35 localhost.localdomain systemd[1]: Starting Samba SMB Daemon…
Apr 16 18:38:36 localhost.localdomain smbd[28414]: [2019/04/16 18:38:36.121155, 0] ../lib/param/loadparm.c:784(lpcfg_map_parameter)
Apr 16 18:38:36 localhost.localdomain smbd[28414]: Unknown parameter encountered: “commem”
Apr 16 18:38:36 localhost.localdomain smbd[28414]: [2019/04/16 18:38:36.121372, 0] ../lib/param/loadparm.c:1844(lpcfg_do_service_parameter)
Apr 16 18:38:36 localhost.localdomain smbd[28414]: Ignoring unknown parameter “commem”
Apr 16 18:38:36 localhost.localdomain smbd[28414]: [2019/04/16 18:38:36.171093, 0] ../lib/util/become_daemon.c:138(daemon_ready)
Apr 16 18:38:36 localhost.localdomain smbd[28414]: daemon_ready: STATUS=daemon ‘smbd’ finished starting up and ready to serve connections
Apr 16 18:38:36 localhost.localdomain systemd[1]: Started Samba SMB Daemon.

这里我按照网上的配置地sharefile里面加  commen=this is a share file 时发现有报错,于是,我直接注释掉这个配置信息,就是一个提示信息而已,不影响

再一次查看启动状态:

[root@localhost samba]# systemctl status smb
● smb.service – Samba SMB Daemon
Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2019-04-16 18:43:40 PDT; 5s ago
Docs: man:smbd(8)
man:samba(7)
man:smb.conf(5)
Main PID: 28525 (smbd)
Status: “smbd: ready to serve connections…”
Memory: 20.8M
CGroup: /system.slice/smb.service
├─28525 /usr/sbin/smbd –foreground –no-process-group
├─28527 /usr/sbin/smbd –foreground –no-process-group
├─28528 /usr/sbin/smbd –foreground –no-process-group
└─28529 /usr/sbin/smbd –foreground –no-process-group

Apr 16 18:43:40 localhost.localdomain systemd[1]: Starting Samba SMB Daemon…
Apr 16 18:43:40 localhost.localdomain systemd[1]: Started Samba SMB Daemon.
Apr 16 18:43:40 localhost.localdomain smbd[28525]: [2019/04/16 18:43:40.665073, 0] ../lib/util/become_daemon.c:138(daemon_ready)
Apr 16 18:43:40 localhost.localdomain smbd[28525]: daemon_ready: STATUS=daemon ‘smbd’ finished starting up and ready to serve connecti

这时候,发现,启动完全正常

六 查看使用的端口以及端口状态:

[root@localhost samba]# netstat -lntp |grep smb
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 28525/smbd
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 28525/smbd
tcp6 0 0 :::139 :::* LISTEN 28525/smbd
tcp6 0 0 :::445 :::* LISTEN 28525/smbd

7.在window端使用telnet 尝试发现,端口不通

telnet  192.168.80.133  139  被拒绝

8 关闭防火墙,也可以开放相应的端口,我这里直接爆力关闭

[root@localhost samba]# systemctl stop firewalld

9. 在真机再一次尝试

linux centos7--linux和window共享文件(samba)

 

这一次正常访问了,至此,共享成功

 

本文来源:1818IP

本文地址:https://www.1818ip.com/post/32598.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。