Install & Configure Samba Server on Linux (RHEL7 / CentOS7)

This post will show you How to Install & Configure Samba Server on Linux (RHEL7 / CentOS7).

If you are interested in learning, Request you to go through the below recommended tutorial.

Topics involved:
What is Samba?
Uses of Samba?
Samba requirements
How to install the Samba server packages?
How to configure Samba server?
How to start the samba service?
How to add a user to samba?
How to verify the samba share access?

Install & Configure Samba Server on Linux
 

What is Samba?

Samba provides a stable and highly compatible file and print sharing service that allows a Linux node to act as a client, a member server, or even a Primary Domain Controller (PDC) or a member of an Active Directory (AD) service on Microsoft-based networks. Samba interacts with Microsoft’s CIFS built on the Server Message Block (SMB) protocol.

Uses of Samba?

1. As a File Server like NFS to share the files but across OS (linux to windows).
2. As a WINS [Windows Internet Name Server] or NBNS server
3. As a PDC [SAM – Security Access Module]
4. As a Print Server using CUPS

Samba details

Package : samba*
Port no : 137,138,139
Script : /etc/init.d/smb
Service name : smb
Daemon : smbd
Configuration file : /etc/samba/smb.conf

Use the following instructions to install and configure the SAMBA Server and Client on Linux (Centos7/RHEL7).

Lab Setup:
RHEL7 or CentOS7 installed server – 2 Nos.
Network enabled
Firewall and selinux are disabled
Hostnames : linux1 (server) and linux2 (client)

Prerequisites:
1. Make sure both server Linux1(192.168.2.61) and client(192.168.2.62) are reachable.
2. Make an entry of each host in /etc/hosts for name resolution or Configure it in DNS to resolve the IP, if you use server name instead of IP address. Read also how to configure DNS Server on RHEL7 But we use IP Address for in this article.

Server end configuration

Login into the server Linux1 (192.168.2.61) and do the following steps to install and configure Samba Server.

Install the Samba server packages

Install the appropriate Samba packages “samba*” using yum to avoid dependencies issue. if yum is not configured, please refer the link Yum Configuration on Linux.

[[email protected] ~]# yum -y install samba*

Configure the Samba server

Samba server main configuration file name is smb.conf which is located in /etc/samba/. It has many directives which can be used for each purpose.

Assume that, we are going to configure the samba server to share the /mnt directory. Lets edit the main configuration file.

[[email protected] ~]# vi /etc/samba/smb.conf

Just go to the last line and append the below entries into the file.

[mnt]
comment = Samba test share
path = /mnt

Note : By default samba doesn’t allow to write any data. If you want the share to be write-able mode, add the below directive as “yes” and change the file permission (chmod 777 /mnt) to write-able. If file permission is not set to write, samba will allow to write the data, but linux file permission wont allow to write, so you will face an issue as permission denied.

writeable = yes

Finally it should looks like below

[mnt]
comment = Samba test share
path = /mnt
writeable = yes

Verify the configuration file
Always after changing the configuration file, use the command “testparm” to check the changes for any syntax errors.

[[email protected] ~]# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section “[homes]”
Processing section “[mnt]”
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
# Global parameters
[global]
workgroup = MYGROUP
server string = Samba Server Version %v
security = USER
log file = /var/log/samba/log.%m
max log size = 50
idmap config * : backend = tdb
[homes]
comment = Home Directories
read only = No
browseable = No
[mnt]
comment = Samba test share
path = /mnt
read only = No

If you dont have any syntax errors, you will get the output as “Loaded services file OK.” If you get error as unknown parameter, please use the correct word.

Enable and Start the Samba service

[[email protected] ~]# systemctl start smb
[[email protected] ~]# systemctl enable smb

Ensure the samba port listening or not.

[[email protected] ~]# netstat -lt | grep netbios

Add a valid linux user to samba

Samba need a additional password to provide the access as well as that user should be a valid linux user, which means user should be exist in the server. if not, create a new user using useradd command and add the user to the samba as below. It will prompt to enter the additional new password specially for samba.

[[email protected] ~]# smbpasswd -a user1
New SMB password:
Retype new SMB password:
Added user user1.

Verify the access locally and remotely

Always first check the access locally and finally check from client end. It will be easy to troubleshoot where the problem exists when the problem occurs to access the samba shares locally or over the network.

Verify the access from samba server end

Use the below samba client utility (smbclient) in which specify the samba server address (-L 192.168.2.61) and user (-U user1). It will prompt to enter the password of the user added to the samba.

[[email protected] ~]# smbclient -L 192.168.2.61 -U user1
Enter user1’s password:
Domain=[MYGROUP] OS=[Windows 6.1] Server=[Samba 4.2.10]
Sharename       Type      Comment
———       —-      ——-
mnt             Disk      Samba test share
IPC$            IPC       IPC Service (Samba Server Version 4.2.10)
user1           Disk      Home Directories
Domain=[MYGROUP] OS=[Windows 6.1] Server=[Samba 4.2.10]
Server               Comment
———            ——-
Workgroup            Master
———            ——-
WORKGROUP            LEARNITGUIDE

If we get the output as above, then we can access the samba server successfully.

Verify the access from samba client

Execute the same command from the client to ensure the same is working from network also. We should get the same output as we got locally.

[[email protected] ~]# smbclient -L 192.168.2.61 -U user1

That’s all the installation and configuration of Samba server on Linux (RHEL7 / CentOS7).

Hope this post helped you to Install & Configure Samba Server on Linux (RHEL7 / CentOS7).

Related Content on Linux might be useful to you to improve your Linux Skills.

 

 

Keep practicing and have fun. Leave your comments if any.

 
 

Support Us: Share with your friends and groups.

 
 

Stay connected with us on social networking sites, Thank you.

extend a filesystem online hp-ux 11, extend a file system offline, Extend file system without using online how to configure samba server, configure samba Server on RHEL7, configure samba server on linux, install samba server in centos7, samba server configuration