Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

centos8安装samba[0]

Posted on 2023年11月14日2025年5月6日 by
说明:此程序在archlinux,opensuse,raspios上测试通过。

samba是一款开源的文件共享软件,经过简单配置就能够实现Linux系统与Windows系统之间的文件共享工作。

  • 安装samba
yum install samba
  • 修改配置文件:
mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

cat /etc/samba/smb.conf.bak | grep -v "#" | grep -v ";" | grep -v "^$" > /etc/samba/smb.conf

nano /etc/samba/smb.conf

修改成如下:

[global]
        workgroup = MYGROUP
        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

[database]
    comment = Do not arbitrarily modify the database file
        path = /home/database
        public = no
        writable = yes

若只需要用户的home文件夹能够访问,参考如下设置:

[homes]
        comment = Home Directories
        valid users = %S, %D%w%S
        browseable = No
        read only = No
        inherit acls = Yes

注意此处需要创建用户和用户的home文件夹

useradd z7
passwd z7
usermod -a users z7 #增加用户到组
chown -Rf users:z7 /home/  #授权读写

 

  • 添加samba用户
useradd linuxprobe
passwd linuxprobe
pdbedit -a -u linuxprobe

创建linuxpobe的文件存储位置

mkdir /home/database
chown -Rf linuxprobe:linuxprobe /home/database
semanage fcontext -a -t samba_share_t /home/database

检查配置selinux中的samba

getsebool -a | grep samba

若开启了selinux的需要设置

setsebool -P samba_enable_home_dirs on
  • 开启samba
systemctl restart smb
systemctl enable smb

若不能访问,需要检查防火墙

  • win10下测试

传输和删除测试:通过

参考资料:

  1. https://www.linuxprobe.com/chapter-12.html

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT