This is a simple article detailing how to install NFS on CentOS/RHEL servers. NFS is used to share a directory between several Linux systems. It allows remote hosts to mount file systems over a network and interact with those file systems as though they are mounted locally on your system.

(Recommended Read: Learn to use Wget command with 12 examples)

Scenario Setup

To install & test the shared folder, we require at least 2 machines:-

  • NFS Server with IP Address:
  • Client machine to test the setup with IP Address:

NFS Installation

Firstly we will install NFS, which is easy & can be installed using the following command

# yum install nfs* -y

now, we need to start our server

# service nfs start
# chkconfig nfs on


Now, we will share a directory, lets share our home (/home) directory. Open the configuration file

# vi /etc/exports

since its an empty file, we will the following lines to the file to share /home folder

/home (rw,sync)

S0, the above line means

/home is the directory to be shared, will be the subnet range for which the shared folder will be available, you can just mention a single IP here,

rw means the client will have both read & write permissions. You can also use ro for read-only.

Now, restart the service to implement changes to the server,

# service nfs restart

Our shared folder is now ready to be used.

Note: If we are giving rw (read, write) settings on nfs share, make sure the permissions on the folder are 777.

Testing shared folder

On the Server, use the following command to show the shared folder

# mountfs -V                                           

& on the client-side, use the following command to see the shared folder

# show mount -e

Client-side configuration

On the Client-side, we will have to firstly install nfs

# yum install nfs* -y

we will now mount the shared folder to /mnt

# mount /mnt

so the above command will mount the shared folder, which we can use as a regular partition. But this will only be a temporary mount i.e. when we restart our system, our mount will be lost.

Therefore in order to permanently mount the shared folder, we need to make an entry in /etc/fstab

# vi /etc/fstab

After opening fstab, make the following entry at the bottom of the file, /mnt nfs defaults 0 0

& drive will remain mounted even after the system reboot.

Important commands which might come handy,

  1. showmount -e :  Shows the available shares on your local machine
  2. showmount -e <server-ip or hostname>:   Lists the available shares at the remote server
  3. showmount -d :  Lists all the subdirectories
  4. exportfs -a :  Exports all shares listed in /etc/exports, or given name
  5. exportfs -v :  Displays a list of shares files and options on a server
  6. exportfs -r :  Refresh the server’s list after modifying /etc/exports
  7. exportfs -u : Unexports all shares listed in /etc/exports, or given name

and in our future tutorials, we will also be discussing VSFTP (very secure FTP) server & Samba server.

So, if you have any questions/comments about this tutorial on NFS installation & configuration, please write them down below. I will surely address them.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter

Linux TechLab is thankful for your continued support.