Samba服务的配置

384 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

防火墙

[root@localhost ~]# systemctl stop firewalld // 关闭防火墙
[root@localhost ~]# systemctl disable firewalld 》 // 关闭防火墙开机自启
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
在这里插入图片描述

强制模式

[root@localhost ~]# vi /etc/selinux/config # 关闭强制模式
在这里插入图片描述

查看强制模式状态

在这里插入图片描述

samba服务安装与开启

[root@localhost ~]# yum install samba -y //安装samba
[root@localhost ~]# systemctl start smb // 开启samba服务
[root@localhost ~]#systemctl enable smb // smaba开机自启
Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
在这里插入图片描述

用户与目录管理

[root@localhost ~]# mkdir /home/smbfile // 创建smb目录
[root@localhost home]# chmod 777 /home/smbfile // 添加权限
[root@localhost ~]# touch /home/smbfile/Hello.txt
[root@localhost ~]#
[root@localhost ~]# useradd smbuser // 添加系统用户
[root@localhost ~]# smbpasswd -a smbuser // 添加smb用户
New SMB password:
Retype new SMB password:
Added user smbuser.

查看samba用户

配置文件

/etc/samba/smb.conf

==追加配置==

[smb]  // 访问的文件夹名
        comment=This is for smbuser.  //提示信息
        path=/home/smbfile		//samba目录
        valid users=smbuser		// 允许访问的用户[多用户的,隔开]
        write list=smbuser		// 允许写入的用户
        public=no  // 是否公开
        browseable=yes			// 是否可见
        writable=yes		// 是否可写

==检查文件语法==

[root@localhost ~]# testparm // 创建smb目录
在这里插入图片描述

==重启smb服务==

[root@server ~]# systemctl restart smb // 创建smb目录

Linux访问Samba

[root@client ~]# yum install samba-client cifs-utils -y
[root@client ~]# smbclient //192.168.0.135/smb -U smbuser
Enter SAMBA\smbuser's password: 
Domain=[SERVER] OS=[Windows 6.1] Server=[Samba 4.6.2]
smb: \> ls  # 获取文件列表
  .                                   D        0  Fri May  6 16:44:27 2022
  ..                                  D        0  Fri May  6 16:44:08 2022
  Hello.txt                           N       15  Fri May  6 16:44:27 2022

                17811456 blocks of size 1024. 16815292 blocks available
smb: \> mkdir linux  //新建文件夹
smb: \> exit

Window访问Samba

==新建window.txt== 在这里插入图片描述