#!/bin/bash ######################################## File Description ######################################## # Creation time:2020-05-30 # Project:07 # Task: 06 # Execute example:bash record-shell-x-x.sh # Detailed description: # About:http://linux.book.51xueweb.cn ################################################################################################## # reback start yum remove samba samba-client -y # reback end #***************reader shell start*************** #---------------Install samba、samba-client--------------- # Install samba、samba-client yum install -y samba samba-client # Start smb、nmb systemctl start smb nmb # Look smb、nmb systemctl status smb nmb # Confige smb、nmb systemctl enable smb nmb systemctl is-enabled smb systemctl is-enabled nmb # Confige Firewalld systemctl stop firewalld # Confige SELinux setenforce 0 #---------------Creat folder--------------- # Creat folder mkdir -p /srv/smbfile/smbshare mkdir -p /srv/smbfile/smbwork mkdir -p /srv/smbfile/smbpublic # Give folder permission chmod 777 -R /srv/smbfile/smbshare chmod 777 -R /srv/smbfile/smbwork chmod 777 -R /srv/smbfile/smbpublic # Look /srv/smbfile ls -l /srv/smbfile #---------------Creat users--------------- useradd smbshareuser -s /sbin/nologin useradd smbworkuser -s /sbin/nologin # Set the SMB password of smbshareuser ( echo smbshareuser@pwd ; echo smbshareuser@pwd ) | smbpasswd -s -a smbshareuser; # Set the SMB password of smbworkuser ( echo smbworkuser@pwd ; echo smbworkuser@pwd ) | smbpasswd -s -a smbworkuser; #---------------configure samba--------------- # Backup configuration file cp /etc/samba/smb.conf /etc/samba/smb.conf.bak1 # Configure samba cat > /etc/samba/smb.conf << EOF [global] workgroup = Project7 server string = Welcome to samba server version %v netbios name = Project7 security = user interfaces = enp0s3 hosts allow = 10.10.2.0/24 max connections = 10 log file = /var/log/samba/samba-log.%m max log size = 10240 passdb backend = tdbsam [smbpublic] comment = workgroup public share disk path = /srv/smbfile/smbpublic admin users = smbworkuser public = yes browseable = yes readonly = yes guest ok = yes [smbshare] comment = workgroup open share disk path = /srv/smbfile/smbshare admin users = smbshareuser public = no browseable = yes valid users = smbshareuser, smbworkuser readonly = no writable = yes write list = smbshareuser, smbworkuser create mask = 0777 directory mask = 0777 force directory mode = 0777 force create mode = 0777 [smbwork] comment = workgroup work share disk path = /srv/smbfile/smbwork admin users = smbworkuser public = no browseable = yes valid users = smbshareuser, smbworkuser readonly = no read list = smbshareuser writable = yes write list = smbworkuser create mask = 0777 directory mask = 0777 force directory mode = 0777 force create mode = 0777 EOF #---------------Reload Samba--------------- # Reload smb、nmb systemctl reload smb nmb #***************reader shell end***************