+
+
nomad
packer
+
+
ember
pandas
flask
+
rider
+
+
+
+
[]
+
+
ocaml
fauna
travis
soap
+
py
^
dask
axum
+
+
+
+
+
atom
+=
strapi
junit
haiku
+
cosmos
λ
bbedit
+
+
+
+
bun
ts
+
+
sklearn
debian
axum
+
+
elm
cdn
+
json
+
bitbucket
+
quarkus
+
+
elasticsearch
+
!!
+
+
@
+
+
qwik
jax
!!
preact
+
+
rails
mxnet
+
+
+
cargo
+
+
+
unix
Back to Blog
📁 AlmaLinux File Server: Complete Samba & NFS Setup Guide
AlmaLinux File Server Samba

📁 AlmaLinux File Server: Complete Samba & NFS Setup Guide

Published Sep 18, 2025

Master file servers on AlmaLinux! Learn Samba for Windows sharing, NFS for Linux, user management, security, and performance optimization. Complete guide with examples.

54 min read
0 views
Table of Contents

📁 AlmaLinux File Server: Complete Samba & NFS Setup Guide

Hey there, file sharing expert! 🎉 Ready to build a powerful file server that can serve files to Windows, Linux, and Mac clients seamlessly? Today we’re setting up both Samba (SMB/CIFS) and NFS on AlmaLinux to create the ultimate cross-platform file sharing solution! 🚀

Whether you’re building a home media server, office file storage, or enterprise-grade shared storage, this guide will turn your AlmaLinux system into a file sharing powerhouse! 💪

🤔 Why is a File Server Important?

Imagine having all your files scattered across different computers, with no central place to store and share them! 😱 A file server centralizes storage and makes collaboration effortless!

Here’s why Samba & NFS on AlmaLinux are amazing:

  • 🔄 Cross-Platform Sharing - Windows, Linux, Mac all work together
  • 🔒 Centralized Security - One place to manage all access controls
  • 💾 Efficient Storage - No more duplicate files everywhere
  • 👥 Team Collaboration - Share files instantly across the network
  • 📱 Universal Access - Access files from any device
  • 🛡️ Backup Simplicity - Back up one central location
  • High Performance - Optimized for network file access
  • 🎯 Version Control - Track changes and maintain file history

🎯 What You Need

Before we build your file sharing empire, let’s check what we need:

AlmaLinux 9.x server (with sufficient storage) ✅ Network connectivity to client machines ✅ Static IP address recommended ✅ Firewall access for ports 445, 139, 2049 ✅ Storage space for shared files ✅ User accounts to manage access ✅ Basic networking knowledge 🌐 ✅ Patience for permissions (they can be tricky!) 😊

📝 Step 1: Install and Configure Samba

Let’s start with Samba for Windows-compatible file sharing! 🎯

# Install Samba packages
sudo dnf install -y samba samba-client samba-common cifs-utils

# Backup original configuration
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup

# Create main Samba configuration
sudo tee /etc/samba/smb.conf << 'EOF'
[global]
# Server identification
workgroup = WORKGROUP
server string = AlmaLinux File Server
netbios name = FILESERVER

# Security settings
security = user
map to guest = bad user
guest account = nobody

# Network settings
interfaces = lo eth0 192.168.1.0/24
hosts allow = 127. 192.168.1.
hosts deny = ALL

# Logging
log file = /var/log/samba/log.%m
max log size = 1000
log level = 1

# Performance tuning
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=524288 SO_SNDBUF=524288
read raw = yes
write raw = yes
max xmit = 65535
deadtime = 15
getwd cache = yes

# Character set
dos charset = CP932
unix charset = UTF-8

# Disable printer sharing
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes

#======================= Share Definitions =======================

[homes]
comment = Home Directories
browseable = no
writable = yes
valid users = %S
create mask = 0664
directory mask = 0775

[public]
comment = Public Share
path = /srv/samba/public
browseable = yes
writable = yes
guest ok = yes
read only = no
create mask = 0664
directory mask = 0775
force user = nobody
force group = nobody

[shared]
comment = Shared Files
path = /srv/samba/shared
browseable = yes
writable = yes
valid users = @sambausers
create mask = 0664
directory mask = 0775
force group = sambausers

[documents]
comment = Company Documents
path = /srv/samba/documents
browseable = yes
writable = yes
valid users = @office
admin users = admin
create mask = 0664
directory mask = 0775
inherit permissions = yes

[backup]
comment = Backup Storage
path = /srv/samba/backup
browseable = no
writable = yes
valid users = admin, backup
create mask = 0600
directory mask = 0700
EOF

# Create share directories
sudo mkdir -p /srv/samba/{public,shared,documents,backup}

# Set up groups for Samba users
sudo groupadd sambausers
sudo groupadd office

