在Debian上,使用Samba创建网络共享
Anne655
・3 分钟阅读
Samba实现Windows使用的协议,比如,工作组,并允许通过Windows查看和修改文件,你可以在Linux上运行Samba以便与Windows客户机共享文件。
本指南会解释如何在Debian上使用Samba建立一个网络共享。
步骤1安装Samba
我们开始吧,为了使用Samba,我们需要安装它,以root用户身份运行以下命令。
apt-get install samba
步骤2配置Samba
这是困难的部分-我将在添加的配置中解释每一行,本文中,我们将使用nano作为首选文本编辑器,但是,你可以用vim或类似的文本编辑器替换它,通过以root身份运行这些命令来打开它。
nano /etc/samba/smb.conf
在配置中向下滚动时,你将遇到的第一个选项是workgroup =WORKGROUP
,在Windows客户端上,你应该已经设置了一个工作组,我们将使用workcomputers
作为本文的工作组,编辑该行的最后一部分并将WORKGROUP更改为你的工作组,或本文的workcomputers。当我们使用nano时我们将通过按住键ctrl w到达底部,然后ctrl v,在你的配置结束时,将这些行添加到你的配置中:
[networkShare]
comment = description of the shared folder
read only = no
path = /networkShare
guest ok = yes
下面是每一行的说明:
[networkShare] - You may edit the section between the brackets, but you must maintain the brackets.
comment = description - Edit the part after"comment =" to how you want to describe the share.
read only = no - If you want clients to not have the ability to manipulate files, change this to"yes".
path = /networkShare - Edit this to the folder you want to share.
guest ok = yes - For this article, we'll be keeping this easy, so don't change"yes".
完成编辑后点击ctrl x键入Y,然后按enter,然后,我们需要重新启动Samba :
service samba restart
Samba设置已完成,此时,你将开始在Windows客户端的计算机的"网络"部分中看到该服务器。
结束语
通过设置这些共享,你可以控制是否可以修改文件,或者只能复制文件,它们很容易设置,也可以轻松地移除。 你可以在步骤2中添加额外的配置块,以添加更多的共享。