Lesson 3 | Installing and configuring a Samba server |
Objective | Install and configure a Samba server. |
Installing and Configuring a Samba Server
You can install Samba either automatically or manually using Red Hat Linux. During installation, select DOS/Windows Connectivity to automatically install the Samba
RPMs[1] .
If you do not select this option, you can install them manually with the following RPMs:
samba-(version).(arch).rpm
samba-client-(version).(arch).rpm
samba-common-(version).(arch).rpm
You will need to replace (version)
and (arch)
with the latest version and architecture, respectively, from your Red Hat Linux CD-ROM. For example, the 2.0.7 Intel RPMs are samba-2.0.7.i386.rpm
, samba-client-2.0.7.i386.rpm
, and samba-common-2.0.7.i386.rpm
.
Configuring Samba
Steps for installing and Configuring Samba Server on Red Hat Linux
To install and configure a Samba server on Red Hat Enterprise Linux (RHEL) 9.2, follow these steps:
- Install Samba Packages
- Open a terminal and ensure your system is updated:
sudo dnf update -y
- Install the Samba server package:
sudo dnf install samba samba-common samba-client -y
- Start and Enable Samba Services
- Enable and start the Samba services:
sudo systemctl enable smb
sudo systemctl enable nmb
sudo systemctl start smb
sudo systemctl start nmb
- Verify the services are running:
sudo systemctl status smb
sudo systemctl status nmb
- Configure the Samba Configuration File
- Open the Samba configuration file with a text editor:
sudo nano /etc/samba/smb.conf
- Make necessary modifications for your Samba setup. For example, to share a directory (`/srv/samba/share`):
Add this to the configuration file:
[global]
workgroup = WORKGROUP
security = user
map to guest = Bad User
dns proxy = no
[ShareName]
path = /srv/samba/share
browsable = yes
writable = yes
guest ok = yes
read only = no
- Save and close the file (`CTRL+O`, `CTRL+X`).
- Create the Shared Directory
- Create the shared directory:
sudo mkdir -p /srv/samba/share
- Set appropriate permissions:
sudo chmod -R 0777 /srv/samba/share
sudo chown -R nobody:nobody /srv/samba/share
- Add a Samba User
- If you want authenticated access, add a Linux user:
sudo useradd -M -s /sbin/nologin sambauser
- Set the Samba password for the user:
sudo smbpasswd -a sambauser
- Enable the user:
sudo smbpasswd -e sambauser
- Adjust Firewall Settings
- Allow Samba services through the firewall:
sudo firewall-cmd --permanent --add-service=samba
sudo firewall-cmd --reload
- Test the Samba Configuration
- Test the Samba configuration for errors:
sudo testparm
- If no errors are reported, proceed to the next step.
- Access the Samba Share
- From a Windows Client
- Open File Explorer and enter: `\\\ShareName`
- Provide authentication if required.
- From a Linux Client
- Install Samba client tools:
sudo dnf install cifs-utils -y
- Mount the share:
sudo mount -t cifs -o username=sambauser,password= //Samba_Server_IP/ShareName /mnt
- Monitor Samba Logs
- To troubleshoot issues, check Samba logs:
sudo tail -f /var/log/samba/log.smbd
sudo tail -f /var/log/samba/log.nmbd
Additional Notes:
- Replace `` with the IP address of your Samba server.
- Always use strong passwords for Samba users.
- Consider restricting access to the Samba share by specifying allowed IP ranges in the `[ShareName]` section:
hosts allow = 192.168.1.0/24
Some configuration options can appear in both the global and the specific share sections. When options appear in the global section, the option affects the entire program. When options appear in a specific share section, the option affects only that shared resource. Because Samba provides many configuration choices, you should read the entire smb.conf man page before modifying the default configuration. In the next lesson, you will learn about shares, homes, and printing.
[1]
RPM: An acronym for Red Hat Package Manager, RPMS is a standard source and binary distribution format.
