Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Share Folders Across Your Network from Fedora Linux

· 6 min read · Home Networking

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To share folders across your network from Fedora Linux, you can use Samba (for Windows/macOS/Linux compatibility) or NFS (for Linux/Unix systems). This guide covers both methods, with Samba as the primary option since it works with virtually all devices. You'll need sudo access and the IP address of the machine you're sharing from.

What You'll Need

  • A Fedora Linux system (any recent version) with sudo privileges
  • The IP address of the Fedora machine (find it with ip addr or hostname -I)
  • For Samba: a username and password on the Fedora system (or you can create a dedicated Samba user)
  • For NFS: the IP addresses or hostnames of the client machines you want to allow
  • Network connectivity between the machines (same LAN or VPN)

Step-by-Step

Method 1: Samba (Recommended for Mixed Networks)

  1. Install Samba: Open a terminal and run sudo dnf install samba samba-client. This installs the server and client tools.
  2. Create a Samba password for your user: If you want to share a folder with your existing Linux user, set a Samba password with sudo smbpasswd -a yourusername. Enter a password when prompted. This is separate from your Linux login password.
  3. Choose the folder to share: For example, create a folder called Shared in your home directory: mkdir ~/Shared. You can share any folder you have read/write access to.
  4. Edit the Samba configuration file: Run sudo nano /etc/samba/smb.conf (or use any text editor). At the bottom of the file, add the following block:
    [Shared]
       path = /home/yourusername/Shared
       valid users = yourusername
       read
       browsable = yes
    Replace yourusername with your actual username and adjust the path if needed. Save and exit.
  5. Test the configuration: Run testparm to check for syntax errors. If it reports errors, fix them before continuing.
  6. Start and enable Samba services: Run sudo systemctl enable --now smb and sudo systemctl enable --now nmb. The first command starts the file sharing service, the second handles NetBIOS name resolution.
  7. Open firewall ports: If you use firewalld (default on Fedora), run sudo firewall-cmd --permanent --add-service=samba and then sudo firewall-cmd --reload. This allows Samba traffic through the firewall.
  8. Access the share from another machine: On Windows, open File Explorer and type \\fedora-ip\Shared (replace with your Fedora IP). On Linux, use your file manager's "Connect to Server" and enter smb://fedora-ip/Shared. On macOS, press Cmd+K and enter smb://fedora-ip/Shared. Enter your Fedora username and Samba password when prompted.

Method 2: NFS (For Linux/Unix Clients Only)

  1. Install NFS server: Run sudo dnf install nfs-utils.
  2. Create the folder to share: For example, mkdir ~/NFSShare. Adjust permissions if needed: chmod 755 ~/NFSShare.
  3. Edit the exports file: Run sudo nano /etc/exports and add a line like:
    /home/yourusername/NFSShare 192.168.1.0/24(rw,sync,no_subtree_check)
    Replace the IP range with your network's subnet. To allow a single machine, use its IP instead. Save and exit.
  4. Apply the exports: Run sudo exportfs -ra to make the share active without restarting.
  5. Start and enable NFS services: Run sudo systemctl enable --now nfs-server.
  6. Open firewall ports: Run sudo firewall-cmd --permanent --add-service=nfs and sudo firewall-cmd --reload. Also add the related services: sudo firewall-cmd --permanent --add-service=mountd and sudo firewall-cmd --permanent --add-service=rpc-bind, then reload again.
  7. Mount on a client: On the client Linux machine, install nfs-utils if not present (sudo dnf install nfs-utils on Fedora, sudo apt install nfs-common on Debian/Ubuntu). Then create a mount point: mkdir ~/mnt_share and mount with sudo mount -t nfs fedora-ip:/home/yourusername/NFSShare ~/mnt_share. To make it permanent, add an entry to /etc/fstab on the client.

Common Mistakes

  • Forgetting to set a Samba password: Your Linux login password is not automatically your Samba password. You must run smbpasswd -a.
  • Wrong folder permissions: If the folder is not readable/writable by the Samba user, access will fail. Ensure the folder's owner and permissions allow the user (e.g., chmod 755 for read-only, chmod 775 for group write).
  • Firewall blocking: Samba uses ports 137-139 and 445. NFS uses port 2049 plus others. If you don't open them in firewalld, clients can't connect.
  • Typo in smb.conf: A missing bracket or wrong path will cause errors. Use testparm to validate.
  • Not enabling the services: If you only start Samba without enabling it, it won't start after a reboot.

Tips

  • Use a dedicated share folder in your home directory rather than sharing your entire home, to limit access.
  • For better security, create a separate Samba user with a strong password and only give that user access to the share.
  • If you need to share with guests (no password), add guest ok = yes and map to guest = Bad User in the share block, but be aware this is insecure on untrusted networks.
  • To see what shares are available on your Fedora machine, run smbclient -L localhost -U yourusername.
  • For NFS, use showmount -e fedora-ip on the client to list available exports.
  • If you have a home router with a built-in firewall, ensure it allows traffic between LAN devices (usually it does by default).

Troubleshooting

  1. Check the service status: Run sudo systemctl status smb (or nfs-server) to see if the service is running. If not, start it with sudo systemctl start smb.
  2. Verify firewall: Run sudo firewall-cmd --list-all to see if the samba or nfs services are listed. If not, re-add them and reload.
  3. Test connectivity: From the client, ping the Fedora IP (ping fedora-ip). If it fails, check network cables, Wi-Fi, and IP addresses.
  4. Check Samba logs: Look at /var/log/samba/log.smbd for errors. Common issues include authentication failures or path errors.
  5. Check NFS exports: On the server, run sudo exportfs -v to see if the export is listed correctly. If not, re-run sudo exportfs -ra.
  6. If you still can't connect: Try disabling SELinux temporarily with sudo setenforce 0 (this is not persistent; to make it permanent, edit /etc/selinux/config). If it works, you need to set the correct SELinux boolean: sudo setsebool -P samba_export_all_rw on for Samba, or sudo setsebool -P nfs_export_all_rw on for NFS. Re-enable SELinux with sudo setenforce 1 after testing.

Frequently Asked Questions

Can I share a folder with Windows without Samba?

No. Windows uses the SMB protocol, which Samba implements. NFS is not natively supported by Windows (though you can install additional software). Samba is the standard solution.

Do I need to create a separate Samba user?

Not necessarily. You can use your existing Linux user, but you must set a Samba password for that user. Creating a dedicated user is safer if you want to limit access.

How do I make the share permanent after reboot?

For Samba, the systemctl enable command ensures the service starts at boot. For NFS, the same applies. The share definitions in smb.conf and /etc/exports are persistent by default.

Why can I see the share but not open it?

This usually means the firewall is allowing browsing, but authentication or permissions are wrong. Check that you have a valid Samba password and that the folder permissions allow the user.

Can I share a folder that is on an external drive?

Yes. Just set the path in smb.conf to the mount point of the external drive (e.g., /run/media/yourusername/DriveName). Ensure the drive is mounted at boot if you want it always available.

Is NFS faster than Samba?

For Linux-to-Linux, NFS often has lower overhead and better performance. For mixed OS networks, Samba is more compatible. The speed difference is usually negligible for home use.