Guides 11792 Published by

This article explains how to install and configure NFS on Linux servers, guiding the reader through package installation, export configuration, service management, and client mounting steps. It emphasizes the simplicity of NFS compared to alternatives such as Samba or SCP scripts, noting that it uses existing user accounts and can be set up quickly after a driver update that breaks file access. The author provides practical commands for adding shared directories to /etc/exports, enabling the NFS kernel server, and ensuring proper firewall rules are in place while also troubleshooting common errors like permission denials or missing export updates. By following these straightforward instructions, users can share code, media, or other files across their Linux machines without needing a GUI wizard.



NFS on Linux: How to Install It and Share Files Without a Hitch

If you’ve ever tried to pull a file from another machine over the network and ended up opening a web browser instead, you’re probably looking for NFS. In short, it’s the classic way Linux boxes talk to each other about files, and it’s surprisingly easy to set up once you know where to look.

What the heck is NFS?

NFS, or Network File System, lets one computer present a folder that another can mount just like any local disk. Think of it as a “shared drive” for Linux, but with the low‑level muscle of TCP/IP instead of a USB stick.

Why you should bother installing NFS

I’ve seen this happen after a bad driver update: a team’s build server lost access to its source tree because the share disappeared from the client. Re‑adding an NFS mount is way faster than re‑creating an SMB share or setting up SCP scripts. And unlike Samba, it doesn’t need a separate user database—just the same Linux accounts.

Quick prerequisites
  • A machine that will host the files (the server)
  • At least one other machine that needs to see them (the client)
  • Root or sudo access on both ends

Make sure you can SSH into each system; otherwise you’re going to be banging your head against a terminal.

Installing the NFS server on Ubuntu / Debian
sudo apt update
sudo apt install nfs-kernel-server

The first line pulls in the newest package list, while the second grabs the actual daemon and its helper utilities. The nfs-kernel-server package is what will listen for mount requests from clients.

Configuring exports

Open /etc/exports with your favorite editor:

sudo nano /etc/exports

Add a line like this:

/srv/nfs/shared 192.168.1.0/24(rw,sync,no_subtree_check)
  • /srv/nfs/shared is the folder you’re giving away (create it first with mkdir -p).
  • 192.168.1.0/24 limits access to your local subnet; change it to match your network or use *(rw,sync) for everyone.
  • rw gives write access; remove it if you only want read‑only.
  • sync forces data to flush before responding—slower but safer.
  • no_subtree_check avoids extra lookups if subfolders move around.

After saving, run:

sudo exportfs -ra

This reloads the export list and tells NFS to start serving those directories.

Starting and enabling the service
sudo systemctl enable --now nfs-kernel-server

enable makes sure it starts on boot; --now starts it immediately. Check with:

systemctl status nfs-kernel-server

You’ll see “active (running)” if everything’s good.

Mounting an NFS share on a client

Create a mount point:

sudo mkdir -p /mnt/shared

Mount it manually to test:

sudo mount -t nfs 10.0.0.5:/srv/nfs/shared /mnt/shared

Replace 10.0.0.5 with your server’s IP. If that works, add a permanent line to /etc/fstab:

10.0.0.5:/srv/nfs/shared  /mnt/shared  nfs  defaults 0 0

Now the share will mount automatically on reboot.

Common pitfalls and debugging
  • “Permission denied” – double‑check that the client’s UID matches a user on the server, or use root_squash in /etc/exports.
  • “No such file or directory” after export changes – make sure you ran exportfs -ra.
  • Firewall blocking – open TCP ports 111, 2049, and any other RPC services:
sudo ufw allow from 192.168.1.0/24 to any port nfs

If you’re on CentOS/RHEL, use firewall-cmd --add-service=nfs instead.

Quick sanity check

On the client, run:

showmount -e 10.0.0.5

You should see your exported path listed. If not, something’s mis‑configured on the server side.

That’s it—no fancy GUI wizard needed. Now you can share code, media, or any other files across Linux machines with just a few lines in /etc/exports and fstab.