How to Install NFS Server and Client on RHEL-based Distributions

In Linux, there are a couple of file-sharing protocols used to share storage and files across a network. The most widely used ones are Samba and NFS.

Samba is a popular open-source application suite that works in a client-server architecture. It offers cross-platform compatibility enabling seamless file sharing across Linux, Windows, and macOS operating systems. A file share hosted on a Linux system can be accessed from diverse platforms, thus fostering collaboration.

Another widely used file-sharing protocol is NFS, short for Network File Share. Just like Samba, it works on a client-server model and allows a user to share directories and files across a network with multiple remote client users.

In this guide, we will check out how to install the NFS server and client on RHEL-based distributions such as Fedora, CentOS Stream, Rocky Linux, and AlmaLinux.

NFS Services

Currently, there are 3 versions of NFS, the latest one being NFSv4 which includes features such as the ability to work over the internet and across a firewall. In addition, there is NFSv3 and NFSv2 which is the oldest protocol.

The NFS service is made up of the NFS Server and client. The NFS server comprises the following key files:

  • nfs-server – This allows client systems to access the NFS-shared files.
  • rpcbind – converts RPC programs to universal addresses.
  • nfs-idmap – Carries out the translation of the user and group IDs to names and user and group names into IDs.
  • portmap – This is a server that converts RPC program numbers to IP port numbers.
  • nfslock – In case of an NFS server crash, the nfslock starts the required RPC processes.

NFS Configuration Services

Here are some of the key configuration files for NFS:

  • /etc/exports – The main configuration file, which stipulates the filesystems or directories to be exported and accessed by remote users.
  • /etc/fstab – This is a file that contains entries of mounted partitions. In NFS, the file contains entries of NFS share directories or filesystems which are permanently mounted and can persist a reboot.
  • /etc/sysconfig/nfs – It defines the ports needed during the running of RPC services.

NFS Server and Client Setup

To set up NFS shares, we’ll need at least two Linux/Unix machines. Here in this tutorial, I’ll be using two servers.

  • NFS ServerRHEL 9 with IP
  • NFS ClientRHEL 9 with IP

Install NFS on Server and Client

To start off, you need to log into both nodes (NFS server and client) and install the NFS services. First, update the package information as shown. The following dnf command will also upgrade all the exciting packages to their latest versions.

$ sudo dnf update 

Once the update is complete, proceed and install the requisite NFS services.

$ sudo dnf install rpcbind nfs-utils -y
Install NFS in Linux
Install NFS in Linux

The next step is to enable the NFS services as shown.

$ sudo systemctl enable nfs-server
$ sudo systemctl enable rpcbind

Be sure to also start the NFS services.

$ sudo systemctl enable nfs-server
$ sudo systemctl enable rpcbind

It’s crucial to verify that all the NFS services are running.

$ sudo systemctl status nfs-server
$ sudo systemctl status rpcbind
Check NFS Status
Check NFS Status

Be sure to also configure the firewall in order to allow inbound NFS services as follows.

$ sudo firewall-cmd --permanent --add-service={nfs,rpc-bind,mountd}
$ sudo firewall-cmd --reload

Create an NFS Share Directory

With all the NFS services installed and running as expected, it’s time to create the NFS share directory, which is the directory that will contain files that will be accessed by NFS clients in the network.

In this case, we will create an NFS share directory called my_nfsshare in our home directory.

$ mkdir -p /home/tecmint/my_nfsshare

Next, assign directory permissions. For demonstration purposes, we will assign global permissions that will accord NFS clients read, write, and execute permissions.

$ sudo chmod 777 -R /home/tecmint/my_nfsshare
Create NFS Share Directory
Create an NFS Share Directory

Export an NFS Share Directory

The next step is to export the NFS share directory. In order to achieve this, we need to make an entry in the /etc/exports file. Therefore, access the file using your preferred text editor. In this case, we will use the Vim editor.

$ sudo vim /etc/exports

Add the following entry. Be sure to replace the server-ip with your NFS server’s IP address.

/home/tecmint/my_nfsshare server-ip/24(rw,no_root_squash)

