centos7安装samba(最全教程)

关闭防火墙

[root@localhost ~]# systemctl stop firewalld.service 
[root@localhost ~]# systemctl disable firewalld.service 
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.

关闭selinux

[root@localhost ~]# cat /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

安装

[root@localhost ]# yum install samba

#查看
[root@localhost ]# rpm -qa | grep samba
samba-common-libs-4.8.3-4.el7.x86_64
samba-libs-4.8.3-4.el7.x86_64
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-4.8.3-4.el7.x86_64
samba-client-4.8.3-4.el7.x86_64


安装包说明
samba-common-3.5.10-125.el6.x86_64               //主要提供samba服务器的设置文件与设置文件语法检验程序testparm
samba-client-3.5.10-125.el6.x86_64                    //客户端软件,主要提供linux主机作为客户端时,所需要的工具指令集
samba-swat-3.5.10-125.el6.x86_64                    //基于https协议的samba服务器web配置界面
samba-3.5.10-125.el6.x86_64                            //服务器端软件,主要提供samba服务器的守护程序,共享文档,日志的轮替,开机默认选项

配置服务

安装后会生成/etc/samba目录,

#======================= Global Settings =====================================

[global]                                                  

# ----------------------- Network Related Options -------------------------
#
# workgroup = NT-Domain-Name or Workgroup-Name, eg: MIDEARTH
#
# server string is the equivalent of the NT Description field
#
# netbios name can be used to specify a server name not tied to the hostname

workgroup = WORKGROUP                             
server string = Liuyunsheng Samba Server Version %v     
netbios name = Liuyunsheng-Samba                         

# --------------------------- Logging Options -----------------------------
#
# Log File let you specify where to put logs and how to split them up.

log file = /var/log/samba/log.%m                  
                                                          
# ----------------------- Standalone Server Options ------------------------
#
# Scurity can be set to user, share(deprecated) or server(deprecated)

security = user 
map to guest = Bad User                                 

#============================ Share Definitions ==============================

[public]                                          
comment = Public Stuff                            
path = /home/test/test
writeable = yes
public = yes 
# 启动smb服务
[root@localhost samba]# systemctl start smb
[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 Thu 2019-04-25 14:44:24 CST; 3s ago
     Docs: man:smbd(8)
           man:samba(7)
           man:smb.conf(5)
 Main PID: 22111 (smbd)
   Status: "smbd: ready to serve connections..."
   Memory: 8.3M
   CGroup: /system.slice/smb.service
           ├─22111 /usr/sbin/smbd --foreground --no-process-group
           ├─22115 /usr/sbin/smbd --foreground --no-process-group
           ├─22116 /usr/sbin/smbd --foreground --no-process-group
           └─22117 /usr/sbin/smbd --foreground --no-process-group

Apr 25 14:44:24 localhost.localdomain systemd[1]: Starting Samba SMB Daemon...
Apr 25 14:44:24 localhost.localdomain smbd[22111]: [2019/04/25 14:44:24.814732,  0] ../lib/util/become_daemon.c:138(daemon_ready)
Apr 25 14:44:24 localhost.localdomain smbd[22111]:   daemon_ready: STATUS=daemon 'smbd' finished starting up and ready to serve connections
Apr 25 14:44:24 localhost.localdomain systemd[1]: Started Samba SMB Daemon.
添加账户(添加的账户必须linux已经创建的)
直接添加用户test会导致失败
[root@localhost share]# smbpasswd -a test
Unknown parameter encountered: "     map to guest"
Ignoring unknown parameter "     map to guest"
New SMB password:
Retype new SMB password:
Failed to add entry for user test.
创建linux账户
[root@localhost share]# groupadd test -g 6000
[root@localhost share]# useradd test -u 6000 -g 6000 -s /sbin/nologin -d /dev/null
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.

创建samba用户
[root@localhost share]# smbpasswd -a test
Unknown parameter encountered: "     map to guest"
Ignoring unknown parameter "     map to guest"
New SMB password:
Retype new SMB password:
Added user test.

删除samba用户
[root@localhost samba]# smbpasswd -x test
Deleted user test.


客户端访问共享目录

在windows输入\\19.6.6.192
然后输入设置的用户名和密码就可以了,并且可以将连接的文件夹映射为网络驱动器,这样就可以直接操作了


谢谢支持打赏

在这里插入图片描述

  • 22
    点赞
  • 117
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 16
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

liuyunshengsir

微信:lys20191020

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值