Complete guide to NFS in Linux: concepts, installation, and best practices

Introduction

In modern business and development environments, sharing files between multiple systems is a daily necessity. Linux offers several solutions for this purpose, one of the oldest and most reliable being the Network File System (NFS). Originally developed by Sun Microsystems in the 1980s, NFS allows machines to access remote directories as if they were local, facilitating collaboration and centralization of data. In this article we will explore what NFS is, how it works, its advantages and limitations, and we will show you step by step how to install, configure, and secure an NFS server on a typical Linux distribution.

What is NFS?

NFS is an application-layer protocol that allows the exchange of files and directories between machines over an IP network. It follows the client‑server model: the NFS server exposes, or exports, certain directories from the local filesystem, while clients mount them in their own directory tree. The protocol uses remote procedure calls (RPC) to translate read, write, and attribute operations into messages that travel across the network. Since its version 2, NFS has evolved to version 3 and later to version 4, incorporating improvements in performance, security, and firewall compatibility. In practice, NFS is frequently used in compute clusters, web servers, and development environments where fast and consistent access to shared data is required.

Advantages and Disadvantages of NFS

Before deciding whether NFS is the right solution for your infrastructure, it is important to evaluate both its strengths and its limitations. Below is a summary of the main aspects to consider.

  • Transparent access: remote files behave as if they were on the local disk, simplifying the use of existing applications.
  • Scalability: it allows sharing large volumes of data among numerous clients without needing to replicate information.
  • Low overhead: on fast and reliable networks, NFS offers performance close to that of local filesystems.
  • Network dependence: any interruption or latency directly affects the availability and performance of the service.
  • Limited security in older versions: NFSv2 and NFSv3 authenticate by IP address, which can be spoofed; NFSv4 improves this with Kerberos and secure export.
  • Configuration complexity in mixed environments: UID/GID mapping between clients and servers must be synchronized to avoid permission problems.

Installing the NFS Server on Linux

In most modern Linux distributions, the package that provides the NFS server is called nfs‑kernel‑server on Debian/Ubuntu and nfs-utils on RHEL/CentOS/Fedora. The installation process is straightforward and is performed using the corresponding package manager.

  • Update the package index: sudo apt update (Debian/Ubuntu) or sudo dnf check-update (Fedora/RHEL).
  • Install the NFS server: sudo apt install nfs-kernel-server or sudo dnf install nfs-utils.
  • Start and enable the service to boot at startup: sudo systemctl enable –now nfs-kernel-server (Debian/Ubuntu) or sudo systemctl enable –now nfs-server (RHEL/Fedora).
  • Verify that the service is active: sudo systemctl status nfs-kernel-server or nfs-server, and ensure it does not show errors.

Basic Export Configuration

Once the service is running, the next step is to define which directories will be shared and with what permissions. This is done by editing the /etc/exports file.

Each line in /etc/exports follows the format (options). For example, to share /srv/nfs/clientes with read and write access for the network 192.168.1.0/24, you would add: /srv/nfs/clientes 192.168.