Most Linux systems are the part of networks that also run Windows systems. Using Linux Samba servers, your Linux and Windows systems can share directories and printers. This is most used full situation where your clients are window native and you want to use the Linux security features

Install the Linux Samba package:

1.    Use yum to install the Samba package:

       yum-y install samba

Creating Samba Test Directory and Files

For this part of the procedure, you’ll use thesu- (switch user) command to work as root. Although it’s not best practice to do this regularly, there are times where it’s much more practical to work directly as root instead of trying to usesudoto do everything. This is one of those times.

You’re going to create a new directory containing three empty files which you’ll share using Samba.

2.    While logged on as root, create the new directory /smbdemowith the following command:

      mkdir/smbdemo

3.    Change the permissions on the new directory to 770 with the following command:

      chmod770 /smbdemo

4.    Navigate to the new directory with the following command:

      cd/smbdemo

5.    Add three empty files to the directory with the following command:

       touchfile1 file2 file3

6.    Use the following command to add a new Samba user (the new Samba user must be an existing Linux user or the command will fail):

      smbpasswd-a <username>

       For example, to add the user don, use the commandsmbpasswd-a don.

Creating the Samba Group

7.    Perform the following steps to create asmbusersgroup, change ownership of the /smbdemodirectory, and add a user to thesmbusersgroup:

       groupaddsmbusers

       chown:smbusers/smbdemo

       usermod -G smbusers don

Edit the Samba configuration file:

#vi/etc/samba/smb.conf

Ansmb.conffile is divided into several sections.the[global] section, which is the first section, has settings that apply to the entire Samba configuration. However, settings in the other sections in the configuration file may override the global settings. To begin with, set theworkgroup, which by default is set as “MYGROUP”:

workgroup= MYGROUP

Since most Windows networks are named WORKGROUP by default, the settings have to be changed as:

workgroup=workgroup

In the next step, a shared resource that will be accessible from the other systems on the Windows network has to be configured. This section has to be given a name by which it will be referred to when shared. For our example, let’s assume you would like share a directory on your Linux system locatedat/data/networkapplications.

You’ll need to entitle the entire section as [NetApps] as shown below in oursmb.conffile:

[NetApps]

path= /data/networkapplications

writeable= yes

browseable= yes

validusers = administrator

When a Windows user browses to the Linux Server, they’ll see a network share labeled “NetApps”.

This concludes the changes to the Samba configuration file.

Any user wanting to access any Samba shared resource must be configured as a Samba User and assigned a password. This is achieved using thesmbpasswdcommand as a root user. Since you have defined “administrator” as the user who is entitled to access the “/data/networkapplications” directory of the RHEL system, you have to add “administrator” as a Samba user.

Add “administrator” as a Windows user

# smbpasswd -aadministrator

The system will respond with

New SMB password: <Enter password>

Retype new SMB password: <Retype password>

It will also be necessary to add the same account as a simplelinuxuser, using the same password we used for the samba user:

#adduseradministrator

#passwdadministrator

Changing password for user administrator

New UNIX password: ********

Retype new UNIX password: ********

passwd: all authentication tokens updated successfully.

Now it is time to test the samba configuration file for any errors. For this you can use the command line tool “testparm” as root:

#testparm

Load smb config files from /etc/samba/smb.conf

Rlimit_max: rlimit_max (1024) below minimum Windows limit (16384)

Processing section “[NetApps]”

Loaded services file OK.

Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

STARTING SAMBA AND NETBIOS NAME SERVICE ON RHEL

The Samba and NetBiosNameserviceor NMB services have to be enabled and then started for them to take effect:

#systemctlenablesmb.service

#systemctlstartsmb.service

#systemctlenablenmb.service

#systemctlstartnmb.service

ACCESSING THE SAMBA SHARES FROM WINDOWS

Now that you have configured the Samba resources and the services are running, they can be tested for sharing from a Windows system. For this, open the Windows explorer and navigate to the Network page. Windows should show the RHEL system. If youdoubleclickon the RHEL icon, you will be prompted for the username and password. Theusernameto be entered now is “administrator” with the password that was assigned.

Again, if you are logged on your Windows workstation using the same account and password as that of the Samba service (e.gAdministrator), you will not be prompted for any authentication as the Windows operating system will automatically authenticate to the RHEL Samba service using these credentials.