Operations 6 min read

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.

Raymond Ops
Raymond Ops
Raymond Ops
Step‑by‑Step Guide to Install and Configure Samba on CentOS 7

Server Configuration

1 Install required packages

yum install samba samba-common -y

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:

useradd smb1 -G centos
useradd smb2 -G centos
useradd smb3 -G centos
smbpasswd -a smb1
smbpasswd -a smb2
smbpasswd -a smb3
pdbedit -L

3 Create shared directory

mkdir /samba
chgrp centos /samba
chmod 2770 /samba
ls -ld /samba

4 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 = @centos

Check syntax with testparm.

5 Start services

systemctl start smb.service
systemctl start nmb.service
smbd

manages shared files and printers; nmbd handles NetBIOS name resolution.

Client Configuration

1 Install client packages

yum install samba-client samba-common -y

2 Test login with smb1

smbclient -L //192.168.29.130 -U smb1

3 Mount the share

mkdir /smb
mount -t cifs //192.168.29.130/samba /smb -o username=smb1,password=1234
df -h /smb

Add an entry to /etc/fstab for automatic mounting at boot:

//192.168.29.130/samba /smb cifs defaults,username=smb1,password=1234 0 0
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxSystem AdministrationCentOSSMBfile sharingSambaCIFS
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.