Setting up NFS Server on Ubuntu Server

Here's how to install and set up NFS Server on Ubuntu so you too can start sharing data with other client systems. We shall show how to set up the host server as well as show you how to set up the client-side. For this tutorial, we will be using Ubuntu 20.04 LTS.

NFS, short for Network File System, is a distributed file system protocol. It can help you share files and entire directories with others over a network. It allows programs on remote systems to share and access information with each other as if it was available on a local machine.

NFS works in a client-server environment. That is to say, if you want to set up NFS to share files between two systems, then one of them needs to be configured as a server and the other as a client.

The server functions as an admin that authenticates and authorizes the client(s) to access the shared data. Almost any number of clients can get access to the shared data as simple as any other file or directory in their local storage.

How to setup NFS Server on Ubuntu Server

So if this has got you interested, we have put together a detailed step-by-step tutorial that will guide you on how to install and set up NFS Server on Ubuntu so you too can start sharing data with other client systems. It is divided into sections, the first part discussing how to set up the host server and the second part showing you how to set up the client-side. For this tutorial, we will be using Ubuntu 20.04 LTS.

Configuring the Host Server

To set up the host server, you first need to install the NFS Kernel server. Once done, you can create and export the files and directories that you want to share with all the client systems.

So let’s get to it.

Step 1: Installing the NFS Kernel Server

First things first, we need to install the NFS Kernel Server package on the Ubuntu system that is going to function as the server. But before that, just to make sure nothing goes haywire during the process, let’s update the system packages.

To do this, type in the following command in the terminal:

$ sudo apt update

With all the system packages updates, it is time to install the “nfs-kernel-server” package using the following command:

$ sudo apt install nfs-kernel-server

This is also going to install some additional packages on your system, including “nfs-common” as well as “rpcbind” which are necessary to set up file sharing.

Installing NFS Server
Installing NFS Server

Step 2: Create NFS Export Directory

With the “nfs-kernel-server” package installed, you can now create an NFS export directory (simply known as the “export directory”), which is going to be shared with all the client systems. To do this, type in the following command inside the terminal.

$ sudo mkdir -p /mnt/nfs_share

All files that you want to be accessible to the clients needs to be created inside of this directory. Since we want the client systems to have full access to this shared directory, we need to remove all directory permissions that are restricting access.

This can be done with the following command:

$ sudo chown -R nobody:nogroup /mnt/nfs_share/

Ubuntu Terminal
Ubuntu Terminal

When done with the above command, head over to the next step.

Step 3: Assign NFS Server Access To Client Systems

With the export directory ready, you need to provide permission to your clients’ systems to access the host server. This permission is defined inside the “exports” file that’s located inside your system’s /etc folder.

You will need to edit this file and add a few extra lines of commands to give your clients’ systems access to the export directory. As such, open it using the Nano editor by entering this command into the terminal:

$ sudo nano /etc/exports

Edit file
Edit file

From here, you can provide NFS server access to either a single client, several clients, or the complete subnet. For this read, we will be providing the entire subnet access to the NFS share.

To do this, you will need to add this line to the “exports” file.

/mnt/nfs_share subnet(rw,sync,no_subtree_check)

Here you need to replace your system’s subnet in the provided placeholder.

Besides this, here is what the other parts of the command mean:

  • rw: read/write command
  • sync: changes are made to the disk first before they are applied
  • no_subtree_check: removes subtree checking

However, if you wish to grant access only to a single client, you can do so by using the following syntax:

/mnt/nfs_share client_IP_1(rw,sync,no_subtree_check)

Whereas to add multiple clients, you need to do so one by one:

/mnt/nfs_share client_IP_1(rw,sync,no_subtree_check)

/mnt/nfs_share client_IP_2(rw,sync,no_subtree_check)

With the client system having access to the NFS server, it is time to move on to the next step.

Step 4: Export the Shared NFS Directory

With all the above configurations in place, it is time that you export the shared NFS directory and makes it available to the client systems.

This is quickly done using this command:

$ sudo exportfs -a

This is followed by restarting the NFS kernel server to make sure all the configurations take effect.

Restart NFS
Restart NFS

It’s finally time to move on to the last step of this setup.

Step 5: Allow Clients to Pass Through the Firewall

Even after giving clients access to the NFS server and exporting the shared directory, clients still won’t be able to access the files if blocked by the firewall. As such, you will need to open up the firewall for your clients. Your Ubuntu PC already has a default firewall – the UFW (Uncomplicated Firewall).

To check if it’s running on your system, you can type in the following command:

$ sudo ufw status

If it shows that it’s inactive, you will need to turn it back on using this command:

$ sudo ufw enable

Check UFW status
Check UFW status

However, if for some reason it is not installed on your system, then you can use this command to install it:

$ sudo apt install

Once you have UFW installed and enabled on your Ubuntu system, you will need to configure it such that it allows access to your clients.

Since we provided NFS access to the entire subnet, we need to use this command:

$ sudo ufw allow from subnet to any port nfs

However, if you only allowed NFS access on a per-client basis, you will need to input the client IP like this:

$ sudo ufw allow from client_IP_1 to any port nfs

And that’s it! You have successfully installed and configured the NFS service on the Server computer.

Configuring the Client System

