+
โˆ‚
jenkins
+
cassandra
+
fauna
+
weaviate
+
+
gitlab
+
vb
+
+
netlify
py
gin
packer
haiku
micronaut
+
c#
+
+
+
+
+
ada
+
+
+
+
+
pnpm
echo
+
pandas
webstorm
+
ts
jasmine
+
0x
docker
py
pytest
tls
spacy
vault
fiber
+
http
suse
+
xml
+
+
eclipse
+
bsd
+
prometheus
::
yarn
+
gin
circle
https
bun
+
+
+
matplotlib
+
+
+
notepad++
fedora
tf
+
+
+
mongo
+
+
jax
gcp
+
Back to Blog
AlmaLinux Samba File Sharing

๐Ÿ“‚ Setting Up Samba File Sharing on AlmaLinux: Share Files Like a Pro Across Your Network

Published Aug 22, 2025

Learn how to set up and configure Samba file sharing on AlmaLinux for seamless file sharing between Linux and Windows systems. Complete guide with security, permissions, and troubleshooting!

5 min read
0 views
Table of Contents

๐Ÿ“‚ Setting Up Samba File Sharing on AlmaLinux: Share Files Like a Pro Across Your Network

Hey there, network wizard! ๐Ÿง™โ€โ™‚๏ธ Ever wished you could easily share files between your Linux and Windows computers? Or maybe you want to create a central file server for your home or office? Well, todayโ€™s your lucky day! Weโ€™re going to set up Samba on AlmaLinux, and trust me, itโ€™s going to be way easier than you think!

I still remember the first time I needed to share files between my Linux server and Windows laptop - I thought Iโ€™d need some expensive software or complicated setup. Then I discovered Samba, and it completely changed how I manage files across my network! ๐ŸŒŸ By the end of this guide, youโ€™ll be sharing files like a networking pro!

๐Ÿค” Why is Samba Important?

Samba is your bridge between different operating systems! ๐ŸŒ‰ Let me show you why itโ€™s absolutely essential:

The Magic of Samba:

  • ๐Ÿ–ฅ๏ธ Cross-Platform Sharing - Works with Windows, Mac, and Linux seamlessly
  • ๐Ÿ  Home Media Server - Share movies, music, and photos with all devices
  • ๐Ÿ’ผ Office File Server - Perfect for small business file sharing
  • ๐Ÿ” Secure Access Control - Manage who sees what with precision
  • ๐Ÿ’พ Centralized Storage - One place for all your important files
  • ๐Ÿš€ Fast Network Transfers - Optimized for local network speed
  • ๐Ÿ“ฑ Mobile Device Access - Many apps support SMB/CIFS protocol
  • ๐ŸŽฎ Gaming Storage - Share game files and saves across devices

๐ŸŽฏ What You Need

Before we start sharing files, letโ€™s check our equipment! ๐ŸŽฏ Hereโ€™s what youโ€™ll need:

Prerequisites:

  • โœ… AlmaLinux 8 or 9 installed and running
  • โœ… Root or sudo access (admin powers required!)
  • โœ… Network connection (local network is fine)
  • โœ… Basic understanding of file permissions
  • โœ… At least 1GB free disk space for shared files
  • โœ… Another computer to test connections
  • โœ… About 45 minutes of your time
  • โœ… Enthusiasm for network file sharing! ๐ŸŽ‰

๐Ÿ“ Step 1: Installing and Preparing Samba

Letโ€™s get Samba installed and ready to rock! ๐Ÿš€ This is like setting up your sharing headquarters.

Install Samba Packages:

# Update your system first - always start fresh!
sudo dnf update -y

# Install Samba and required tools
sudo dnf install samba samba-common samba-client -y

# Install additional utilities
sudo dnf install cifs-utils samba-winbind -y

# Check Samba version
smbd --version
# Output: Version 4.x.x - Perfect! ๐ŸŽฏ

# Enable Samba services
sudo systemctl enable smb nmb winbind

# Start Samba services
sudo systemctl start smb nmb winbind

# Verify services are running
sudo systemctl status smb
# Output: Active (running) - Excellent! โœ…

Configure Firewall:

# Add Samba service to firewall
sudo firewall-cmd --permanent --add-service=samba

# If you need specific ports instead
sudo firewall-cmd --permanent --add-port=139/tcp
sudo firewall-cmd --permanent --add-port=445/tcp
sudo firewall-cmd --permanent --add-port=137-138/udp

# Reload firewall
sudo firewall-cmd --reload

