May 24, 2021 That's what Linux should learn
The FTP file transfer service explained in the last chapter can actually make file transfer between hosts simple and convenient, but the nature of the FTP protocol is to transfer files, not share files, so it is a hassle to modify the contents of files directly on the server through the client.
In 1987, Microsoft and Intel co-established the SMB (Server Messages Block, Server Message Block) protocol, which aims to solve the problem of sharing resources such as files or printers within a local area network, which also makes it easier to share files between multiple hosts. B y 1991, Tridgwell, who was still in college at the time, had developed the SMBServer service based on the SMB protocol to address file sharing between Linux and Windows systems. T his is an open source file sharing software that enables file sharing between Linux and Windows systems with a simple configuration. A t the time, Tridgwell wanted to register the software's name SMBServer as a trademark, but the trademark office rejected the application for SMB's meaningless characters. T hen Tridgwell looked through the dictionary and suddenly saw a Latin dance name, Samba, and the enthusiastic dance name happened to contain "SMB", so the name of the Samba service was born (see Figure 12-1). Samba service programs are now the best choice for sharing files between Linux and Windows systems.
Figure 12-1 The logo of the Samba service program
The configuration method of the Samba service program is similar to that of many of the services explained earlier, starting with the installation of the Samba service program through the Yum repository (the name of the Samba service program also happens to be the name of the package):
Install 1 Package
Total download size: 527 k
Installed size: 1.5 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : samba-4.1.1-31.el7.x86_64 1/1
Verifying : samba-4.1.1-31.el7.x86_64 1/1
Installed:
samba.x86_64 0:4.1.1-31.el7
Complete!
After installing, open the main profile of the Samba service program and find that there are as many as 320 lines! A re you scared? B ut a closer look reveals that most of them are actually lines of comment information that begin with a hashtag. There is Mr. Liu Wei in, certainly will not let everyone go to "dead gnaw" these content.
[root@linuxprobe ~]# cat /etc/samba/smb.conf
# options listed here, refer to the smb.conf(5) manual page. Samba has a huge
# number of configurable options, most of which are not shown in this example.
#
# The Official Samba 3.2.x HOWTO and Reference Guide contains step-by-step
# guides for installing, configuring, and using Samba:
# http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# The Samba-3 by Example guide has working examples for smb.conf. This guide is
# generated daily: http://www.samba.org/samba/docs/Samba-Guide.pdf
#
# In this file, lines starting with a semicolon (;) or a hash (#) are
# comments and are ignored. This file uses hashes to denote commentary and
# semicolons for parts of the file you may wish to configure.
#
# Note: Run the "testparm" command after modifying this file to check for basic
# syntax errors.
#
………………省略部分输出信息………………
Since there are too many comment lines in the main profile of the Samba service provider to analyze the important parameters inside, the main configuration file is changed to a name, then the cat command is used to read into the main configuration file, and then the -v parameter (reverse selection) is added after the grep command, removing all the hashtags (s) and semi-numbers (; A t the beginning of the comment information line, the remaining blank line can be represented and defiltered using the s$parameter, and finally the filtered available parameter information is overwritten to the original file name via a redirector override. The parameters of the remaining Samba service program after filtering are not complicated, and tables 12-1 list the parameters and the corresponding notes in order to make it easier for the reader to access the parameters.
The parameters and roles in the Samba service program in Table 12-1
The global # global parameters. Workgroup S MyGroup # Working Group Name Server String S Samba Server Version% V # server introduction information, parameter% V Shows SMB Version Number log file s /var/log/samba/log.%M # Defines the location and name of the log fileParameter% M is Visiting Host Name Max log size s 50 # definition of the maximum capacity of the log file is 50KB Security S User # security verification method, A Total of 4
#user:需验证来访主机提供的口令后才可以访问;提升了安全性
#server:使用独立的远程主机验证来访主机提供的口令(集中管理账户)
#domain:使用域控制器进行身份验证
passdb backend = tdbsam #定义用户后台的类型,共有3种
#smbpasswd:使用smbpasswd命令为系统用户设置Samba服务程序的密码
#tdbsam:创建数据库文件并使用pdbedit命令建立Samba服务程序的用户
#ldapsam:基于LDAP服务进行账户验证
load printers = yes #设置在Samba服务启动时是否共享打印机设备
cups options = raw #打印机的选项
[homes] #共享参数
comment = Home Directories #描述信息
browseable = no #指定共享信息是否在“网上邻居”中可见
writable = yes #定义是否可以执行写入操作,与“read only”相反
[printers] #打印机共享参数
comment = All Printers
path = /var/spool/samba #共享文件的实际路径(重要)。
browseable = no
guest ok = no #是否所有人可见,等同于"public"参数。
writable = no
printable = yes
[root@linuxprobe ~]# mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
[root@linuxprobe ~]# cat /etc/samba/smb.conf.bak | grep -v "#" | grep -v ";" | grep -v "^$" > /etc/samba/smb.conf
[root@linuxprobe ~]# cat /etc/samba/smb.conf