Finally export the NFS share directory or filesystem.

$ sudo exportfs -rv
Export NFS Share Directory
Export NFS Share Directory

Run the following command to view the NFS shares.

$ showmount -e localhost
View NFS Share Directory
View NFS Share Directory

Configure NFS Client

The remaining phase of this exercise is to configure the NFS client in order to access the shared directory. First, confirm that you can view the export list or NFS shares on the NFS server.

# showmount -e
List NFS Share Directory
List NFS Share Directory

The next step is to mount the NFS share from the server to the client. To do this, we first need to create a mount directory. In this case, we will create a directory called nfs_backup.

# mkdir nfs_backup

Thereafter, we will mount the NFS share to the mount directory that we have just created in the root home directory

# mount -t nfs  ~/nfs_backup 

To persist the NFS share, edit the /etc/fstab file.

# vim /etc/fstab

Then add the following entry.    /root/nfs_backup  nfs     defaults 0 0
Mount NFS Share Directory
Mount NFS Share Directory

Save and exit the configuration file.

Testing NFS Setup

The last step is to verify if the NFS setup is working as expected. We will create a few files on the server and verify their availability on the NFS client side.

On the server side, we will create the files in the NFS share directory.

$ sudo touch my_nfsshare/file{1..4}.txt

To verify that the files have been created, we will execute the ls command:

$ ls -l my_nfsshare/
Verify NFS Share Directory
Verify NFS Share Directory

Back to the client side, verify that the files are available in the mount directory without any service refresh or restart of any services as seen in the following output.

$ ls -l nfs_backup/
Check NFS Share Files
Check NFS Share Files

Removing NFS Mount

If you no longer need the mounted directory on your system, you can unmount them from the client side using the following umount command:

$ umount ~/nfs_backup

NFS Share Commands

Some more important commands for NFS.

  • showmount -e – Shows the available shares on your local machine
  • showmount -e ip-address – Lists the available shares at the remote server
  • showmount -d – Lists all the sub-directories
  • exportfs -v – Displays a list of shared files and options on a server
  • exportfs -a – Exports all shares listed in /etc/exports, or given name
  • exportfs -u – Unexports all shares listed in /etc/exports, or given name
  • exportfs -r – Refresh the server’s list after modifying /etc/exports

This wraps up our guide on how to install the NFS server and client on RedHat-based distributions. We have installed the NFS services on the server, created an NFS share directory, and finally mounted the share directory on the client. Lastly, we verified the NFS setup by accessing the file created on the server from the client side.

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.


