NFS or Network File System is used to share files of folders between Linux systems. With NFS, you can handle remote files and folders same like local files or folders.
In this tutorial, I will share you how you can install and configure NFS between two system.
Suppose, we have two system, and we want to share folders of one system to aonther. The hosing server's folder will be access by client.
First of all we need to install NFS package in both system. use the below command to install in Debian based distribution system.
sudo apt install nfs-kernel-server
For Fedora distribution use below command.
sudo dnf install nfs-utils
nfs-server is automatically starts when you install. Else you can start manually with below command.
sudo systemctl enable --now nfs-server
In this article, I want to share
/home/nfs. So create directory from the Terminal.
To share the files or folders in nfs, we need to add this folder in /etc/exports.
sudo nano /etc/exports
Add the below line at the end of file.
At the end load new configuration using below command.
sudo exportfs -a
So we have configured in the host server. Now we will going to configure client system.
For the client we need to install below package.
Debian based distribution system:
sudo apt install nfs-utils nfs-utils-lib
Fedora distribution system:
sudo dnf install nfs-utils nfs-utils-lib
When the package is installed, You need to mount NFS share folder of remove server into your local filesystem.
mount -t nfs 192.168.0.6:/home/nfs /mnt/nfs
The above command will generate new folder
/mnt/nfs in your local system.
The last option is to mount the remote directory permanently on your system, so it will remain even after client reboot the system.
For that you need to edit
/etc/fstab file. Open the file in nano editor.
sudo nano /etc/fstab
And add the below line anywhere in the file.
192.168.0.6:/nfs /mnt nfs defaults 0 0
Save the file and lastly run the below command.
sudo mount -a
That's it. The local client can access, edit the folder of remote server. I hope it will help you.