祝您身体健康,前程似锦,小弟期待文章对您有帮助,也期待您的打赏:
目录
1. 查看当前系统是否已经安装samba
rpm -qa | grep 'samba'
2. 使用yum进行安装
yum -y install samba samba-common samba-client
3. 查看是否安装成功
[jamza@Jamza ~]$ rpm -qa | grep 'samba'
samba-common-tools-4.8.3-4.el7.x86_64
samba-common-4.8.3-4.el7.noarch
samba-client-libs-4.8.3-4.el7.x86_64
samba-libs-4.8.3-4.el7.x86_64
samba-4.8.3-4.el7.x86_64
samba-common-libs-4.8.3-4.el7.x86_64
samba-client-4.8.3-4.el7.x86_64
(安装完成后,会生成/etc/samba/smb.conf文件)
4. 查看samba服务状态,启动服务
service smb status //查看samba服务状态
service smb start //启动samba服务
service smb restart //重启samba服务
5. 设置smb服务开机启动
systemctl enable smb.service
6. 关闭linux端的防火墙
systemctl stop firewalld.service
#停止firewall
systemctl disable firewalld.service
#禁止firewall开机启动
firewall-cmd --state
#查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
7. 关闭SELinux
获取当前SELinux的运行状态:getenforce
返回的结果分为三种:Enforcing,Permissive和Disabled。其中,Enforcing-代表记录警告且阻止可疑行为;Permissive-代表仅记录安全警告但不阻止可疑行为;Disabled表示被禁用
永久改变的话,就需要配置它的配置文件:vi /etc/sysconfig/selinux
设置SELINUX=xxx(xxx表示你想要的状态,enforcing,permissive或disabled)即可
2 # This file controls the state of SELinux on the system.
3 # SELINUX= can take one of these three values:
4 # enforcing - SELinux security policy is enforced.
5 # permissive - SELinux prints warnings instead of enforcing.
6 # disabled - No SELinux policy is loaded.
7 SELINUX=disabled
8 # SELINUXTYPE= can take one of three values:
9 # targeted - Targeted processes are protected,
10 # minimum - Modification of targeted policy. Only selected processes are protected.
11 # mls - Multi Level Security protection.
12 SELINUXTYPE=targeted
8. 添加工作组samba和用户share
groupadd samba
# useradd -g 组名 用户名 useradd -g samba share
# 设置用户share的密码 passwd share
(输入123456)
#删除用户(如果输入错了) userdel -r 用户名
已经存在的系统账户添加到samba中才可以访问共享目录:
# smbpasswd 参数: -a: 添加 -x: 删除 -d: 禁用 -e: 启用 smbpasswd -a share
9. 创建共享目录
mkdir /home/work # chown -R 用户名:组名 目录 chown -R share:samba /home/work
10. 修改samba服务配置文件
打开samba服务配置文件 /etc/samba/smb.conf,内容如下:
# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.
[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes
[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = @printadmin root
force group = @printadmin
create mask = 0664
directory mask = 0775
[work] (增加这段)
path = /home/work
comment = share_dir
public = yes
writeable = yes
browseable = yes
guest ok = yes
valid users = share,root
available = yes
read only = No
11. 重启smb服务
systemctl restart smb.service
12. 访问
在Windows系统上按下“win+r”键,输入"\\共享文件夹的IP地址",在看到文件夹后,点击进入文件夹,输入账户名和密码即可查看共享文件
(期待您上面二维码打赏,也祝您前程似锦,步步高升)