在Ubuntu 20.04 LTS Focal Fossa上安装Samba
步骤1.首先,通过apt
在终端中运行以下命令来确保所有系统软件包都是最新的。
sudo apt update
sudo apt upgrade
步骤2.配置主机文件。
我们需要将Ubuntu 20.04 LTS添加到Windows主机文件中。为此,请在Windows中运行以下命令:
notepad C:\\Windows\System32\drivers\etc\hosts
您需要添加由命名的ubuntu2004引用的Ubuntu的本地条目,并保存它:
192.168.1.3 ubuntu2004.localhost ubuntu2004
然后,运行以下命令,并使用Windows的主机名键入IP,保存文件并退出:
sudo nano /etc/hosts
完成后,以管理特权在Windows中运行以下命令:
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes
步骤3.在Ubuntu 20.04上安装Samba。
在终端中运行以下命令以在Ubuntu系统上安装Samba:
sudo apt install samba samba-common-bin
要验证Samba服务是否正在运行,请运行以下命令:
sudo systemctl status smbd
步骤4.配置Samba公共共享。
运行以下命令以打开Samba配置:
sudo nano /etc/samba/smb.conf
在下面添加以下行:
======================= Global Settings ======================= [global] ## Browsing/Identification ### # Change this to the workgroup/NT-domain name your Samba server will part of workgroup = WORKGROUPnetbios name = ubuntu2004 security = user proxy = no map to guest = bad user #### Networking #### # The specific set of interfaces / networks to bind to # This can be either the interface name or an IP address/netmask; # interface names are normally preferred interfaces = 127.0.0.0/8 eth0 # Only bind to the named interfaces and/or networks; you must use the # 'interfaces' option above to use this. bind interfaces only = yes #Most people will want "standalone server" or "member server". #Running as "active directory domain controller" will require firstserver role = standalone server obey pam restrictions = yes #This boolean parameter controls whether Samba attempts to sync the Unix[public] path = /samba/public browseable = yes guest ok = yes guest only = yes read only = no force user = nobody force create mode = 0777 force directory mode = 0777
进行更改后,重新启动Samba守护程序:
sudo systemctl restart smbd
接下来,您需要创建一个公用文件夹,每个人都应具有以下权限:
sudo mkdir -p /samba/public
成功后,重新启动Samba服务器。您可以在Windows 10或您使用的任何Windows中看到共享文件夹。
步骤5.配置防火墙。
如果您有活动的防火墙,请运行:
sudo ufw allow 'Samba'
恭喜你!您已经成功安装了Samba。感谢您使用本教程在Ubuntu 20.04 LTS Focal Fossa系统上安装Samba。有关其他帮助或有用信息,我们建议您检查Samba官方网站。
原创文章,作者:校长,如若转载,请注明出处:https://www.yundongfang.com/Yun40271.html