The decision of using NFS or Samba only depends on who you are sharing with. Linux can communicate with NFS and SAMBA, but Windows can communicate only with SAMBA.

To learn about SAMBA file-sharing read the following post: SAMBA Server and Client on Ubuntu 20.04 [Link].


SERVER – NFS CONFIG

sudo apt-get update
sudo apt-get install nfs-kernel-server rpcbind -y
sudo ufw allow nfs
sudo nano /etc/exports

Add this line at the end of the file:

/home/ubuntu 192.168.2.0/24(rw,sync,no_subtree_check)

Customize this command to meet your network:

/home/ubuntu The directory being shared.
192.168.2.0/24 Your network ID (check your network).
rw Read and Write (ro would be Read Only).

To know your network address issue:

hostname -I

Ignore the IPs starting with ‘127‘, and use the first three blocks of the IP according to your network to replace ‘192.168.2‘.

sudo systemctl restart nfs-kernel-server
sudo systemctl status nfs-kernel-server
OR

sudo service nfs-kernel-server restart
sudo service nfs-kernel-server status

When the service is running use the following command to apply changes on /etc/exports:

sudo exportfs -ra

To check the shares on a NFS server locally:

showmount -e

CLIENT – NFS MOUNT

sudo apt-get update
sudo apt-get install nfs-common -y

Check connectivity:

showmount -e 192.168.2.40

To eventually mount one remote share in a local file system issue:

sudo mount 192.168.2.40:/home/ubuntu /tmp/file-server

Customize this command to meet your network:

192.168.2.40 IP address of the server.
/home/ubuntu The directory being shared in the server.
/tmp/file-server Local mounting point.

The directory ‘/tmp/file-server‘ has to exist in the local file system. If it does not exist issue:

sudo mkdir /tmp/file-server
sudo chmos 755 /tmp/file-server

The following command unmounts from the local computer:

sudo umount /tmp/file-server

To make it automatically mount on the boot:

sudo nano /etc/fstab

Add this line at the end of the file:

192.168.2.40:/home/ubuntu /tmp/file-server nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0

Customize this command to meet your network:

192.168.2.40 IP address of the server.
/home/ubuntu The directory being shared in the server.
/tmp/file-server Local mounting point.
nfs Specifies the protocol ‘nfs‘.
auto,nofail,noatime,nolock,
intr,tcp,actimeo=1800 0 0
Keep these arguments as they are.

Restart the client computer and check if the share was automatically mounted.