【Ubuntu】Ubuntu22.04 to build Samba service

00. Catalog

01. Overview of Samba

In 1987, Microsoft Corporation and Intel Corporation jointly developed the SMB (Server Messages Block, Server Message Block) protocol, which aims to solve the problem of sharing resources such as files or printers in the LAN, which also makes it easier to share files among multiple hosts. It's getting easier and easier. In 1991, Tridgwell, who was still in college at the time, developed the SMBServer service program based on the SMB protocol in order to solve the file sharing problem between the Linux system and the Windows system . This is an open source file sharing software, which can realize file sharing between Linux system and Windows system after simple configuration. At that time, Tridgwell wanted to register the name of the software, SMBServer, as a trademark, but the application was rejected by the Trademark Office on the grounds that "SMB is a meaningless character". Later, Tridgwell kept looking through the dictionary, and suddenly saw the name of a Latin dance—Samba, and this passionate dance name happened to contain "SMB", so the name of the Samba service program was born. The Samba service program has now become the best choice for sharing files between Linux systems and Windows systems.

insert image description here

02. Samba suite

samba : This package mainly includes SAMBA's main daemon files (smbd and nmbd), SAMBA's document files (document), and other SAMBA-related logrotate configuration files and boot default option files, etc.;

samba-common : This suite mainly provides the main configuration file of SAMBA (smb.conf), the test program of smb.conf syntax verification (testparm), etc.;

samba-client : This package provides the tool commands needed when Linux is used as the SAMBA client, such as mounting the executable file smbmount in the SAMBA file format and so on.

03. Samba configuration file

In earlier versions, SAMBA configuration files were placed directly under /etc, and in later versions, all configuration files were placed under /etc/samba (some distributions were placed under /etc/smb and some It is /etc/samba.d, use locate to search!). Several important configuration files under /etc/samba are:

/etc/samba/smb.conf : This is the main configuration file of SAMBA! Among the simpler setups, this is the only one! In addition, this file itself contains quite a lot of instructions, so before setting, please use vi to read this file in detail! The main settings of this configuration file are divided into two parts, which are [global], which sets the host function, and the attribute settings of each shared directory.

/etc/samba/lmhosts : The main purpose of this file is to correspond to the NetBIOS name and the IP of the host name. In fact, it is a bit like the function of /etc/hosts! It's just that the host name corresponding to lmhosts is NetBIOS name! Not to be confused with /etc/hosts! As the functions of SAMBA are becoming more and more powerful, usually as soon as you start SAMBA, it can capture the information of the NetBIOS name corresponding to the IP of the relevant computer in the LAN. Therefore, this file usually does not need to be set.

/etc/samba/smbpasswd : This file does not exist by default. It is the SAMBA default user password correspondence table. When the configured SAMBA server is relatively strict and requires the user to enter the account number and password to log in, the user's password is placed here by default (of course, you can set the password in smb.conf by yourself) place and password file name, however, we use the default state to illustrate here). It should be noted that this file contains the user's password, so of course, more attention should be paid to the permissions! The owner of this file needs to be root, and the permission is set to 600.

04. Samba installation

4.1 Update software sources

deng@local:~$ sudo apt update

4.2 Install Samba service

deng@local:~$ sudo apt install samba 

05. Samba configuration

5.1 Open the samba configuration file

deng@local:~$ sudo gedit /etc/samba/smb.conf 

5.2 Add something in /etc/samba/smb.conf

[Home]
	comment = Home Share
	path = /home/deng
	public = yes
	browseable = yes
	read only = no
	valid users = deng
	create mask = 0777
	directory mask = 0777 
	force user = deng
	force group = deng
	available = yes

5.3 Restart the samba service

deng@local:~$ sudo systemctl restart smbd

5.4 Set Samba username and password

deng@local:~$ sudo smbpasswd -a deng
New SMB password:
Retype new SMB password:
Added user deng.
deng@local:~$ 

06. Samba test

6.1 Press Win + R in Windows system
insert image description here

6.2 Enter the IP of the Samba service, then click OK
insert image description here

6.3 Enter the samba username and password
insert image description here

07. Technical exchange

Interested enthusiasts in IoT, embedded, C++, C direction, etc. can add WX to communicate together. Click the private message on the homepage to add blogger WeChat.

08. Appendix

Guess you like

Origin blog.csdn.net/dengjin20104042056/article/details/131747739