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
<code>yum install samba samba-common -y</code>Samba 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:
<code>useradd smb1 -G centos
useradd smb2 -G centos
useradd smb3 -G centos
smbpasswd -a smb1
smbpasswd -a smb2
smbpasswd -a smb3
pdbedit -L</code>3 Create shared directory
<code>mkdir /samba
chgrp centos /samba
chmod 2770 /samba
ls -ld /samba</code>4 Edit Samba configuration
Modify
/etc/samba/smb.confto set the workgroup and security, then add a share definition:
<code>[global]
workgroup = MYGROUP
security = user
[samba]
comment = My samba share
path = /samba
browseable = yes
create mask = 0664
directory mask = 0775
write list = @centos</code>Check syntax with
testparm.
5 Start services
<code>systemctl start smb.service
systemctl start nmb.service</code> smbdmanages shared files and printers;
nmbdhandles NetBIOS name resolution.
Client Configuration
1 Install client packages
<code>yum install samba-client samba-common -y</code>2 Test login with smb1
<code>smbclient -L //192.168.29.130 -U smb1</code>3 Mount the share
<code>mkdir /smb
mount -t cifs //192.168.29.130/samba /smb -o username=smb1,password=1234
df -h /smb</code>Add an entry to
/etc/fstabfor automatic mounting at boot:
<code>//192.168.29.130/samba /smb cifs defaults,username=smb1,password=1234 0 0</code>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.