Leave a Reply
  1. Found some missing files in the fedora 33 servers /etc the exports file has to be created, also I cruised thru usr/systemd.conf files, some needed a user added as only root can access some of them. Redhat has removed the “rsh” login while Debian has it, with rsh I can connect eth0 to the dell idrac port, type rsh 192.168.0.? And can log in gives tons of cli commands that the web-based idrac doesn’t seem to have, not sure there’s a difference in formats.

    Debian for some reason does not include netstat if config and FTP? Also, fedora7 and 8 had rwhod, whois, telnet, FTP, apache web server. The fefora33 server I’m using lacks these old tools and I’m not sure if I’m getting past the firewall other than pinging my idrac on my dell server!

    Unfortunately, I have to go online to ad nfs files to make it work in the fedora33 server. I noticed you used init.d but redhat and its subsidiary ones all use the system.d in their configuration, so init.d might not work on a redhat/fedora/centos box!

  2. I have one doubt, why he did not add some services to the firewall without adding? it is possible.

    below are some of the services – nfs-server, rpcbind mounted,

    can some confirm

  3. I had difficulty getting the server to reboot, the solution for me was to change the /etc/fstab on the nfsclient to the following:

    nfsserver:/var/nfsshare/work /opt/work nfs defaults,_netdev,x-systemd.after=nfs-server.service 0 0

  4. This is one of the easiest installation. But this is not as simple as this is mentioned in the blog. Here the consideration is taken when the Firewall is stopped.

    Which specific ports to be allowed for NFS server to work properly. Only allowing NFS service is firewall is not working. It keeps on giving error of portmapper and something like that.

    I am doing it on CentOS 7, NFS server does not work independently so allowing NFS port is not making any difference

  5. Thank you for the article. I think you need to add the line “run exportfs -a command” after creating a entry in /etc/exports file without running that command shares wont be accessible from clients.

  6. Hi,

    I have mounted directory from windows server to Linux server. When I run mount -a on Linux server, it gives error:

    mount.nfs: /directory_name is busy or already mounted.

    I want to know the root cause for this. I know this can be solved by unmounting that directory and mounting again but what is the root cause?

  7. This information is spread out in so many places across the web, so thank you for this concise write-up.

    I got this up and running except I’m unable to permanently mount the export directory so that my client automatically loads it. I did something bad to fstab and my computer (R Pi) would not boot. Had no choice but to reformat it.

    Got it to work fine by manually mounting, so I know I’m close…thanks for any pointers!

  8. First, I thank you for your lessons, they’re one of the best.

    In preparation for the LFCS exam, knowing that some commands are deprecated and some files changed, for example:

    [root@nfsserver ~]# /etc/init.d/portmap start
    [root@nfsserver ~]# /etc/init.d/nfs start
    [root@nfsserver ~]# chkconfig --level 35 portmap on
    [root@nfsserver ~]# chkconfig --level 35 nfs on

    These are not available in latest Centos 7.

    Does one has a choice of the version of Linux machine to use in the exam? As I am new to Linux, I am only conversant with latest commands.


  9. Hi Tarunika,

    Thanks for such a nice article on NFS server and client. It will help the readers to resolve NFS related issue.

    Best Regards

  10. Hi ,

    Thank you for sharing this article, very helpful ,

    when we are mounting with rw permissions in client side, can we restrict root/normal user to delete this nfs shared folders from client side.

    My Export config in server side

    /files   (rw,all_squash,anonuid=99,anongid=99)

    Mounting with below command

    mount -t nfs -o rw   ipaddresss:/files/frontend_shared /fe_shared/

    please advise.


  11. mount -v -t nfs /root/temp
    mount.nfs: timeout set for Mon Jan 8 23:05:38 2018
    mount.nfs: trying text-based options ‘vers=4.2,addr=,clientaddr=’
    mount.nfs: mount(2): Protocol not supported
    mount.nfs: trying text-based options ‘vers=4.1,addr=,clientaddr=’
    mount.nfs: mount(2): Input/output error
    mount.nfs: mount system call failed

    journalctl | tail -1
    Jan 08 23:06:30 kali kernel: NFS: nfs4_discover_server_trunking unhandled error -22. Exiting with error EIO

  12. On CentOS 6.x i got error “unable to register (RQUOTAPROG, RQUOTAVERS, udp)”, “Connection refused”.

    I had to start & enable rpcbind service:
    service rpcbind start;chkconfig rpcbind on

  13. Really a very help instructive article.

    I have mounted a directory of one system on another.

    Now I am not able to create file/folder from that client system into this mount point.

    How can I create file or folder from that client system into the mount point i.e. into the shared directory of the server?

      • Thanks Ravi for the quick suggestion.

        rw permission was already given.
        However the root_squash applied on the server shared directory was denying the permission to create files in it from the client machine.
        Using no_root_squash solved the issue.

    • @Mustaque,

      Same procedure, manually mount the nfs share on client machines, or if you have good scripting skills you can automate it..

    • @Sriram,

      Please follow the instructions carefully, as we’ve already mentioned which commands should be run on Server and Client..

  14. Hi this really worked but one thing is missing we need to start the nfs service on both the node with the below command.

    # service nfs start
    Starting NFS services:                                     [  OK  ]
    Starting NFS quotas:                                       [  OK  ]
    Starting NFS daemon:                                       [  OK  ]
    Starting NFS mountd:                                       [  OK  ]

    Once this status is OK then we can see the mount points in nfs client..

    • Please restart the rpcbind/portmap, nfs service in server side and check firewall (stop firewall and try then add respective ports in firewall, make firewall on )

    • By default, NFS shares change the root user to the nfsnobody user, an unprivileged user account. In this way, all root-created files are owned by nfsnobody, which prevents uploading of programs with the setuid bit set.
      If no_root_squash is used, remote root users are able to change any file on the shared file system and leave trojaned applications for other users to inadvertently execute.

  15. Hello,

    Would this work to mount an entire raid from one Red Hat Server to an Ubuntu server? How can I mount the entire raid volume? Thanks!

    • @Sanjeev,

      To mount nfs share with username and password in Linux, you should add following entry in your fstab file. /mnt nfs user=administrator,password=pass 0 0

      And don’t forget to change above values as per your requirements.

  16. I’m learning Linux.

    I have created users in /home/export directory server side, exported and shared to particular ip address..
    On client side I have mounted that directory to home directory and I got error i.e,

    No such file or directory on /etc/fstab

    1. is this possible to share the user’s in NFS?
    2. if s please let me know solution for above process?

    • @Irfan,

      You can’t mount to /home directory, you can only mount all external drives under /mnt directory, try mounting NFS share directory to /mnt and then see..

  17. I am using Linux Mint 17.3

    When I enter the command:
    $ sudo apt-get install nfs-utils nfs-utils-lib

    I get:
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package nfs-utils
    E: Unable to locate package nfs-utils-lib

    • @Keith,

      Sorry for trouble, it seems in Linux Mint 17.3, you should follow these commands to install NFS.

      $ sudo apt-get install nfs-kernel-server rpcbind nfs-common

      We will update this article with new instructions to support newer version of Ubuntu and Mint distributions.

  18. is it possible to use CentOS-6 as NFS server and CentOS-7 as NFS client. I tried like this. But i got the following error.
    mount.nfs: access denied by server while mounting

    at the same time when i mounting NFS shares in a CentOS-6 version client it is fine and it is successfully mounted. But getting problem while mounting in CentOS-7 client.

    • @Nagababu,

      It seems you’ve to play with iptables, have you opened port 2049 on firewall? or else stop the iptables and give a try..

      • Got it….Both nfs server(centos 6) and client(centos 7) i’m using are in same VMWare. But while using one of my servers having centos 7 as nfs client., it was mounted successfully. Seems there is something to set in network in vmware.


  19. How can i specify size to the nfs shared directory. After mounting nfs shared directory in client system and using df -h command., it is displaying entire nfs server filesystem size as nfs shared directory. So how to specify some particular size to the nfs shared directory in nfs server. Is it possible.

    • @Nagabab

      Could you please share the screenshot or output of the df -h command so that we can better understand your problem and also it seems that you’ve added the entire filesystem in /etc/exports file, better just place the shared directory name.

      • i just added the shared directory in /etc/exports in nfs server. here is the output of df -h -F nfs in client system
        nfs server :
        nfs client :

        [root@localhost nfs_mount]# df -h -F nfs
        Filesystem Size Used Avail Use% Mounted on 28G 7.8G 19G 31% /home/temp/nfs_mount

        Here is the /etc/exports file contents in nfs server

        Nfs server is a centos in vmware. It has 30 GB of total size.

        • @Nagababu,
          Thanks for sharing the NFS configuration, it seems that nfs share under /mnt filesystem and you’re looking for directory size, so here instead using df command, try using du command which shows disk usage of directory..

  20. Hi Tarunika,
    Thanks for the step by step writeup.
    I have a issue after mounting shared nfs directory on the client.
    The owner and group of /mnt/nfsshare changes to 1002
    drwxrwxr-x 103 1002 1002 4.0K Jan 19 12:08 nfsshare

    Tried changing it as root but operation is not permitted. What thing am I missing?

    • @Shantanu,

      Are you trying to change the permission of a mounted nfs share on client machine using root user? if yes, that’s not possible, because the device is just mounted on the client machine with given rights in export file, so only the creator of share directory will have access to modify the permission..

    • Sap,
      The uid & gid seen on the client would normally be the same as seen from the server. The difference might be that the user accounts on each of the hosts doesn’t match one anothers’ uid/gid.
      For nfs, it’s important for the user accounts sharing their data via nfs to be identically configured.

  21. These yum commands have worked for me for several months. Sometime between when I last ran them in December and when I ran them yesterday, they suddenly broke. Now when I use:

    yum -y install nfs-utils-lib

    I get an error message saying: No package nfs-utils-lib is available.

    Any idea why this is happening or how to fix it?

    • @Taylor,

      I’ve just tried to install nfs-utils-lib package using yum command on my CentOS 6 and 7 servers and the package is available to install. May I know on which CentOS based distribution you’re trying to install? could you post the whole output of yum command?

    • @Hanmaiah,
      Sorry no idea about quantum tape drive, mount I think you can use mount command to mount the tape drive with the help of its device name, which you can get by fdisk or lsblk command.

  22. Hi, great post. This helped me a lot. I’ll appreciate if you would explain what is the best file-system choice when shared resource is mounting on client in their different contexts. I’ll appreciate that. Thanks in advance!!!

  23. Hi all,

    Can we have a tutorial on “Mounting NFS Share using Autofs”???

    Even we can use ‘_netdev’ instead of ‘defaults’ in fstab configuration, to avoid Boot Time Delay.

    Example: /mnt nfs defaults 0 0

    May replaced with /mnt nfs _netdev 0 0


  24. Hi, thanks for the wiki, only keep in mind that in the last version of Ubuntu, nfs-utils and nfs-utils-lib are no longer available.

  25. There is a typo in the /etc/fstab configuration section /mnt nfs defauls 0 0
    should be /mnt nfs defaults 0 0

  26. OK, needing to do a silly RSYNC across two Centos 6.5 servers has seemed to be more problematic with NFS than it used to be with Ubuntu. Security over convenience, I suppose.

    #sudo yum install nfs* -y
    #sudo nano /etc/exports
    add your export, in my case:
    #sudo nano /etc/sysconfig/iptables
    (add the following below the “*filter*, make sure to adjust IP)
    -A INPUT -s -m state –state NEW -p udp –dport 111 -j ACCEPT
    -A INPUT -s -m state –state NEW -p tcp –dport 111 -j ACCEPT
    -A INPUT -s -m state –state NEW -p tcp –dport 2049 -j ACCEPT
    -A INPUT -s -m state –state NEW -p tcp –dport 32803 -j ACCEPT
    -A INPUT -s -m state –state NEW -p udp –dport 32769 -j ACCEPT
    -A INPUT -s -m state –state NEW -p tcp –dport 892 -j ACCEPT
    -A INPUT -s -m state –state NEW -p udp –dport 892 -j ACCEPT
    -A INPUT -s -m state –state NEW -p tcp –dport 875 -j ACCEPT
    -A INPUT -s -m state –state NEW -p udp –dport 875 -j ACCEPT
    -A INPUT -s -m state –state NEW -p tcp –dport 662 -j ACCEPT
    -A INPUT -s -m state –state NEW -p udp –dport 662 -j ACCEPT

    #sudo service iptables restart
    #sudo service nfs restart

    Centos client:
    #sudo yum install nfs* -y
    make sure you can ping the shares

  27. If you want NFS service to start automatically as well as rpc bind this is what you need to do.

    Below is equivelent to “chkconfig servicename on”

    sudo systemctl enable nfs-server

    sudo systemctl enable rpcbind

  28. This is what you need to do if you are getting access denied

    1 – Update /etc/exports as this (remove IP add *)

    /nfsshare *(rw,fsid=0,insecure,no_subtree_check,async)

    2 – Set this values in configuration file /etc/sysconfig/nfs

    LOCKD_TCPPORT=32803 – This is uncommented so just add the value
    LOCKD_UDPPORT=32769 – This is uncommented so just add the value
    MOUNTD_PORT=892 – You need to add this line anwyhere
    RQUOTAD_PORT=875 – You need to add this line anwyhere
    STATD_PORT=662 – You need to add this line anwyhere
    STATD_OUTGOING_PORT=2020 – You need to add this line anwyhere

  29. Hey :)
    Really great tutorial ! Thanks a lot !
    Everything looks fine, on the server, the services are launched OK, but I have a “permission denied” on the client side, even if the showmount -e gives the good informations…
    Would you have a suggestion ?
    Thx in advance ;)

    • check shared(exported) directory. there may be ro permission. change it rw. you will not get that error.
      Thank you.

  30. there is something wrong with me
    when i write the command to mount the server
    #mount -t nfs /mnt/nfsshare
    this error appear
    mount.nfs: access denied by server while mounting

  31. Hello Siva,

    I have one external HDD, i format it in ntfs filesystem by installing fuse-ntfs-3g*.rpm package and fuse module. I have mount it in Cento OS by
    #mount -t ntfs-3g -o force.
    But the when i want to configure nfs like this.. [say mount_point : /mnt ]in Cento OS
    #vim /etc/exports
    /mnt *(rw,sync,no_root_squash)
    But when I am trying to mount from remote machine.
    [in remote machine]
    #mount -t nfs :/mnt
    Then one error message has come like this…

    #mount :/mnt failed reason given by server:permission denied.

    Please give me one solutions..

  32. Hello Siva,

    Please check if you are able to telnet the port 111 from the client to host, if no then check the rcbind service on host.

    Haffizuddin S

  33. hai,
    recently i try to mount my files using nfs .. i have 2 pcs which are packed with ubuntu 13.10.. from 1 system i used as sever ( and another one as
    i followed the procedure as u said above to install nfs on server
    for client i installed nfs-common package..
    my problem was i configure properly at the server side .. but the client side when i try to execute this line $showmount -e
    i got the following error report
    “rpc mount export: RPC: Timed out “”

    i’m not able to understand the problem from where it is.. either from server or from client side..
    tell me is there any other way to find out where the problem comes from??

    help me out how to resolve this issue!!!
    thanks in advance !!

    • first check the communication to the two systems

      server : required packets nfs -tools and nfs-utilities
      vi /etc/exports
      shareparth *(rw)
      service nfs start
      service rpcbind start
      service nfslock start
      exportfs -a
      showmount -e client
      client :
      showmount -e server
      mount -t nfs server:/path mountpoint
      vi /etc/fstab -permanent mount

  34. If you are using NFS-version4 with ext4 file system then you can direct mount
    in /net

    For Example:-
    [root@linux ~]# cd /net/

    [root@linux]# ls
    nfsshare <———– your shared directory
    [root@linux]# pwd

    Here you can find you shared directory

  35. For mounting…

    mount -t nfs /mnt/nfsshare
    mount -t nfs /mnt/nfsshare


    Which one is correct??

  36. Hi,

    Really great post i was struggling with NFS on RHEL6 from last three days, and only two tutorials helped me out one is this and other is
    Configure NFS on RHEL 6
    From your tutorials i was able to setup NFS. My system have IPTABLES & SELinux configured which blocked NFS client connection but with the help of second tutorial i was able to fix that.

  37. Hello
    Running in my Pc Fedora 19

    It’s already installed:
    #yum install nfs-utils nfs-utils-lib
    #yum install portmap

    I have a problem, when i try to start the service give me:
    [root@Pc4 init.d]# /etc/init.d/nfs start
    bash: /etc/init.d/nfs: No such file or directory

    What happen?

  38. I am running Ubuntu 10.04 LTS. I have typed apt-get install nfs-utils nfs-utils-lib but it gave error: E: Couldn’t find package nfs-utils

    How to fix this?

  39. Hi,

    If any one happened to come across the error

    Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)
    rpc.nfsd: unable to set any sockets for nfsd

    make sure that /etc/init.d/rpcbind is running

    if not please start the service and then restart the portmap

  40. While it’s easy to create an /etc/exports file (linear for N machines), it is a real annoyance to create /etc/fstab entries and mount points (quadratic for N machines). Why doesn’t anyone ever talk about using autofs for this, so that stuff just gets automounted in /net/machine/whatever-got-exported ?

    Good article, but I don’t understand why nearly all articles overlook this.


Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.