Remember Centos7 to build Samba service (file sharing service)

1. Basic information

       Samba is a free software that implements the SMB protocol on Linux and UNIX systems and consists of server and client programs. SMB (Server Messages Block, information service block) is a communication protocol for sharing files and printers on a local area network. It provides resource sharing services 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 the shared file system, printers and other resources on the server. By setting "NetBIOS over TCP/IP", Samba can not only share resources with hosts on the local area network, but also share resources with computers all over the world.

2. Environmental preparation

1. VMware version: VMware Workstation Pro15

2. System description

System: CentOS-7-x86_64-Minimal-1708

download link: 

 http://archive.kernel.org/centos-vault/7.4.1708/isos/x86_64/   

3. Install the virtual machine

Refer to the installation process:

https://blog.csdn.net/llwy1428/article/details/89328381

4. Tools: xshell5

Three, build deployment

1. Configure the virtual machine network, the virtual machine is connected to the Internet (and set a static IP)

Network card configuration can refer to:

https://blog.csdn.net/llwy1428/article/details/85058028

Set static IP

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33

Restart network service

[root@localhost ~]# systemctl restart network

2. Install basic tools

[root@localhost ~]# yum install -y vim samba samba-client

3. Turn off the firewall

Turn off the firewall, and set boot prohibition

关闭防火墙  : systemctl stop firewalld
查看状态    : systemctl status firewalld
开机禁用    : systemctl disable firewalld

4. Disable selinux

Temporary (valid under current connection)

[root@localhost ~]# setenforce 0

Permanent (effective after system restart)

[root@localhost ~]# vim /etc/selinux/config

5. View configuration files, backup configuration files

[root@localhost ~]# ll /etc/samba/
[root@localhost ~]# cp /etc/samba/smb.conf /etc/samba/smb.conf-bak

6. Add system users and set passwords for the added users

[root@localhost ~]# useradd smbtest
[root@localhost ~]# passwd smbtest

7. Set the password of the smb user (Samba management account)

[root@localhost ~]# smbpasswd -a smbtest

8. Create a shared directory

[root@localhost ~]# mkdir /opt/smbstore

9. Grant shared directory permissions as needed

[root@localhost ~]# chmod 755 /opt/smbstore/
或
[root@localhost ~]# chmod 777 /opt/smbstore/
或
[root@localhost ~]# chown smbtest:root /opt/smbstore/
或
[root@localhost ~]# chown smbtest:smbtest /opt/smbstore/
(权限分配原理:略)

10. Modify the configuration file

[root@localhost ~]# vim /etc/samba/smb.conf

11. Start the service, and set the startup, shutdown, and restart

#启动
[root@localhost ~]# systemctl start smb
#开机启动 
[root@localhost ~]# systemctl enable smb
#关闭  
[root@localhost ~]# systemctl stop smb
#重启  
[root@localhost ~]# systemctl restart smb

12. Viewing computer address

13, test

[root@localhost ~]# touch /opt/smbstore/test.txt

Shared folder view

 

So far, Centos7 has finished building Samba service!

 

Expansion:

1. Description of the
pdbedit command The pdbedit command is used to manage the account information database of the Samba service. The format is: "pdbedit [option] account" The
first time user information is written to the database, the -a parameter is required, and the user password is modified and deleted later. User and other operations are no longer needed.
 
pdbedit -L: view samba user
pdbedit -a -u user: add samba user
pdbedit -r -u user: modify samba user information
pdbedit -x -u user: delete samba user
 
samba service database password can also use smbpasswd command to operate
smbpasswd -a user: add a samba user
smbpasswd -d user: disable a samba user
smbpasswd -e user: restore a samba user
smbpasswd -x user: delete a samba user

 

Guess you like

Origin blog.csdn.net/llwy1428/article/details/105759959