Home System Tutorial LINUX Samba: The best file sharing solution between Linux and Windows

Samba: The best file sharing solution between Linux and Windows

Feb 15, 2024 pm 01:00 PM
linux linux tutorial linux system linux command shell script embeddedlinux Getting started with linux linux learning

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

How to run sublime after writing the code How to run sublime after writing the code Apr 16, 2025 am 08:51 AM

There are six ways to run code in Sublime: through hotkeys, menus, build systems, command lines, set default build systems, and custom build commands, and run individual files/projects by right-clicking on projects/files. The build system availability depends on the installation of Sublime Text.

See all articles