Simple way to create and manage samba shares in RHEL 7

Simple way to Create and Manage Samba Shares in RHEL 7. We can also call this as CIFS (Common Internet File System) shares, Sharing the directories / Folders across the corporate network. Sharing the Directories / Folders from Linux to Windows and Windows to Linux wise versa we have to use SMB (samba) protocol. Samba is not only used for sharing directories, we can also use it for sharing printing services (printing server). I will explain you in detailed simple way to create and manage samba shares in RHEL 7.

Samba Server Profile

  • Packages Required: samba*
  • Port Number: 445
  • Daemon Name: smb
  • Config File Location: /etc/samba/smb.conf


  • Accessing CIFS shares across the multiple environments
  • Sharing Printer using SMB
  • Mount windows CIFS shares to Linux
  • Fully Secured shares using user authentication

Steps to Configure samba server

Install required Packages, Start & Enable Service, Create users and convert them as samba users, Create New Directory and Share the directory using SMB Service, Apply SELinux context and Open Firewall Ports.

Installation of Samba Server in RHEL 7

# yum install samba*

Enabling and Starting SMB services

To Enable the SMB and its dependant service NMB, we have to use below command

# systemctl enable smb
ln -s '/usr/lib/systemd/system/smb.service' '/etc/systemd/system/'
# systemctl enable nmb
ln -s '/usr/lib/systemd/system/nmb.service' '/etc/systemd/system/'

Starting SMB and NMB services, use below mentioned commands to start required services

# systemctl start nmb
# systemctl start smb
# systemctl status smb

Create Directory and apply SELinux Policy

If your SELinux is in enforcing mode then in RHEL 7 SELinux will allow any content to be access from other servers / clients. We have to apply SELinux context or keep SELinux in disabled / permissive mode.

before applying SELinux context

[root@desktop ~]# ls -ldZ /arkit_share
drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /arkit_share

After Applied SELinux context

# mkdir /arkit_share
# semanage fcontext -a -t samba_share_t "/arkit_share(/.*)?"
# restorecon -vRF /arkit_share
# ls -ldZ /arkit_share
drwxr-xr-x. root root system_u:object_r:samba_share_t:s0 /arkit_share

As shown above when you applied an SELinux context to particular directory you can see using ls -ldZ command. Change directory permissions for user

# ls -ld /arkit_share/
# chown arkit:root /arkit_share/
# ls -ld /arkit_share/

Create users and convert them as Samba Users

[root@desktop ~]# useradd arkit -s /sbin/noshell
[root@desktop ~]# smbpasswd -a arkit
New SMB password:
Retype new SMB password:
Added user arkit.

Create an normal user with restricted shell access then convert the same user as samba user. Below is the command to verify samba user is correctly created or Not

# pdbedit -L -v

Configuring samba / CIFS shares

Edit the configuration file to share directory using SMB / SAMBA server. /etc/samba/smb.conf

# vim /etc/samba/smb.conf
comment = CIFS share for windows clients
path = /arkit_share
browseable = yes
valid users = arkit
writable = yes

Save the file and Exit

  • [CIFS_Share] – Share Name
  • Path – Directory path which directory you would like to share 
  • Valid Users – User Name which user we are providing the access
  • writable – Providing Write permissions to share ( this permission will be overwritten by Actual Directory permissions)

Enabling Firewall to access from Client

# firewall-cmd --permanent --add-service=samba
# firewall-cmd --reload

Restart the Samba service to reflect changes

# systemctl restart smb.service
# systemctl restart nmb.service

Accessing from Client Side SMB /CIFS Share

Install required packages to access SMB share from Linux client

# yum install cifs-utils

 cifs-utils.x86_64 0:6.2-7.el7


Create directory for mount point

# mkdir /cifs
# mount -t cifs -o username=arkit // /cifs/
Password for arkit@// ******

That’s it about simple way to create and manage samba shares in RHEL 7. We will in next article how to auto mount CIFS /SMB share and adding entry into /etc/fstab file. Simple way to create and manage samba Simple way to create and manage samba Simple way to create and manage samba Simple way to create and manage samba Simple way to create and manage samba 

Please provide your valuable feedback on the same

Linux Tutorial

CIFS share multi user access

Thanks for your wonderful Support and Encouragement