NFS file sharing server and client on Ubuntu Linux

When you want to share files between Linux and Windows machines you don't have a lot of choice, you end up using Samba. This situation is very common so most Linux distributions including Ubuntu Linux make configuring Samba a breeze. But what if you want to share files between Linux PCs? Sure you can use Samba but you have more flexible and faster choice - NFS (Network File System). In this article I'll show you how to do basic NFS server and client setup on Ubuntu Linux and other Ubuntu based distributions.

NFS server

First lets install our NFS server. You can paste these commands to your terminal:

sudo apt-get install nfs-common portmap nfs-kernel-server

Second step is to add your directories to the /etc/exports file using your favorite text editor, I'll use Nano editor like this:

sudo nano /etc/exports

Inside /etc/exports file you will find some examples on how to specify directories and things like allowed clients. For detailed documentation you can consult users manual pages using man exports command. For basic sharing of your documents directory you would put something like this at the end of /etc/exports file:

/home/Documents    *(rw,sync)

Now save the file by pressing Ctrl^X and run exportfs command to apply changes. Also make sure nfs-kernel-server and portmap services are started correctly like this:

sudo exportfs -a
sudo service nfs-kernel-server restart
sudo service portmap restart

NFS client

On the client PC you must install following packages:

sudo apt-get install nfs-common portmap

Also you must make sure portmap service is started correctly:

sudo service portmap restart

To mount Documents directory shared from your NFS server you should make destination directory on your client PC like this:

mkdir ServerDocuments

Then you can use following command to mount shared Documents directory from NFS server with IP address to ServerDocuments directory on NFS client.

sudo mount -t nfs ServerDocuments

That's it. You should now be able to see contents of your Documents directory from NFS server inside your ServerDocuments directory on your NFS client.

One more thing. To browse all NFS shares for NFS server with IP address you can use showmount command like this

showmount -e

I wish you happy file sharing!


A quality focused Magento specialized web development agency. Get in touch!

7 thoughts on “NFS file sharing server and client on Ubuntu Linux

  1. Florin

    It surely is not faster than sharing using Samba! That one is completely automatically and it takes 2 seconds to set it up. 🙂

  2. Gordon Dracup

    NFS is fine in a traditional Client/Server setup where the server is on 24/7. For home networks and distributed networks where files are over several machines that are powered up and down frequently, NFS will hang the machine if it looses a connection to a NFS shared folder.

    Not sure what the solution is, but it shouldn’t be this hard and should work out of the box.

    IMO off course 🙂


    1. Marko Author

      This is true but I guess NFS devs didn’t go into making it more user friendly because of Samba project with main goal of being cross platform and user friendly. But NFS is much faster on my network than Samba. And yes it does sometimes hang when you turn off NFS server machine, if I find solution I’ll post here. Anyways solution should be on the client side to give up on NFS shared folder after reasonable timeout without connection I guess…


Leave a Reply

Your email address will not be published. Required fields are marked *