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

<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.conf

to 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>
smbd

manages shared files and printers;

nmbd

handles 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/fstab

for automatic mounting at boot:

<code>//192.168.29.130/samba /smb cifs defaults,username=smb1,password=1234 0 0</code>
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

login 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.