树莓派官方文档之samba

Samba/CIFS

Samba is a implementation of the SMB/CIFS networking protocol that is used by Windows devices to provide shared access to files, printers, and serial ports etc. There is a comprehensive Wikipedia page about Samba and its capabilities.

Samba 是 SMB/CIFS 网络协议的实现,该协议被 Windows 设备用于共享访问文件、打印机和串行端口等。
维基百科上有一个综合介绍 Samba 及其作用的页面。

This page will explain how to use a subset of the Samba system to ‘mount’ a shared folder on a Windows device so it appears on your Raspberry Pi, or to share a folder on your Raspberry Pi so it can be accessed by a Windows client.

这个页面将解释如何使用 Samba 系统的子集在 Windows 设备上安装一个共享文件夹,这样它就会出现在你的 Raspberry Pi 上,
或者在你的 Raspberry Pi 上共享一个文件夹并且可以被 Windows 客户端访问。

Installing CIFS/Samba support 安装 CIFS/Samba 支持

By default, Raspbian does not include CIFS/Samba support, but this can easily be added. The following commmands will install all the required components for using Samba as a server or a client.

默认Raspbian 不包含 CIFS/Samba 支持,但是这很容易添加。 下面的命令将安装使用 Samba 作为服务器或客户端所需的所有组件。

sudo apt-get update
sudo apt-get install samba samba-common-bin smbclient cifs-utils

Using a shared Windows folder 使用共享 Windows 文件夹

First, you need to share a folder on your Windows device. This is quite a convoluted process!

首先,你需要在 Windows 设备上共享一个文件夹。 这是一个相当复杂的过程!

Turn on sharing 开始分享

  1. Open the Networking and Sharing Centre by right-clicking on the system tray and selecting it
  2. Click on Change advanced sharing settings
  3. Select Turn on network discovery
  4. Select Turn on file and printer sharing
  5. Save changes

  1. 右键单击并选择系统托盘来打开网络和共享中心
  2. 点击更改高级共享设置
  3. 选择打开网络发现
  4. 选择打开文件和打印机共享
  5. 保存更改

Share the folder 共享文件夹

You can share any folder you want, but for this example, simply create a folder called share.

你可以共享任何你想共享的文件夹,但是在这个例子中,简单起见就创建一个名为 share 的文件夹。

  1. Create the folder share on your desktop.
  2. Right-click on the new folder, and select Properties.
  3. Click on the Sharing tab, and then the Advanced Sharing button
  4. Select Share this folder; by default, the share name is the name of the folder
  5. Click on the Permissions button
  6. For this example, select Everyone and Full Control (you can limit access to specific users if required); click OK when done, then OK again to leave the Advanced Sharing page
  7. Click on the Security tab, as we now need to configure the same permissions
  8. Select the same settings as the Permissions tab, adding the chosen user if necessary
  9. Click OK

  1. 在你的桌面上创建一个名为 share 的文件夹
  2. 右击新文件夹,然后选择属性
  3. 点击共享选项卡,然后点击高级共享按钮
  4. 选择共享此文件夹; 默认情况下,共享名称是文件夹的名称
  5. 点击权限按钮
  6. 在这个例子中,选择Everyone完全控制(如果需要,您可以限制访问特定用户) ; 完成后单击确定,然后再次确定离开高级共享页面
  7. 点击安全标签,因为我们现在需要配置相同的权限
  8. 选择与权限选项卡相同的设置,必要时添加所选用户
  9. 点击确定

The folder should now be shared.
该文件夹现在应该被共享。

Windows 10 Sharing Wizard

On Windows 10 there is a Sharing Wizard that helps with some of these steps.

在 windows10上有一个分享向导,它可以帮助你完成这些步骤。

  1. Run the Computer Management application from the Start Bar
  2. Select Shared Folders, then Shares
  3. Right-click and select New Share, which will start up the Sharing Wizard; click Next
  4. Select the folder you wish to share, and click Next
  5. Click Next to use all the sharing defaults
  6. Select Custom and set the required permissions, and click OK, then Finish

  1. 从开始栏运行计算机管理应用程序
  2. 选择共享文件夹,然后分享
  3. 右击并选择新共享,这将启动共享向导; 单击下一步"
  4. 选择要共享的文件夹,然后单击下一步
  5. 单击下一步来使用所有的共享默认值
  6. 选择自定义并设置所需权限,然后单击确定,然后完成

Mount the folder on the Raspberry Pi 在 Raspberry Pi 上挂载文件夹

Mounting* in Linux is the process of attaching a folder to a location, so firstly we need that location.

在 Linux 中挂载是将一个文件夹连接到一个位置的过程,首先我们需要这个位置。

mkdir windowshare

Now, we need to mount the remote folder to that location. The remote folder is the host name or IP address of the Windows PC, and the share name used when sharing it.
We also need to provide the Windows username that will be used to access the remote machine.

现在,我们需要将远程文件夹挂载到该位置。远程文件夹是 Windows PC 的主机名或 IP 地址,以及共享时使用的共享名称。
我们还需要提供用于访问远程计算机的 Windows 用户名。

sudo mount.cifs //<hostname or IP address>/share /home/pi/windowshare -o user=<name>

You should now be able to view the content of the Windows share on your Raspberry Pi.

现在你应该可以在你的 Raspberry Pi 上查看 Windows 分享的内容。

cd windowshare
ls

Sharing a folder for use by Windows 共享文件夹供 Windows 使用

Firstly, create a folder to share. This example creates a folder called shared in the home folder of the current user, and assumes the current user is pi.

首先,创建一个文件夹来共享。这个例子是在当前用户的家目录下创建一个名为 share 的文件夹,并假设当前用户是 pi。

cd ~
mkdir shared

Now we need to tell Samba to share this folder, using the Samba configuration file.

现在我们需要告诉 Samba 共享这个文件夹,通过使用 Samba 配置文件。

sudo nano /etc/samba/smb.conf

At the end of the file, add the following to share the folder, giving the remote user read/write permissions:

在文件的末尾,添加以下来分享文件夹,给予远程用户读写权限:

[share]
    path = /home/pi/shared
    available = yes
    valid users = pi
    read only = no
    browsable = yes
    public = yes
    writable = yes

In the same file, find the workgroup line, and if necessary, change it to the name of the workgroup of your local Windows network.

在同一个文件中,查找workgroup所在的行,如果有必要可以将其更改为本地 Windows 网络的工作组名称。

workgroup = <your workgroup name here>

That should be enough to share the folder. On your Windows device, when you browse the network, the folder should appear and you should be able to connect to it.

这些对于分享这个文件夹来说应该足够了。在你的 Windows 设备上浏览网络时,文件夹应该会出现,你也应该可以连接到它。

你可能感兴趣的:(外语翻译,树莓派,树莓派,samba)