Share Folders Across Your Network from Fedora Linux
In this article
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 addrorhostname -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)
- Install Samba: Open a terminal and run
sudo dnf install samba samba-client. This installs the server and client tools. - 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. - Choose the folder to share: For example, create a folder called
Sharedin your home directory:mkdir ~/Shared. You can share any folder you have read/write access to. - 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
Replaceyourusernamewith your actual username and adjust the path if needed. Save and exit. - Test the configuration: Run
testparmto check for syntax errors. If it reports errors, fix them before continuing. - Start and enable Samba services: Run
sudo systemctl enable --now smbandsudo systemctl enable --now nmb. The first command starts the file sharing service, the second handles NetBIOS name resolution. - Open firewall ports: If you use firewalld (default on Fedora), run
sudo firewall-cmd --permanent --add-service=sambaand thensudo firewall-cmd --reload. This allows Samba traffic through the firewall. - 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 entersmb://fedora-ip/Shared. On macOS, press Cmd+K and entersmb://fedora-ip/Shared. Enter your Fedora username and Samba password when prompted.
Method 2: NFS (For Linux/Unix Clients Only)
- Install NFS server: Run
sudo dnf install nfs-utils. - Create the folder to share: For example,
mkdir ~/NFSShare. Adjust permissions if needed:chmod 755 ~/NFSShare. - Edit the exports file: Run
sudo nano /etc/exportsand 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. - Apply the exports: Run
sudo exportfs -rato make the share active without restarting. - Start and enable NFS services: Run
sudo systemctl enable --now nfs-server. - Open firewall ports: Run
sudo firewall-cmd --permanent --add-service=nfsandsudo firewall-cmd --reload. Also add the related services:sudo firewall-cmd --permanent --add-service=mountdandsudo firewall-cmd --permanent --add-service=rpc-bind, then reload again. - Mount on a client: On the client Linux machine, install
nfs-utilsif not present (sudo dnf install nfs-utilson Fedora,sudo apt install nfs-commonon Debian/Ubuntu). Then create a mount point:mkdir ~/mnt_shareand mount withsudo mount -t nfs fedora-ip:/home/yourusername/NFSShare ~/mnt_share. To make it permanent, add an entry to/etc/fstabon 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 755for read-only,chmod 775for 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
testparmto 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 = yesandmap to guest = Bad Userin 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-ipon 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
- Check the service status: Run
sudo systemctl status smb(ornfs-server) to see if the service is running. If not, start it withsudo systemctl start smb. - Verify firewall: Run
sudo firewall-cmd --list-allto see if the samba or nfs services are listed. If not, re-add them and reload. - Test connectivity: From the client, ping the Fedora IP (
ping fedora-ip). If it fails, check network cables, Wi-Fi, and IP addresses. - Check Samba logs: Look at
/var/log/samba/log.smbdfor errors. Common issues include authentication failures or path errors. - Check NFS exports: On the server, run
sudo exportfs -vto see if the export is listed correctly. If not, re-runsudo exportfs -ra. - 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 onfor Samba, orsudo setsebool -P nfs_export_all_rw onfor NFS. Re-enable SELinux withsudo setenforce 1after 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.