# Set permissions
sudo chown nobody:nobody /srv/samba/public
sudo chown root:sambausers /srv/samba/shared
sudo chown root:office /srv/samba/documents
sudo chown root:root /srv/samba/backup

sudo chmod 755 /srv/samba/public
sudo chmod 2775 /srv/samba/shared
sudo chmod 2775 /srv/samba/documents
sudo chmod 700 /srv/samba/backup

# Enable and start Samba services
sudo systemctl enable smb nmb
sudo systemctl start smb nmb

# Check configuration
sudo testparm

Perfect! Samba is configured! 🎉

🔧 Step 2: Create Samba Users

Now let’s create users for Samba access:

# Create Samba user management script
cat > /usr/local/bin/samba-user-manager.sh << 'EOF'
#!/bin/bash
# Samba User Management Tool

add_samba_user() {
    read -p "Username: " USERNAME
    read -sp "Password: " PASSWORD
    echo

    # Create system user
    sudo useradd -M -s /sbin/nologin $USERNAME

    # Add to groups
    sudo usermod -a -G sambausers $USERNAME

    # Set Samba password
    echo -e "$PASSWORD\n$PASSWORD" | sudo smbpasswd -a $USERNAME

    # Enable user
    sudo smbpasswd -e $USERNAME

    echo "✅ Samba user created: $USERNAME"
}

delete_samba_user() {
    read -p "Username to delete: " USERNAME

    # Remove from Samba
    sudo smbpasswd -x $USERNAME

    # Remove system user
    sudo userdel $USERNAME

    echo "✅ Samba user deleted: $USERNAME"
}

list_samba_users() {
    echo "📋 Samba Users:"
    sudo pdbedit -L
}

reset_password() {
    read -p "Username: " USERNAME
    read -sp "New Password: " PASSWORD
    echo

    echo -e "$PASSWORD\n$PASSWORD" | sudo smbpasswd $USERNAME
    echo "✅ Password reset for: $USERNAME"
}

show_connections() {
    echo "🔗 Active Samba Connections:"
    sudo smbstatus
}

case "$1" in
    add) add_samba_user ;;
    delete) delete_samba_user ;;
    list) list_samba_users ;;
    password) reset_password ;;
    status) show_connections ;;
    *) echo "Usage: $0 {add|delete|list|password|status}" ;;
esac
EOF

chmod +x /usr/local/bin/samba-user-manager.sh

# Create initial users
echo "Creating sample users..."
sudo useradd -M -s /sbin/nologin john
sudo useradd -M -s /sbin/nologin alice
sudo usermod -a -G sambausers john
sudo usermod -a -G sambausers,office alice

# Set Samba passwords (you'll be prompted)
echo "Setting up Samba passwords..."
sudo smbpasswd -a john
sudo smbpasswd -a alice

Excellent! Samba users are set up! 🌟

🌟 Step 3: Install and Configure NFS

Now let’s set up NFS for Linux/Unix file sharing:

# Install NFS packages
sudo dnf install -y nfs-utils rpcbind

# Create NFS export directories
sudo mkdir -p /srv/nfs/{shared,projects,backup}

# Configure NFS exports
sudo tee /etc/exports << 'EOF'
# NFS Exports Configuration

# Shared directory for all clients
/srv/nfs/shared     192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash)

# Projects directory with restricted access
/srv/nfs/projects   192.168.1.0/24(rw,sync,no_subtree_check,root_squash,anonuid=1001,anongid=1001)

# Backup directory - read-only for most clients
/srv/nfs/backup     192.168.1.0/24(ro,sync,no_subtree_check)
/srv/nfs/backup     192.168.1.10(rw,sync,no_subtree_check,no_root_squash)

# Home directories
/home               192.168.1.0/24(rw,sync,no_subtree_check,root_squash)
EOF

# Set NFS directory permissions
sudo chown nfsnobody:nfsnobody /srv/nfs/shared
sudo chown nfsnobody:nfsnobody /srv/nfs/projects
sudo chmod 755 /srv/nfs/shared
sudo chmod 755 /srv/nfs/projects
sudo chmod 755 /srv/nfs/backup

# Enable and start NFS services
sudo systemctl enable rpcbind nfs-server
sudo systemctl start rpcbind nfs-server

# Export the filesystems
sudo exportfs -arv

# Check exports
sudo exportfs -v

✅ Step 4: Configure Firewall

Let’s open the necessary ports for file sharing:

# Configure firewall for Samba
sudo firewall-cmd --permanent --add-service=samba
sudo firewall-cmd --permanent --add-port=445/tcp
sudo firewall-cmd --permanent --add-port=139/tcp

# Configure firewall for NFS
sudo firewall-cmd --permanent --add-service=nfs
sudo firewall-cmd --permanent --add-service=rpc-bind
sudo firewall-cmd --permanent --add-service=mountd

