Learn how to configure an NFS server in Linux step-by-step. Don’t miss out on mastering this essential skill for seamless file sharing across systems—your Linux expertise isn’t complete without it! #centlinux #linux #nfs
Table of Contents
What is NFS Server?
An NFS (Network File System) server is a protocol that allows for the sharing of files and directories over a network. Developed by Sun Microsystems in 1984, NFS enables users to access and manipulate files on remote systems as though they were local, providing a seamless and integrated file sharing experience across different machines.
Key Features of NFS
- File Sharing: Allows multiple users and systems to access shared files and directories over a network.
- Transparency: Provides transparent access to files on remote systems, making them appear as if they are on the local machine.
- Scalability: Can be used in both small and large network environments, scaling efficiently as the network grows.
- Compatibility: Supports various operating systems, including different Unix flavors and Linux distributions.
- Security: Can be configured with different security measures, such as Kerberos authentication, to ensure secure file access.

Common Use Cases
- Centralized File Storage: Storing files on a central server to be accessed by multiple clients.
- Home Directories: Hosting user home directories on a server to be accessed from any client machine in a network.
- Backup Solutions: Facilitating centralized backups by accessing and storing data from multiple machines on a central backup server.
- Collaboration: Enabling multiple users to work on shared projects and files stored on a server.
NFS simplifies network file sharing, making it an essential tool in many enterprise environments.
Recommended Training: Complete Linux Training Course to Get Your Dream IT Job 2025 from Imran Afzal

Linux Server Specification
In this article, we will configure NFS Server in Linux and mount the shared directory at the Client.
We are using two Red Hat Enterprise Linux (RHEL) 7 servers. We will use one as the NFS Server and the other as the NFS Client.
NFS Server: | nfsserver.example.com |
NFS Client: | nfsclient.example.com |
Operating System: | RHEL 7.0 |
Read Also: Configure NFS Share for Group Collaboration
Anker Prime TB5 Docking Station, 14 Ports Thunderbolt 5 Docking Station with 140W Max Charging, 120Gbps Max Transfer, Ambient LED Lighting, Cooling System, Up to 8K Display for Thunderbolt 5/4 Laptops
$399.99 (as of May 15, 2025 16:15 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Configure NFS Server in Linux
Connect to nfsserver.example.com using ssh as root user.
To configure NFS Server, we have to install nfs-utils package. Usually, this package is automatically installed during installation of Red Hat Enterprise Linux (RHEL) or CentOS 7. However, you can install it anytime using yum command.
yum install -y nfs-utils
nfs-utils is already installed on our system.
Create a directory to share with other clients.
mkdir /nfsshare
chgrp nfsnobody /nfsshare/
chmod g+w /nfsshare/
We have created a directory /nfsshare, changed its group to nfsnobody and w rights has been given to group. So, the anonymous users can create files on this shared directory.
Adjust SELinux type of the /nfsshare directory.
semanage fcontext -a -t nfs_t "/nfsshare(/.*)?"
restorecon -Rv /nfsshare/
Output:
restorecon reset /nfsshare context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:nfs_t:s0
If semanage command does not available on your system then install policycoreutils-python package.
Now export/share this directory to specific clients via NFS.
echo '/nfsshare nfsclient.example.com(rw,sync)' >> /etc/exports
exportfs -r
Enable and start the nfs-server service.
systemctl start nfs-server
systemctl enable nfs-server
Allow nfs and other supplementary services through Linux firewall.
firewall-cmd --permanent --add-service={mountd,nfs,rpc-bind}
firewall-cmd --reload
NFS Server has been configured.
Disarming Code: System Programming, Debugging & Reverse Engineering in Linux, Android, Darwin
Now retrieving the price.
(as of May 15, 2025 16:15 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Configure NFS Client
Connect to the nfsclient.example.com and install nfs-utils package.
yum install -y nfs-utils
Create a directory, to mount the shared directory from nfsserver.example.com.
mkdir /mnt/nfsshare
Check the shared directories from nfsserver.example.com.
showmount -e nfsserver.example.com
Output:
Export list for nfsserver.example.com:
/nfsshare nfsclient.example.com
Persistently mount this shared directory by adding following entry in /etc/fstab.
echo 'nfsserver.example.com:/nfsshare /mnt/nfsshare nfs defaults,_netdev 0 0' >> /etc/fstab
mount -a
Check the status of mounted directory.
mount | grep nfs
Output:
nfsserver.example.com:/nfsshare on /mnt/nfsshare type nfs4 (rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.116.202,local_lock=none,addr=192.168.116.200,_netdev)
Create a file in this shared directory, to verify the file permissions.
cd /mnt/nfsshare/
touch test1
ls -al
Output:
total 0
drwxrwxr-x. 2 root nfsnobody 18 Jul 31 07:32 .
drwxr-xr-x. 4 root root 31 Jul 31 07:23 ..
-rw-r--r--. 1 nfsnobody nfsnobody 0 Jul 31 07:32 test1
We have successfully configure NFS server and client on CentOS/RHEL 7 and persistently mount the NFS share on that client.
However, this NFS share is not secured and anyone can write on this directory. For configuring a secure NFS share, you should read our article Configure a Kerberized NFS Server in RHEL 7.
Frequently Asked Questions (FAQs)
What is an NFS server, and what is it used for?
NFS (Network File System) allows sharing files and directories between Linux systems over a network. It’s useful for centralized storage and accessing files remotely.
What do I need before setting up an NFS server?
You need a Linux system with administrative (root) access, a stable network connection, and the NFS software package installed.
Which directories can I share using NFS?
You can share any directory, but common choices include /home
for user data or /var/www
for web servers. Ensure the directory has proper permissions.
How do clients access the NFS shared directory?
Clients must have NFS utilities installed and use the mount
command (or /etc/fstab
) to connect to the server’s shared directory.
Is NFS secure for sharing files over a network?
Basic NFS lacks encryption, so it’s best used in trusted local networks. For better security, restrict access via firewall rules and IP-based permissions.
BlingKingdom 10 PCS Blue Switch Replacement 3 PIN Blue Mechanical Keyboard Switches Clicky Accurate Typing, Dustproof Keyboard Switch for LED Keyboard, Mechanical Gaming Keyboard
$4.89 (as of May 15, 2025 16:15 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Final Thoughts
Now that you’ve seen how straightforward it is to configure an NFS server on Linux, you’re just one step away from simplifying file sharing across your network. Imagine the time and effort you’ll save with a centralized solution that just works. Don’t let this crucial admin skill slip by—others are already optimizing their environments with NFS.
Take action now and implement what you’ve learned—your future self (and your infrastructure) will thank you!
Need a dependable Linux system administrator? I specialize in managing, optimizing, and securing Linux servers to keep your operations running flawlessly. Check out my services on Fiverr!
Leave a Reply
You must be logged in to post a comment.