Network file system is a simple way to share files and folders over the network. NFS is developed by Sun Microsystems in 1980. NFS is very popular in the Linux and Unix world. NFS is an alternative for SMB which is Windows ecosystem file-sharing protocol. We will look at how to install the NFS server, share files and mount shares in this tutorial with some extra configurations.
Install NFS
Installing NFS can be done for Ubuntu, Debian, Kali, Mi
Ubuntu, Debian, Kali, Mint:
$ sudo apt install nfs-common

Fedora, CentOS, RedHat:
$ yum install nfs-utils.x86_64

Man
Manpage for NFS daemon or simple server can get like below.
$ man nfsd

Configuration Files
NFS server works as a daemon as expected. Daemon configuration file is by default in /etc/default/nfs-kernel-server
for Ubuntu-based systems
Ubuntu, Debian, Kali, Mint:
/etc/default/nfs-kernel-server
Fedora, CentOS, RedHat:
/etc/nfsmount.conf
Services
NFS server has more than one service to share files and folders.
Export File
Shares are generally defined in different configuration files than daemon configuration files. NFS shares are called exports
and stored into /etc/exports
. Below we can see the default export file.

As we see in this file some examples of shares are defined in comments which have no effect.
Create Share
As stated previously to create share an entry should be created in the export file. We will create a simple entry that does not have advanced attributes. Say our directory we want to share is located at /share
.
Put the following line to the /etc/exports
/share *
Reload NFS Server
We have to change the configuration of the NFS server and created a new share to enable the new configuration we should reload the server.
Ubuntu, Debian, Kali, Mint:
$ sudo systemctl restart nfs-server.service

Fedora,CentOS, RedHat:
systemctl restart nfs-server.service

List Shares
NFS has the ability to list shares. This feature is similar to SMB. We will run list command from our client named ubu2
. While trying to list share there can be an error like clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)
which simply means a network access error. Generally, firewalls will prevent access to the NFS service to get a share list. Create appropriate rules to access these services.
$ showmount -e 192.168.122.179

Mount NFS Share
NFS shares can be mounted to the local system with regular mount command and NFS related parameters. To mount NFS share NFS file system libraries must be installed which is provided by NFS packages we have previously installed.
$ mount -t nfs 192.168.122.179:/share mnt

- While mounting shares NFS type provided with
-t nfs
- And remote NFS share specified
192.168.122.179:/share
- Local mount path is working directory
mnt
Unmount NFS
Unmounting is the same as regular disk-based file systems. This will unmount the NFS file system. We will unmount the path /mnt
in this example.
$ sudo umount mnt