# Reload firewall
sudo firewall-cmd --reload

# Verify open ports
sudo ss -tlnp | grep -E "445|139|2049|111"

🎮 Quick Examples

Example 1: Advanced Samba Security

# Configure advanced Samba security
cat >> /etc/samba/smb.conf << 'EOF'

[secure]
comment = Secure Document Storage
path = /srv/samba/secure
browseable = no
writable = yes
valid users = @management
admin users = admin
create mask = 0600
directory mask = 0700
encrypt passwords = yes
smb encrypt = required
vfs objects = audit
audit:facility = local5
audit:priority = info
EOF

# Create secure directory
sudo mkdir -p /srv/samba/secure
sudo groupadd management
sudo chown root:management /srv/samba/secure
sudo chmod 2770 /srv/samba/secure

Example 2: NFS Performance Tuning

# Optimize NFS for performance
cat > /etc/nfs.conf << 'EOF'
[nfsd]
# Number of NFS server threads
threads=16

# TCP settings
tcp=y
vers3=y
vers4=y
vers4.0=y
vers4.1=y
vers4.2=y

[mountd]
# Mount daemon settings
manage-gids=y
EOF

# Restart NFS with new settings
sudo systemctl restart nfs-server

Example 3: File Server Monitoring

# Create file server monitoring script
cat > /usr/local/bin/fileserver-monitor.sh << 'EOF'
#!/bin/bash
# File Server Monitoring

echo "📊 File Server Status Report"
echo "============================"
echo ""

# Samba status
echo "🔗 Samba Connections:"
sudo smbstatus --shares | grep -v "^$"
echo ""

echo "👥 Samba Users:"
sudo smbstatus --users | grep -v "^$"
echo ""

# NFS status
echo "📁 NFS Exports:"
sudo exportfs -v
echo ""

echo "🌐 NFS Connections:"
sudo netstat -an | grep :2049
echo ""

# Disk usage
echo "💾 Storage Usage:"
df -h /srv/samba /srv/nfs
echo ""

# System load
echo "⚡ System Performance:"
uptime
free -h
echo ""

# Recent logs
echo "📝 Recent Samba Logs:"
sudo tail -n 5 /var/log/samba/log.smbd
echo ""

echo "✅ Monitoring completed at $(date)"
EOF

chmod +x /usr/local/bin/fileserver-monitor.sh

# Schedule monitoring
(crontab -l 2>/dev/null; echo "0 */6 * * * /usr/local/bin/fileserver-monitor.sh >> /var/log/fileserver-monitor.log") | crontab -

🚨 Fix Common Problems

Problem 1: Samba Access Denied

# Check user and permissions
sudo pdbedit -L
ls -la /srv/samba/

# Fix permissions
sudo chown -R root:sambausers /srv/samba/shared
sudo chmod -R 2775 /srv/samba/shared

# Reset Samba password
sudo smbpasswd username

# Check SELinux contexts
sudo setsebool -P samba_enable_home_dirs on
sudo setsebool -P samba_export_all_rw on

Problem 2: NFS Mount Failures

# Check NFS services
sudo systemctl status rpcbind nfs-server

# Verify exports
sudo exportfs -v

# Re-export shares
sudo exportfs -ra

# Check client connectivity
rpcinfo -p localhost

# Test mount manually
sudo mount -t nfs localhost:/srv/nfs/shared /mnt

Problem 3: Slow File Transfer

# Optimize Samba performance
echo "socket options = TCP_NODELAY SO_RCVBUF=524288 SO_SNDBUF=524288" >> /etc/samba/smb.conf

# Tune NFS block size
mount -t nfs -o rsize=32768,wsize=32768 server:/path /mnt

# Check network settings
ethtool eth0

📋 Simple Commands Summary

CommandPurpose
sudo systemctl status smbCheck Samba status
sudo smbstatusShow Samba connections
sudo systemctl status nfs-serverCheck NFS status
sudo exportfs -vList NFS exports
samba-user-manager.sh addAdd Samba user
sudo mount -t nfs server:/path /mntMount NFS share
sudo testparmTest Samba configuration
showmount -e localhostShow NFS exports

🏆 What You Learned

Congratulations! You’ve built a complete file server on AlmaLinux! 🎉

Configured Samba for Windows file sharing ✅ Set up NFS for Linux/Unix sharing ✅ Created user management system ✅ Implemented security controls ✅ Optimized performance settings ✅ Built monitoring tools

🎯 Why This Matters

A well-configured file server is the backbone of any network! 🌟 You now have cross-platform file sharing that serves Windows, Linux, and Mac clients efficiently and securely! 🚀

Keep your file server maintained and monitored for best performance! ⭐🙌