Linux Mint – Sharing files with NFS

How to Install Docker on macOS

As mentioned earlier, NFS is another method of sharing files on a Linux machine. NFS is a very worthy choice, especially if all your computers are running on Linux. If you have a mixed environment, Samba would be the preferred choice. To get started, you’ll need to install the nfs-kernel-server package. You can do this via the following command:

sudo apt-get install nfs-kernel-server

Once it is installed, you’re ready to configure NFS. However, unlike Samba, we’ll need to use shell commands in order to get NFS going. The configuration file responsible for NFS shares in Linux is the /etc/exports file, which we’ll need to edit by opening it using the following command line:

sudo nano /etc/exports

To share a folder on your system, enter a line similar to the following one at the end of the file:


Now, we’ll walk through that line so that you’ll be able to deduce how to translate it to fit in with your own system. First, /home/jdoe/MyShare is the folder that we want to share on the network via NFS. Change this to the path of the folder you want to share on your own system. Next, we have an IP address of Notice how the IP address ends in a zero; this is not typical. The zero signifies that we want to allow any computer on the 192.168.1.x network to access the share. You’ll need to change this to the IP addressing that’s being used on your network (use the ifconfig command if at all you are unsure). Next, we add rw to clarify that we want to allow others to read and write to the file. We would have used ro if we wanted a read-only access. Next, we add the sync option, which, in short, helps prevent file corruption, should the server go down before a file has finished being written to the disk. Finally, we have the no_subtree_check option, which helps reduce problems when files are being renamed.


If you plan on using NFS, it’s recommended that you peruse the man pages for some additional reading for a better understanding of its options, as a tutorial on every available NFS parameter is beyond the scope of this tutorial. To read more about NFS and its options, consider executing the man exports command.

Now that you have configured a share via NFS, the next step is to access this share with another computer. As mentioned earlier, NFS is primarily targeted to the Linux and UNIX systems, as Windows computers cannot access these shares by default without installing the service for the NFS package, which is limited to certain editions of Windows. To mount an NFS share in Linux, first ensure that the nfs-common package is installed on the system using the following command line:

sudo apt-get install nfs-common

Then, we’ll need a folder to mount the share. You can use an existing (preferably empty) folder or create a new one. You can mount an NFS share virtually wherever you have the permission to access it. To mount an NFS share, use the following sample command as a guide:

sudo mount -o rw /mnt/MyShare

In the preceding command line, the IP address of the machine hosting the NFS share is, so you’ll need to replace this with the IP address of your machine. Then, we have a colon followed by the path to the share on the hosting machine. Finally, we have a space and then the path of the filesystem’s location on the local computer where we want to access the share. In this example, a folder named MyShare was created in the /mnt folder, so the files contained in /home/jdoe/MyShare on the hosting machine will appear in the /mnt/MyShare folder on the local machine. Once you’re finished with the share, you can unmount it to disconnect it from your system using the following command line:

sudo umount /mnt/MyShare

Comments are closed.