In this article, we will be covering setting up Samba on Red Hat Linux servers. This will allow sharing within Linux and Windows shares. Samba is used many times in mixed
Samba is an open-source software suite that runs on Unix/Linux based platforms but is able to communicate with Windows clients like a native application. So Samba is able to provide this service by employing the Common Internet File System (CIFS). At the heart of this CIFS is the Server Message Block (SMB) protocolLinuxandUbuntu
Initial steps in Setting up Samba on Red Hat Linux
We first need to setup our directory structure for our Samba share.
# mkdir -p /sambashare
# chmod 2770 /sambashare/
SELinux and creating the sales group
We need to setup our share for SELinux (you are running SELinux right?).
# semanage fcontext -at samba_share_t '/sambashare(/.*)?' # restorecon -vvFR /sambashare
Then we are going to set up our sales group.
# groupadd sales # chgrp sales /sambashare/
Creating samba only users
We will add some users, some will be part of our sales group, while others will not. The ones in the sales group will have access to this particular share we are setting up.
# useradd -s /sbin/nologin -G sales calvin # useradd -s /sbin/nologin -G sales daphne # useradd -s /sbin/nologin penny
Installing Samba server packages
Next we will install the samba server and client packages on our server.
# yum install samba samba-client
# smbpasswd -a calvin # smbpasswd -a penny
We will set each user to the password “redhat”.
Setting up the firewall
We need to open up the samba port to allow samba to work properly.
# firewall-cmd --permanent --add-service=samba # firewall-cmd --reload
Editing the smb.conf file
# vim /etc/samba/smb.conf
At the end of the conf
Enabling smb and nmb
We need to enable and start the samba services next.
# systemctl enable smb nmb # systemctl start smb nmb
Preparing the client for the samba share
Next, we switch over to the client to perform the required tasks to mount our share and be ready for use.
# mkdir -p /mnt/sales
We then need to edit the /etc/fstab file.
# vim /etc/fstab
The server we are connecting to is //code and the share name as you recall is
We need to remember to install the gifs-utils and create our multiuser.txt file before attempting to mount this volume however.
We need to install the
# yum install cifs-utils.x86_64
Next, we need to set up that text file which will hold the credentials for our samba share.
# vim /root/smb-multiuser.txt
Inside the text file, add username=calvin and password=redhat
Installing the samba client package
# yum install samba-client
Once this is finished, we can mount our share and verify.
# mount -a # df -h
As you can see, our samba mount is now available. It shows the total size of 22G with 19G available.