Samba installation configuration usage

I need to use Linux as a file service and Windows to read or write files under the same intranet. I feel that Samba is more suitable, so I will write about it.

Samba is an open source software suite that implements file sharing and network resource sharing functions between different operating systems. By supporting the SMB/CIFS protocol, it enables Linux, Unix, Windows and other systems to communicate with each other and share files.

Install

sudo apt-get install samba

Configuration

Open the Samba configuration file

sudo nano /etc/samba/smb.conf

Add the configuration of the shared folder at the end of the file.
For example, the following is the
share name: Pictures.
The description is Shared Pictures.
Specify users who can access it.
Set read-only to no for pi.

[Pictures]
comment = Shared Pictures
path = /home/pi/Pictures
valid users = pi
read only = no

The following are some common configuration items and their functions:

[global] 部分:
workgroup:定义工作组的名称,用于标识网络中的计算机群组。
server string:指定服务器的描述字符串。
security:设置安全级别,例如使用用户身份验证。
map to guest:定义未经身份验证的访问行为。

[share] 部分(将"share"替换为共享名称):
comment:提供共享的注释或描述信息。
path:指定共享的文件夹路径。
valid users:定义可以访问共享的用户列表。
read only:设置共享是否为只读模式。
writable:指定共享是否可写入。
guest ok:允许访客(未经身份验证)访问共享。
browseable:控制共享是否在网络上可浏览。

身份验证和权限设置:
username map:映射不同的用户名,以使Samba中的用户名与系统中的用户名匹配。
valid users:定义可以访问共享的用户列表。
invalid users:定义被拒绝访问共享的用户列表。
write list:指定可以写入共享的用户列表。
create mask 和 directory mask:设置新创建的文件和目录的默认权限掩码。

其他选项:
hosts allow 和 hosts deny:允许或拒绝特定主机或IP地址的访问。
printing:启用或禁用打印功能。
printcap name:指定打印机配置文件的名称。
printer admin:指定打印机管理员的用户列表。

Create Samba user password

Run the following command to create a Samba user password. pi is the created user name. After pressing Enter, you will be prompted to enter the password.

sudo smbpasswd -a pi

Restart the Samba service

Run the following command to restart the Samba service for the configuration changes to take effect.
Remember to allow port 139

sudo service smbd restart

Guess you like

Origin blog.csdn.net/sywdebug/article/details/132763723