Complete steps to use samba to share folders in CentOS 7

Complete steps to use samba to share folders in CentOS 7

Preface

Samba is a free software that implements the SMB protocol on Linux systems, consisting of server and client programs. SMB (Server Messages Block) is a communication protocol for sharing files and printers on a local area network. It provides sharing services for resources such as files and printers between different computers in the local area network. The SMB protocol is a client/server protocol through which the client can access shared file systems, printers, and other resources on the server.

For example, I want to share the folder /home/samba with other computers.

Install samba

yum install -y samba

Create samba user

useradd samba

Modify samba configuration

The configuration file is /etc/samba/smb.conf

# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.

[global]
 workgroup = SAMBA #samba workgroup, set to Windows workgroup security = user #security options, can be share|user|server|domain, security level increases passdb backend = tdbsam
 printing = cups
 printcap name = cups
 load printers = yes
 cups options = raw

[homes] #By default, the user's home directory will be shared. This is unsafe. You can comment it out with comment = Home Directories
 valid users = %S, %D%w%S
 browseable = No
 read only = No
 inherit acls = Yes

[printers] #Printer sharing comment = All Printers
 path = /var/tmp
 printable = Yes
 create mask = 0600
 browseable = No

[print$]
 comment = Printer Drivers
 path = /var/lib/samba/drivers
 write list = root
 create mask = 0664
 directory mask = 0775

[rootdir] #Custom shared folder comment = SambaRoot
 path = /home/samba/ #Shared path read only = No

Note: remove the comment after # when modifying it yourself

Adding Samba Users

Add the samba user you just created and set the corresponding password according to the prompts

smbpasswd -a samba

The smbpasswd command is used to maintain the user accounts of the Samba server, as follows:

// Add Samba user account # smbpasswd -a sambauser 
// Disable the Samba user account # smbpasswd -d sambauser
// Enable Samba user account # smbpasswd -e sambauser
// Delete Samba user account # smbpasswd -x sambauser

Start Samba Service

Start, stop, and view related commands

systemctl start smb
systemctl stop smb
systemctl status smb

Windows access shared directories

Simply press Win + R, enter \192.168.1.20 in the run interface, which is your Linux host address. The username and password input interface will pop up. Enter the username and password you just set to access it.

Frequently asked questions

If you access a shared directory in Linux from Windows, you will get a message saying you do not have permission.

  1. Make sure the Linux firewall is turned off or open the shared directory permissions
  2. Make sure that the Samba server configuration file smb.conf is set correctly.
  3. Make sure setlinux is turned off, you can use the setenforce 0 command to execute; by default SELinux prohibits writing to the shared directory on the Samba server on the network

Samb also needs to open the following four ports

UDP 137, UDP 138, TCP 139, TCP 445

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • Distributed deployment of pyspider in centos7
  • Construction and development of Hadoop distributed environment based on CentOS
  • Complete steps to build NFS file sharing storage service in CentOS 7
  • How to move mysql5.7.19 data storage location in Centos7
  • A brief analysis of how to access Windows 10 host folders from CentOS 8 virtual machines
  • Detailed tutorial for installing nginx on centos8 (picture and text)
  • How to add Nginx to system services in CentOS7
  • Centos7 configuration fastdfs and nginx distributed file storage system implementation process analysis

<<:  Ubuntu 18.04 MySQL 8.0 installation and configuration method graphic tutorial

>>:  How to print highlighted code in nodejs console

Recommend

CSS style does not work (the most complete solution summary in history)

When we write pages, we sometimes find that the C...

React+TypeScript project construction case explanation

React project building can be very simple, but if...

Understanding of the synchronous or asynchronous problem of setState in React

Table of contents 1. Is setState synchronous? asy...

How to implement data persistence using the vuex third-party package

Purpose: Allow the state data managed in vuex to ...

Search optimization knowledge to pay attention to in web design

1. Link layout of the new site homepage 1. The loc...

How to add a column to a large MySQL table

The question is referenced from: https://www.zhih...

About VSCode formatting JS automatically adding or removing semicolons

introduction It is okay to add or not add a semic...

MySQL 5.6 compressed package installation method

There are two installation methods for MySQL: msi...

Detailed explanation of Angular routing sub-routes

Table of contents 1. Sub-route syntax 2. Examples...

A brief discussion on the design of Tomcat multi-layer container

Table of contents Container Hierarchy The process...

Basic ideas for finding errors in Web front-end development

WEB development mainly consists of two interactio...

Detailed explanation of how to connect Java to Mysql version 8.0.18

Regarding the connection method between Java and ...

Alpine Docker image font problem solving operations

1. Run fonts, open the font folder, and find the ...