This is the 20th day of my participation in the August More Text Challenge

Introduction of the Samba

Samba is open source software based on the SMB protocol (ServerMessage Block). Samba can also be a trademark of the SMB protocol. SMB is a protocol for sharing resources such as files and printers on Linux and UNIX systems. It is based on the Client\Server protocol. The Client can access shared resources on the Server through THE SMB. When Windows is a Client and CentOS is a server, Samba enables Windows to access Linux resources and realize data interaction between the two systems.

Configuration file for Samba

/etc/samba/smb.conf: This is the main samba configuration file, which is basically the only one, and the configuration file itself is very detailed. The main Settings include server global Settings, such as workgroup, NetBIOS name and password level, and shared directory Settings, such as the actual directory, shared resource name and permissions.

/etc/samba/lmhosts: The NetBIOS name of the earlier lmhosts requires additional Settings. Therefore, the IP file corresponding to the NetBIOS name of the LMhosts is required. In fact it’s a bit like /etc/hosts functionality! The host name of lmhosts is NetBIOS name. Not to be confused with /etc/hosts! Currently Samba defaults to using your native hostname as your NetBIOS name, so it doesn’t matter if this file is not set.

/etc/samba/smbusers: The administrator and visitor account names are different on Windows and Linux, for example: Administrator (Windows) and root(Linux). You can use this file to set the account relationship between the two

Var/lib/samba/private /{passdb. TDB,secrets.tdb} : database files used to manage the samba user accounts and passwords

The installation of the Samba

The system I use is CentOS, and the installation software generally uses the Yum (Yellow Dog Updater, Modified) package manager. Yum is based on THE RPM package management, which can automatically download the RPM package from the specified server and install it, and can automatically handle the dependency relationship. In addition, all dependent software packages are installed at one time without tedious downloading and installation.

yum -y install samba
Copy the code

Samba instance

mkdir /share Create a shared directory
vim /etc/samba/smb.conf
Copy the code

Parameters of the configuration file:

Comment = Any character string Comment is the description of the share. It can be any character string. Path = Shared directory path Description: Path specifies the path of the shared directory. You can replace the Unix user and client Netbios names in the path with macros such as %u and %m, which are used primarily for the [homes] shared domain. For example, if we do not plan to use the home segment as the client's share, but create a directory under /home/share/ for each Linux user with his username as his share directory, then path can be written as: path =/home/share/%u; . When a user connects to the share, the specific path is replaced by his or her username. Note that the username path must exist; otherwise, the client will not find the network path when accessing the share. Similarly, if we were to directory each machine on the network that has access to Samba not by users but by clients, and create a path with its NetBIOS name as a shared resource between the different machines, we could write: path =/home/Share / % m. Browseable = yes/no Description: Browseable specifies whether the share can be browsed. Writable = yes/no Description: Writable specifies whether the share path is writable. Available = yes/no Description: Available Specifies whether the shared resource is available. Admin Users = Administrator of the share Description: The admin users command is used to specify the administrator of the share who has full control over the share. The samba3.0If the user authentication mode is set to Security =share, this parameter is invalid. For example, admin Users = David, sandy (multiple users are separated by commas). Valid users = Users allowed to access the share Description: Valid Users specifies users allowed to access the share. For example, valid Users = David, @dave, @tech (Multiple users or groups are separated by commas (,). If you want to join a group, use @group name.) Invalid Users = Users who are not allowed to access the share Description: Invalid Users is used to specify users who are not allowed to access the share. For example, invalid Users = root, @bob (multiple users or groups are separated by commas.) Write List = Allowed users to write files to the share Description: The write list is used to specify the users who can write files to the share. For example, write list = David, @dave public = yes/no Note: public specifies whether the share can be accessed by guest accounts. Guest OK = yes/no Note: The meaning is the same as public.Copy the code

Creating an SMB User

[root@yxb ~]# useradd smb 
[root@yxb ~]# smbpasswd -a smb
New SMB password:
Retype new SMB password:
Added user smb.
Copy the code

Restart the service

systemctl restart smb
Copy the code

Win +R open run type \\IP address

Enter the password for the user name you just created

Access successful!

Finally said a pit, into the folder will prompt no permission

This is due to Selinux, which can be disabled

setenforce 0
Copy the code

The resources

Install and configure the Samba server.

Linux Samba configuration and use

Recommended reading

Linux Shell programming basics!

Linux Sudo and Sudoers

Linux TCP kernel parameter Settings and tuning (details)!

Operation and maintenance must know Linux RAID details!

Linux Service Management!

Server Hardware Guide!