# Verify firewall rules
sudo firewall-cmd --list-all
# You should see samba in services list! ๐Ÿ”ฅ

๐Ÿ”ง Step 2: Creating Shared Directories

Time to create the folders weโ€™ll share! ๐Ÿ“ Think of these as your network filing cabinets.

Set Up Share Directories:

# Create main share directory
sudo mkdir -p /srv/samba/public

# Create a private share directory
sudo mkdir -p /srv/samba/private

# Create department shares (example for office)
sudo mkdir -p /srv/samba/accounting
sudo mkdir -p /srv/samba/marketing
sudo mkdir -p /srv/samba/it-dept

# Set initial permissions (we'll refine these)
sudo chmod 755 /srv/samba/public
sudo chmod 750 /srv/samba/private

# Create a test file in public share
echo "Welcome to Samba! ๐ŸŽ‰" | sudo tee /srv/samba/public/welcome.txt

# Check directory structure
tree /srv/samba/
# Shows your share hierarchy

Configure SELinux for Samba:

# Set SELinux context for Samba shares
sudo semanage fcontext -a -t samba_share_t "/srv/samba(/.*)?"

# Apply the context
sudo restorecon -Rv /srv/samba/

# Allow Samba to access home directories (if needed)
sudo setsebool -P samba_enable_home_dirs on

# Allow Samba to share any directory
sudo setsebool -P samba_export_all_rw on

# Verify SELinux contexts
ls -Z /srv/samba/
# Should show samba_share_t context

๐ŸŒŸ Step 3: Configuring Samba Shares

Letโ€™s configure our shares! ๐ŸŽฏ This is where we define what to share and how.

Backup and Edit Samba Configuration:

# Always backup original config!
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup

# Edit Samba configuration
sudo nano /etc/samba/smb.conf

Add this configuration (Iโ€™ll explain each part!):

[global]
    # Basic server settings
    workgroup = WORKGROUP
    server string = AlmaLinux Samba Server %v
    netbios name = ALMASERVER
    security = user
    map to guest = bad user
    dns proxy = no
    
    # Performance tuning
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072
    read raw = yes
    write raw = yes
    use sendfile = yes
    
    # Logging
    log file = /var/log/samba/log.%m
    max log size = 50
    log level = 1
    
    # Character encoding for international files
    unix charset = UTF-8
    dos charset = CP850

# Public share - everyone can access
[Public]
    comment = Public Share - Free for All! ๐ŸŒ
    path = /srv/samba/public
    browseable = yes
    writable = yes
    guest ok = yes
    read only = no
    create mask = 0644
    directory mask = 0755
    force user = nobody
    force group = nobody

# Private share - authentication required
[Private]
    comment = Private Share - Login Required ๐Ÿ”
    path = /srv/samba/private
    valid users = @smbusers
    browseable = yes
    writable = yes
    guest ok = no
    read only = no
    create mask = 0660
    directory mask = 0770
    force group = smbusers

# IT Department share - restricted access
[IT-Dept]
    comment = IT Department Files ๐Ÿ’ป
    path = /srv/samba/it-dept
    valid users = @it-team
    browseable = yes
    writable = yes
    guest ok = no
    read only = no
    create mask = 0660
    directory mask = 0770
    force group = it-team

# Home directories (optional)
[homes]
    comment = Home Directories
    browseable = no
    writable = yes
    valid users = %S
    create mask = 0700
    directory mask = 0700

Test Configuration:

# Test Samba configuration for errors
testparm

# Press Enter to see full config
# Should show "Loaded services file OK" ๐ŸŽ‰

# Restart Samba to apply changes
sudo systemctl restart smb nmb

โœ… Step 4: Managing Users and Groups

Letโ€™s set up users who can access our shares! ๐Ÿ‘ฅ This is your security checkpoint.

Create Samba Users and Groups:

# Create groups for organized access
sudo groupadd smbusers
sudo groupadd it-team

# Create a system user for Samba (no home directory)
sudo useradd -M -G smbusers sambauser1

# Create IT team member
sudo useradd -M -G it-team,smbusers itadmin

# Set Samba passwords (different from system passwords!)
sudo smbpasswd -a sambauser1
# Enter password twice

sudo smbpasswd -a itadmin
# Enter password twice

# Enable Samba users
sudo smbpasswd -e sambauser1
sudo smbpasswd -e itadmin

# List Samba users
sudo pdbedit -L
# Shows all Samba users

# View detailed user info
sudo pdbedit -L -v

Set Directory Ownership:

