Operations 6 min read

How to Set Up Samba Server and Client on CentOS: Step-by-Step Guide

This tutorial walks you through installing Samba on CentOS, creating Samba users, configuring a shared directory, editing the smb.conf file, starting services, and finally setting up a client to connect and mount the share, complete with command examples.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Set Up Samba Server and Client on CentOS: Step-by-Step Guide

Samba is free software that bridges UNIX-like operating systems and Windows via the SMB/CIFS protocol, allowing file and printer sharing and even acting as a domain controller.

Server Configuration

1 Install required packages

# yum install samba samba-common -y

The samba package provides the SMB services, while samba-common supplies shared configuration files and utilities.

2 Add Samba users

Create system users that will become Samba users and add them to the centos group.

# useradd smb1 -G centos
# useradd smb2 -G centos
# useradd smb3 -G centos

Set passwords for the Samba accounts.

# smbpasswd -a smb1
# smbpasswd -a smb2
# smbpasswd -a smb3

List existing Samba users.

# pdbedit -L

3 Create shared directory

# mkdir /samba
# chgrp centos /samba/
# chmod 2770 /samba/

The directory now belongs to the centos group with appropriate permissions.

4 Edit Samba configuration

# vim /etc/samba/smb.conf
[global]
    workgroup = MYGROUP   # workgroup name
    security = user       # require user authentication

[samba]
    comment = My samba share
    path = /samba
    browseable = yes
    create mask = 0664
    directory mask = 0775
    write list = @centos

Check the configuration syntax.

# testparm

5 Start Samba services

# systemctl start smb.service
# systemctl start nmb.service
smbd

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

Client Configuration

1 Install client packages

# yum install samba-client samba-common -y

The client provides tools such as mount.cifs for mounting SMB shares.

2 Test connection with a Samba user

# smbclient -L //192.168.29.130 -U smb1

The command lists available shares, confirming connectivity.

3 Mount the share

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

The share is now accessible at /smb.

4 Configure automatic mount at boot

# vim /etc/fstab
//192.168.29.130/samba /smb cifs defaults,username=smb1,password=1234 0 0

After saving, the share will be mounted automatically on system startup.

Samba configuration illustration
Samba configuration illustration
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.

CentOSLinux Administrationnetwork servicesSMBfile sharingSamba
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

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.