Samba Setup Guide
Overview
Samba is an open-source software suite that provides file and print services to SMB/CIFS clients. It enables seamless file and printer sharing between Linux/Unix and Windows machines. This guide outlines the process of configuring Samba shares on Windows Server, Rocky Linux, and Ubuntu, as well as mounting these shares across the various platforms.
Environment Information
Below is the environment setup used for this configuration, including the server types and their respective IP addresses for reference:
- Windows SMB Server — Windows Server 2022 →
44.101.0.131
- Rocky Linux SMB Server — Rocky Linux 9.x →
44.101.2.131
- Ubuntu SMB Server — Ubuntu 24.04 →
44.101.4.131
1. Create Samba Shares
1.1 Create SMB Share on Windows Server
- Open Server Manager
- Click Manage → Add Roles and Features → Next → Next → Next → Next.
- Select SMB 1.0/CIFS File Sharing Support.
- Click Next → Install → Close.
Create SMB Folder
- Open File Explorer → Local Disk (C:) → Right-click → New Folder → Name it
var
. - Right-click
var
→ New Folder → Name itsmb
.
Create SMB Share
- Open Server Manager
- Click File and Storage Services → Shares → Tasks → New Share….
- Select SMB Share - Quick → Next.
- Browse to
/var/smb
, select the folder, and click Next. - Enter
winsmb
as the share name → Next → Next. - Click Customize Permissions… → Select Everyone → Edit → Full Control → OK → OK.
- Click Next → Create → Close.
1.2 Create Samba Share on Rocky Linux
Install Samba package:
sudo dnf install samba samba-client -y
Create Samba directory:
sudo mkdir -p /var/smb sudo chmod 777 /var/smb sudo chown nobody:nogroup /var/smb
Export Samba Share:
sudo vim /etc/samba/smb.conf
Press
i
to enter insert mode.Add the following lines:
[rockysmb] path = /var/smb browsable = yes writable = yes read only = no valid users = jack create mask = 0777 directory mask = 0777
Press
esc
→:wq
to save and quit.
Allow Samba through the firewall:
sudo firewall-cmd --permanent --add-service=samba sudo firewall-cmd --reload
Enable and start Samba service:
sudo systemctl enable smb sudo systemctl enable nmb sudo systemctl start smb sudo systemctl start nmb
Create Samba user:
sudo smbpasswd -a jack sudo smbpasswd -e jack
1.3 Create Samba Share on Ubuntu
Install Samba package:
sudo apt install samba -y
Create Samba directory:
sudo mkdir -p /var/smb sudo chmod 777 /var/smb sudo chown nobody:nogroup /var/smb
Export Samba Share:
sudo vim /etc/samba/smb.conf
Press
i
to enter insert mode.Add the following lines:
[ubtsmb] path = /var/smb browsable = yes writable = yes read only = no valid users = jack create mask = 0777 directory mask = 0777
Press
esc
→:wq
to save and quit.
Enable and start Samba service:
sudo systemctl enable smbd nmbd sudo systemctl start smbd nmbd
Create Samba user:
sudo smbpasswd -a jack sudo smbpasswd -e jack
2. Mount Samba Shares
2.1 Mount SMB Shares to Windows
Press Windows Key → Type
cmd
→ Open Command PromptEnter the following commands:
net use Z:\\44.101.2.131\rockysmb /user:jack [secure password] net use Y:\\44.101.4.131\ubtsmb /user:jack [secure password]
2.2 Mount Samba Shares on Rocky Linux
Install CIFS utilities:
sudo dnf install cifs-utils -y
Mount Windows Samba share:
sudo mkdir -p /mnt/windowssamba sudo mount -t cifs //44.101.0.131/winsmb /mnt/windowssamba -o username=Administrator,password=[Secure Password]
Mount Ubuntu Samba share:
sudo mkdir -p /mnt/ubtsamba sudo mount -t cifs //44.101.4.131/ubtsmb /mnt/ubtsamba -o username=jack,password=[Secure Password]
2.3 Mount Samba Shares on Ubuntu
Install CIFS utilities:
sudo apt install cifs-utils -y
Mount Windows Samba share:
sudo mkdir -p /mnt/windowssamba sudo mount -t cifs //44.101.0.131/winsmb /mnt/windowssamba -o username=Administrator,password=[Secure Password]
Mount Rocky Samba share:
sudo mkdir -p /mnt/rockysamba sudo mount -t cifs //44.101.2.131/rockysmb /mnt/rockysamba -o username=jack,password=[Secure Password]
3. Verification
To verify the Samba shares are mounted on Windows:
- Press Windows Key
- Type
File Explorer
→ Open it - Click This PC
- You should see the newly mapped drives representing the Samba shares.
To verify the Samba shares are mounted on Linux:
df -h | grep smb