# Set ownership for shares
sudo chown -R nobody:nobody /srv/samba/public
sudo chown -R root:smbusers /srv/samba/private
sudo chown -R root:it-team /srv/samba/it-dept

# Set proper permissions
sudo chmod 2775 /srv/samba/private
sudo chmod 2770 /srv/samba/it-dept

# The '2' sets SGID bit - new files inherit group ownership

๐ŸŽฎ Quick Examples

Letโ€™s test our Samba setup with real-world scenarios! ๐Ÿš€

Example 1: Connect from Windows

# First, get your server's IP address
ip addr show | grep "inet "
# Note your IP (e.g., 192.168.1.100)

# On Windows, open File Explorer and type:
# \\192.168.1.100
# Or
# \\ALMASERVER

# You should see your shares! ๐ŸŽŠ

# Map a network drive (Windows):
# Right-click "This PC" โ†’ "Map network drive"
# Drive letter: Z:
# Folder: \\192.168.1.100\Private
# Check "Connect using different credentials"
# Enter your Samba username and password

Example 2: Connect from Linux

# List available shares
smbclient -L //localhost -N
# Shows all shares

# Connect to a share
smbclient //localhost/Public -U sambauser1
# Enter password when prompted

# Inside smbclient:
smb: \> ls
smb: \> put testfile.txt
smb: \> get welcome.txt
smb: \> exit

# Mount share permanently
sudo mkdir -p /mnt/samba-private
sudo mount -t cifs //192.168.1.100/Private /mnt/samba-private -o username=sambauser1

# Add to /etc/fstab for permanent mount
echo "//192.168.1.100/Private /mnt/samba-private cifs credentials=/etc/samba/credentials,uid=1000,gid=1000,iocharset=utf8 0 0" | sudo tee -a /etc/fstab

# Create credentials file
sudo nano /etc/samba/credentials
# Add:
# username=sambauser1
# password=YourPassword
# domain=WORKGROUP

# Secure credentials file
sudo chmod 600 /etc/samba/credentials

Example 3: Create a Media Server Share

# Create media share directory
sudo mkdir -p /srv/samba/media/{movies,music,photos}

# Add to smb.conf
sudo tee -a /etc/samba/smb.conf << 'EOF'

[Media]
    comment = Media Server - Movies, Music, Photos ๐ŸŽฌ๐ŸŽต๐Ÿ“ธ
    path = /srv/samba/media
    browseable = yes
    read only = yes
    guest ok = yes
    write list = @media-admins
    create mask = 0644
    directory mask = 0755
    
    # Media-specific optimizations
    veto files = /*.tmp/*.temp/*.~*/
    delete veto files = yes
    
    # Performance for large files
    min receivefile size = 16384
    aio read size = 16384
    aio write size = 16384
EOF

# Create media admins group
sudo groupadd media-admins

# Add user to media admins
sudo usermod -aG media-admins sambauser1

# Set permissions
sudo chown -R root:media-admins /srv/samba/media
sudo chmod -R 775 /srv/samba/media

# Restart Samba
sudo systemctl restart smb

๐Ÿšจ Fix Common Problems

Donโ€™t panic if something doesnโ€™t work! Here are solutions to common issues:

Problem 1: Canโ€™t Access Shares from Windows

# Check if Samba is running
sudo systemctl status smb nmb

# Check Windows workgroup name
testparm -s | grep workgroup
# Should match Windows workgroup (usually WORKGROUP)

# Disable Windows firewall temporarily to test
# Or add exception for ports 139, 445

# Reset Samba user password
sudo smbpasswd sambauser1

# Check SELinux isn't blocking
sudo setenforce 0  # Temporarily disable to test
# If this fixes it, configure SELinux properly:
sudo setsebool -P samba_export_all_rw on
sudo setenforce 1  # Re-enable

Problem 2: Permission Denied Errors

# Check file ownership
ls -la /srv/samba/

# Fix ownership
sudo chown -R nobody:nobody /srv/samba/public

# Check Samba user exists
sudo pdbedit -L

# Verify user is in correct group
groups sambauser1

# Check SELinux context
ls -Z /srv/samba/

# Fix SELinux context if needed
sudo restorecon -Rv /srv/samba/

Problem 3: Slow Transfer Speeds

# Add performance tuning to [global] section
sudo nano /etc/samba/smb.conf

# Add these lines:
# socket options = TCP_NODELAY SO_RCVBUF=131072 SO_SNDBUF=131072
# use sendfile = yes
# write cache size = 2097152
# min receivefile size = 16384

# Disable oplocks for databases (if sharing database files)
# oplocks = no
# level2 oplocks = no

