Step‑by‑Step Guide to Install and Configure Samba on CentOS 7
This tutorial walks through installing Samba on CentOS 7, creating system and Samba users, setting up a shared directory, configuring smb.conf, starting services, and then configuring a client to connect, mount, and auto‑mount the share using CIFS, providing a complete end‑to‑end solution.
Server Configuration
1 Install required packages
yum install samba samba-common -ySamba provides SMB services; samba-common contains shared configuration files.
2 Add Samba users
Create system users smb1, smb2, smb3 in the centos group, set their Samba passwords, and verify with pdbedit:
useradd smb1 -G centos
useradd smb2 -G centos
useradd smb3 -G centos
smbpasswd -a smb1
smbpasswd -a smb2
smbpasswd -a smb3
pdbedit -L3 Create shared directory
mkdir /samba
chgrp centos /samba
chmod 2770 /samba
ls -ld /samba4 Edit Samba configuration
Modify /etc/samba/smb.conf to set the workgroup and security, then add a share definition:
[global]
workgroup = MYGROUP
security = user
[samba]
comment = My samba share
path = /samba
browseable = yes
create mask = 0664
directory mask = 0775
write list = @centosCheck syntax with testparm.
5 Start services
systemctl start smb.service
systemctl start nmb.service smbdmanages shared files and printers; nmbd handles NetBIOS name resolution.
Client Configuration
1 Install client packages
yum install samba-client samba-common -y2 Test login with smb1
smbclient -L //192.168.29.130 -U smb13 Mount the share
mkdir /smb
mount -t cifs //192.168.29.130/samba /smb -o username=smb1,password=1234
df -h /smbAdd an entry to /etc/fstab for automatic mounting at boot:
//192.168.29.130/samba /smb cifs defaults,username=smb1,password=1234 0 0Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
