配置samba

1,安装

yum install samba -y

 

2,配置

vi /etc/samba/smb.conf

添加sambatest用户信息,配置文件中不能含有#后面内容

[test1]
path = /home/disk1         #共享目录
public = yes               #允许guest用户访问
writable = yes    
directory mask = 0775
create mask = 0775
valid users = smbtest,bridge,root  #允许访问该共享的用户
write list = smbtest,bridge,root   #可写入共享的用户列表
browseable = yes           #该指定共享目录可浏览
available = yes            #该指定共享资源可使用

testparm   # 测试samba配置是否正确

 

3,用户

useradd sambatest   # linux用户

passwd sambatest    # linux密码

smbpasswd -a sambatest  # linux用户---> samba用户

 

4,服务启动:

systemctl restart smb   # 启动smb

systemctl restart smb   # 重启smb

systemctl enable smb          # 设置开机启动

service smb status  # 查看状态

 

5,防火墙开放端口:

firewall-cmd --zone=public --add-port=139/tcp --permanent
firewall-cmd --zone=public --add-port=445/tcp --permanent
firewall-cmd --zone=public --add-port=137/udp --permanent
firewall-cmd --zone=public --add-port=138/udp --permanent
firewall-cmd --reload
systemctl restart firewalld.service

6,关闭SELinux

setenforce 0    # 如果可以看到目录,但是无法访问就是SELinux的问题

 

 7,如果慢,改hostname

vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=server

vim /etc/hosts
#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1 server
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

 

service network restart


 

 

 

######################

结束

######################

其他关闭命令:

1,关闭防火墙 firewalld

systemctl stop firewalld

2,关闭防火墙 iptables

systemctl stop iptables

3,关闭SELinux

setenforce 0

 

 

关防火墙:service iptables stop

systemctl stop firewalld

systemctl status firewalld

systemctl disable firewalld

systemctl enable firewalld

systemctl stop firewalld

systemctl mask firewalld

yum install iptables-services

 

systemctl enable iptables

systemctl stop iptables

systemctl start iptables

systemctl restart iptables

systemctl reload iptables

 

posted @ 2021-04-14 21:11  GUXH  阅读(27)  评论(0编辑  收藏  举报