Samba是一个免费的开源软件,可用于在Linux之间共享文件,文件夹和打印机。和Windows系统。
在CentOS 8上安装Samba
步骤1.首先,让我们首先确保您的系统是最新的。
sudo dnf update sudo dnf install epel-release
步骤2.在CentOS 8上安装Samba。
现在,我们运行以下命令来安装Samba及其依赖项:
sudo dnf install samba samba-common samba-client
安装完成后,启动Sambe服务,使其能够在系统启动时自动启动:
sudo systemctl start smb
sudo systemctl status smb
步骤3. Samba配置。
首先,创建默认Samba配置文件的备份副本,该文件带有预配置设置和各种配置指令:
cp /etc/samba/smb.conf /etc/samba/smb.conf.orig
接下来,创建一个名为shared的共享文件夹,并分配必要的权限和所有权:
mkdir -p /srv/samba/idroot chmod -R 0777 /srv/samba/idroot chown -R nobody:nobody /srv/samba/idroot chcon -t samba_share_t /srv/samba/idroot
现在,我们创建一个新的samba配置文件:
sudo nano /etc/samba/smb.conf
添加以下行:
[global] workgroup = WORKGROUP netbios name = rhel security = user ...[idroot] comment = Anonymous File Server Share path = /srv/samba/idroot browsable =yes writable = yes guest ok = yes read only = no force user = nobody
保存并关闭文件。然后,重新启动Samba服务以应用更改:
sudo systemctl restart smb
要验证配置是否正确,请运行testparm
命令:
testparm
输出:
Load smb config files from /etc/samba/smb.conf rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (46384) Unknown parameter encountered: "netbios" Ignoring unknown parameter "netbios" Processing section "[homes]" Processing section "[printers]" Processing section "[print$]" Processing section "[idroot]" Loaded services file OK. Server role: ROLE_STANDALONE Press enter to see a dump of your service definitions # Global parameters [global] printcap name = cups security = USER idmap config * : backend = tdb cups options = raw [homes] browseable = No comment = Home Directories inherit acls = Yes read only = No valid users = %S %D%w%S [printers] browseable = No comment = All Printers create mask = 0600 path = /var/tmp printable = Yes [print$] comment = Printer Drivers create mask = 0664 directory mask = 0775 force group = @printadmin path = /var/lib/samba/drivers write list = @printadmin root[idroot] comment = Anonymous File Server Share force user = nobody guest ok = Yes path = /srv/samba/idroot read only = No
步骤4.配置防火墙。
我们必须打开适当的端口,以便可以从其他计算机访问samba共享的资源:
sudo firewall-cmd --add-service=samba --zone=public --permanent sudo firewall-cmd --reload
步骤5.访问Samba共享路径。
要从Windows访问samba共享,请按Windows键+ R启动运行对话。输入IP地址或主机名,然后按Enter。
恭喜你!您已经成功安装了Samba。感谢您使用本教程在CentOS 8系统上安装Samba。有关其他帮助或有用信息,我们建议您检查Samba官方网站。
原创文章,作者:校长,如若转载,请注明出处:https://www.yundongfang.com/Yun50343.html