Next, we will need to install and set up NFS on the client system to access the shared directory. Similar to before, here is a step-by-step guide to help you out.

Step 1: Installing the NFS-Common Package

While setting up the client system for NFS share, we need to install the “nfs-common” package. Just like before, you should first update the system package and then install nfs-common using the following commands:

To update packages:

$ sudo apt update

To install the nfs-common package:

$ sudo apt install nfs-common

Once done, move on to the next step.

Step 2: Create a Mount Point

Next, you will need to create a mount point. It will be used to mount the NFS shared files from the NFS server. To do this, type in this command in the terminal:

$ sudo mkdir -p /mnt/nfs_clientshare

Step 3: Mount the NFS Shared Directory on the Client System

The folder that you created in the above step-functions like any other folder on your system. To access the NFS shared directory from the host server, you will need to mount it to this new folder: “nfs_clientshare”.

To do this, first, you need to know the NFS server’s IP address. Type in the following command in the terminal of the server system:

$ ifconfig

It will bring up the network interface configuration. The server’s IP is the one given under “inet,” which in our case is

if config
if config

Using this IP, type in the following command in the terminal of the NFS client to finally mount the NFS shared directory to the client system:

$ sudo mount /mnt/nfs_clientshare

Step 4: Test the Connection to See if Everything is Working

By following the above steps in order, you have successfully created an NFS server for sharing files and folders between a server system and multiple client systems.

All that remains is to check if everything is working correctly.

To do this, create a new file in the NFS shared directory that’s on the server. You can do this by using this command:

$ cd /mnt/nfs_share/
$ touch file1.txt file2.txt file3.txt

Once done, check on the client system to see if these files show up on the NFS shared directory using this command:

$ ls -l /mnt/nfs_clientshare/

If you see the files – “file1.txt”, “file2.txt”, and “file3.txt” in the list, then the NFS server is working, and you can now start sharing and receiving files between the client and server systems.

Nitish is a Technical Writer with five years of experience. He enjoys covering new tech and has a special love for Linux. He also has a keen interest in Blockchain and WordPress.


Please enter your comment!
Please enter your name here




Basics of Working with the SQLite Database in Python

A database is one of the most useful and popular files for storing data; they can be used to store any kind of data, including text, numbers, images, binary data, files, etc. SQLite is a relational database management system based on the SQL language. It is a C library, and it provides an API to work with other programming languages, including Python. It does not require a separate server process to be run as needed in large database engines like MySQL and Postgresql.

5 Ways to Check the Linux Version

When most people talk of Linux, they are always referring to a Linux distribution. However, this is not the case. Linux itself is a kernel which acts as a bridge between user applications and the hardware. When we talk of a Linux distribution, we refer to an operating system developed from the Linux kernel. A distribution comes with a package manager, pre-installed applications, a Desktop Environment, and several more features.

Getting Started with Linux Operating System

The Linux operating system brings forth a vibrant mix of features and security, making it the best alternative to macOS or Windows operating systems. In this post, we will give you a master guide on Getting started with Linux systems - taking you from a complete beginner to a level where you can begin testing the various Linux distributions available with much ease.

How to Create a Comprehensive Mail Server on Ubuntu

Postal is a free and open-source mail server used to send and receive emails. It comes loaded with tons of excellent features and functionalities, making it extremely popular among large organizations as well as in enterprise settings.

The 10 Best Linux Performance Monitoring Tools

Do you want to monitor the performance of your Linux system? Are you looking for some powerful performance monitoring tools to help you out? If you agree, it's your day as we have put together a detailed list of the ten best Linux performance monitoring tools.

How to Boot your Windows or Linux PC from a USB Drive

Sometime back, the process of installing an operating system required users to pop a bootable media disk into their DVD or CD drive and use it to boot the PC. But times have changed. Nowadays, the most common way of installing an OS is booting from a USB drive. The use of USB drives is further propelled by the current production of slim and lightweight laptops with no support for DVD/CD drives.


Buyers who wish to go for a machine that is based on Linux often show interest in Chromebooks due to the form factor and extended battery life capabilities. Although ChromeOS power these machines, users can still miss out on a more genuine Linux experience. For those who happen to agree, the new Lemur Pro by System76 might get some heads turning.
Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.

5 Things to do when your Linux system GUI freezes

All operating systems freeze at some point and, Linux distributions are no exceptions. In this post, we are going to look at five methods you can apply to your frozen system before thinking of plugging out the power cable or holding down the power button to power off the PC.

5 Best Application Launchers for Ubuntu

Ubuntu is one of the most used Linux distributions worldwide. It is also the reason why it has the maximum number of available programs for itself. Today we are going to talk about one category of those programs, the application launchers.

10 Reasons to use Cinnamon as your Desktop Environment

With the release of Gnome 3 in 2011, there was quite a mixed reaction from users and developers. Most of them preferred the original Gnome that got forked, and one of those forks was Cinnamon. Since the release of Cinnamon 2.0, Cinnamon has evolved to become a desktop environment by itself.

VIDEO: Linux Lite 4.8 Features and Desktop Tour

Linux Lite eases Windows 7 users transition to Linux much more comfortable by offering simple software like Team Viewer, VLC, Firefox, TimeShift backup utility, and a full Microsoft Office compatible office suite in LibreOffice.