# Restart Samba
sudo systemctl restart smb

# Check network speed
iperf3 -s  # On server
iperf3 -c SERVER_IP  # On client

๐Ÿ“‹ Simple Commands Summary

Your Samba command cheat sheet! ๐Ÿ“š Keep this handy:

TaskCommandWhat It Does
Start Sambasudo systemctl start smb nmbStarts file sharing ๐Ÿš€
Stop Sambasudo systemctl stop smb nmbStops file sharing ๐Ÿ›‘
Restart Sambasudo systemctl restart smb nmbApplies new config ๐Ÿ”„
Check Statussudo systemctl status smbShows if running โœ…
Test ConfigtestparmValidates smb.conf ๐Ÿงช
Add Usersudo smbpasswd -a usernameCreates Samba user ๐Ÿ‘ค
List Userssudo pdbedit -LShows all users ๐Ÿ“‹
List Sharessmbclient -L localhost -NShows available shares ๐Ÿ“
Connect Sharesmbclient //server/share -U userAccess share ๐Ÿ”—
Check Logssudo tail -f /var/log/samba/log.smbdView activity ๐Ÿ“
SELinux Fixsudo restorecon -Rv /srv/samba/Fix contexts ๐Ÿ”ง
Whoโ€™s Connectedsudo smbstatusShows active connections ๐Ÿ‘ฅ

๐Ÿ’ก Tips for Success

Here are my battle-tested tips for running Samba like a pro! ๐ŸŽฏ

Security Best Practices:

  • ๐Ÿ” Never use simple passwords - Samba is network-accessible!
  • ๐Ÿ›ก๏ธ Limit valid users - Donโ€™t use โ€˜guest okโ€™ for sensitive data
  • ๐Ÿ”’ Use separate Samba passwords - Different from system passwords
  • ๐Ÿ“ Monitor access logs - Check whoโ€™s accessing what
  • ๐Ÿšซ Disable SMBv1 - Add min protocol = SMB2 to config
  • ๐ŸŽฏ Use IP restrictions - Add hosts allow = 192.168.1.0/24
  • ๐Ÿ”ง Regular updates - Keep Samba patched and current
  • ๐Ÿ’พ Backup configurations - Before any major changes

Performance Tips:

  • โšก Use socket options - Optimize network performance
  • ๐Ÿš€ Enable sendfile - Faster file transfers
  • ๐Ÿ“Š Monitor usage - Use smbstatus regularly
  • ๐ŸŽฏ Tune for your network - Gigabit vs WiFi settings differ
  • ๐Ÿ’ก Separate shares by usage - Donโ€™t mix databases with media
  • ๐Ÿ”„ Regular maintenance - Clean up old files and logs

๐Ÿ† What You Learned

Wow, look at what youโ€™ve accomplished! ๐ŸŽŠ Youโ€™re now a Samba expert!

Your Achievements:

  • โœ… Installed and configured Samba server
  • โœ… Created multiple share types (public/private)
  • โœ… Set up user authentication
  • โœ… Configured SELinux for Samba
  • โœ… Managed permissions and groups
  • โœ… Tested Windows and Linux connections
  • โœ… Optimized performance settings
  • โœ… Learned troubleshooting techniques
  • โœ… Created a media server setup
  • โœ… Mastered network file sharing!

๐ŸŽฏ Why This Matters

Your Samba server is more than just file sharing - itโ€™s your networkโ€™s collaboration hub! ๐ŸŒŸ

With your new Samba skills, you can:

  • ๐Ÿ  Build a home NAS - Central storage for the family
  • ๐Ÿ’ผ Create office file server - Professional document management
  • ๐ŸŽฌ Stream media - Movies and music to any device
  • ๐Ÿ’พ Centralize backups - One location for all backups
  • ๐ŸŽฎ Share game files - LAN party file sharing
  • ๐Ÿ“ธ Photo management - Family photo archive
  • ๐Ÿ”ง Development shares - Code repository access
  • ๐Ÿš€ Scale your network - From home to enterprise

Remember when file sharing seemed complicated? Now youโ€™re running a professional-grade file server! Youโ€™ve bridged the gap between different operating systems and created a unified storage solution. Thatโ€™s seriously impressive! ๐ŸŒŸ

Keep exploring, keep sharing, and most importantly, enjoy your new file sharing superpowers! ๐Ÿฆธโ€โ™‚๏ธ

Happy sharing, and welcome to the world of seamless network storage! ๐Ÿ™Œ


P.S. - Donโ€™t forget to regularly backup your shared data. Your users are counting on you! โญ