Appearance

linux下搭建samba用来和windows共享文件

coderzhouyu

linux下搭建samba用来和windows共享文件

安装samba

 yum install samba samba-client samba-swat

查看安装情况

rpm -qa | grep samba
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服务器的守护程序,共享文档,日志的轮替,开机默认选项

Samba服务器安装完毕,会生成配置文件目录/etc/samba和其它一些samba可执行命令工具,

/etc/samba/smb.conf是samba的核心配置文件,

/etc/init.d/smb是samba的启动/关闭文件。

启动服务

systemctl start smb #启动samba
systemctl enable smb #设置开机启动
systemctl status smb #查看启动状态

添加windows链接时的用户

smbpasswd -a root

配置smb

vim /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
[public]
        path = /www
        public = yes
        browseable = yes
        writable = yes

windows下链接

windos先要在控制面板添加smb组件

删除 windows 挂载:

win+r cmd

net use Z: /del

Last Updated 2023/10/5 10:09:24