Home > System Tutorial > LINUX > body text

Samba: The best file sharing solution between Linux and Windows

PHPz
Release: 2024-02-15 13:00:14
forward
895 people have browsed it

Linux系统和Windows系统之间的文件共享一直是一个值得关注的话题。在过去,想要在这两种操作系统之间互相分享文件,需要通过FTP或者HTTP等协议来实现,但是这种方式很繁琐并且不安全。如今,有了Samba这个强大的工具,你可以很容易地在Linux和Windows系统之间实现文件共享,而不必担心安全问题。

Samba让你可以在Linux系统上模拟文件和打印服务。你可能并不完全了解这样的系统能为你做什么,但简而言之,使用Samba创建基于Linux的文件和打印服务器,有望为你省钱并简化管理。

Samba: The best file sharing solution between Linux and Windows

一、不需要域

不必实施Windows Active Directory(AD)域即可使用Samba文件和打印共享。如果你有域,也不必为了向Windows系统提供文件和打印服务而将Linux系统加入域。但需要做两件事才能使这两个操作系统无缝运行,如同拥有一个AD域那样:同步密码,并匹配域或工作组名称。

注意:我不反对AD域,相反支持AD域。我也是Windows管理员,明白拥有AD域的价值。如果你没有AD域,或者不想将Linux系统加入域,有一些变通方法。

同步那些密码

在没有AD域的情况下实施Samba时你要做的一件事就是同步密码。在Linux系统上,将密码设为与Windows系统(或域)上使用的密码为同一个。请记住,你得使用smbpasswd命令来这么做。passwd命令仅适用于Linux用户帐户,不影响Samba用户的密码。

添加Samba用户实际上是两个步骤的过程。首先要添加新用户:

$ sudo smbpasswd -a mjones
Copy after login

其次需要启用新用户。这是最常被遗忘的步骤:

$ sudo smbpasswd -e mjones
Copy after login

之后,使用smbpasswd命令更改Samba用户的密码:

$ sudo smbpasswd mjones
Copy after login

有一种方法可以使用/etc/samba/smb.conf文件中的全局配置设置来同步用户和密码,但是该选项不在本文探讨的范围。

匹配域或工作组名称

设置Samba时,使用Windows系统使用的域或工作组名称。默认工作组名称(SAMBA)在Windows环境中可能没有用。匹配名称将帮助你浏览Windows系统,允许Windows系统顺畅无阻地浏览Linux系统的共享区。

启用了Samba的Linux系统还会出现在域计算机的浏览列表中。不过由于该系统不是正式的域成员,因此Windows管理员无法以任何方式执行策略或管理系统。提醒一下,应获得以这种方式配置Linux系统的权限。

二、启用Samba的Linux系统看起来像Windows系统

如果你的网络上有正确配置的启用Samba的Linux系统,很难将它与Windows系统区分开来。你甚至可以模仿所选择的Windows版本,让Linux系统报告自己是Windows系统。大多数用户不会知道有何区别,也不会关心在网络浏览器中看到的一个或多个系统运行Linux。

将驱动器映射到Samba共享区

若没有AD域,你要创建一个CMD(比如LOGIN.CMD)文件,并将其放入每个用户的Startup文件夹中,该文件夹将驱动器映射到Linux Samba文件服务器。优秀的Windows管理员可以实现映射的驱动器,无需接触每个系统。简单的PowerShell脚本可以将CMD文件部署到网络上的每个Windows系统。如果你有域,可以创建组策略,将驱动器映射到系统及其共享区。在这两种情况下,假设你的Linux文件服务器名为FS1,并且有两个共享区:Public和Projects。以平常的方式从Windows计算机映射驱动器:

NET USE P: \\FS1\Public
NET USE Q: \\FS1\Projects
Copy after login

如果一切设置正确,驱动器将会映射,没有密码提示,就像你使用Windows文件服务器一样。标准共享区可锁定起来,供特定的用户或组使用。Public驱动器之类的共享区通常对所有人开放,可以读取写入。

管理共享区不包括在内

Windows管理员会注意到,他们心爱的管理共享区(C等)在Samba中不存在,也不应该存在。当然,你可以创建管理共享区,但除非你出于某个原因想要破坏Linux系统的安全性,否则就没有理由这么做。

打印机共享/服务

通过Samba设置打印机共享是相当复杂的过程。你得为Windows驱动程序和spooling打印作业创建共享区,必须单独共享每台打印机。正确设置后,Samba打印机共享或服务效果很好。进行这项设置时务必要耐心,因为相比Windows服务器的安装设置(几乎是自动的),其安装设置可能令人沮丧。

三、可选的Samba功能和部署

Using Samba, your Linux system can become a browser host, domain controller or domain member without any commercial software. Of course, the feature list will never quite compare to an actual Windows server, but for cost savings and overall ease of setup, you can't go wrong with Samba if you want to integrate with a Windows system.

Want to use Windows, just create Samba enabled Linux. In other words, once you have Samba set up, configured, and running, you don't need to perform any special operations on your Windows system. From this perspective, Samba is easy to implement, and the only deployment is what you would expect from a Windows server, since there are no third-party agents to install, and no special configuration is required to use the Samba server.

NOTE: Due to the way browsing on Windows networks, Shares and Systems may not appear for up to 45 minutes. Be patient, and don't think something is wrong when Community Zones and Systems don't immediately appear in the browse list.

4. Summary

For years, IT administrators have deployed tools to integrate Windows and Linux/Unix systems on corporate networks. NFS software for Windows, terminal emulation software for Windows, FTP clients, and SSH clients are common tools deployed on Windows systems to interface with these systems, yet Samba works almost out of the box. Samba requires very little computational overhead to run. Any Linux system can be used. First released in 1992, Samba has proven its place in modern networking and provides free interoperability for your heterogeneous environments. Enjoy!

In short, Samba is a very powerful tool that makes file sharing between Linux and Windows very simple. In just a few steps, you can easily set up a Samba share and transfer files between the two operating systems in real time. We strongly recommend Samba as the tool of choice for file sharing, it will bring you faster speeds, stronger security, and a better user experience.

The above is the detailed content of Samba: The best file sharing solution between Linux and Windows. For more information, please follow other related articles on the PHP Chinese website!

source:lxlinux.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!