File sharing using NFS
According to me, NFS wins hands down every time when it comes to file sharing between Linux PCs. The setup configuration is minimal and in less than 60 seconds, two Linux boxes can be talking nicely to each other. Importantly, it is super stable in comparison to Samba, et al. I have never ever seen NFS break.
Here is my cheat sheet for setting up NFS sharing between my Linux PCs.
-
Install NFS
Open a terminal and install NFS server:sudo apt install nfs-kernel-server
-
Configure NFS
Edit the NFS exports file:sudo nano /etc/exports
Add the following line to share a specific folder:
/path/to/shared/folder <IP address of the other PC>(rw,sync,no_subtree_check)
-
Export the Shared Directory
Run the following command to export the shared directory:sudo exportfs -a
-
Start NFS Service
Ensure the NFS service is running:sudo systemctl start nfs-kernel-server
-
Open the NFS port to one specific IP
Expose the NFS default port 2049 to one specific LAN IP address only:sudo ufw allow from <IP address of the other PC> to any port 2049
-
Access the Shared Folder
On the other Linux PC, mount the shared folder:sudo mount <IP address of the first PC>:/path/to/shared/folder /mnt
You can now access the shared files in the
/mnt
directory.To unmount the shared folder:
sudo umount /mnt