Directory Share - NFS,CIFS
Network File Share (NFS) and Common Internet File Share (CIFS) are both use for directory sharing. One purely between UNIX/Linux systems (NFS) and the other between UNIX/Linux and Windows Systems (CI
Network File System (NFS)
NFS was introduced by Sun Microsystems and is used between UNIX/Linux Systems for directory/file sharing and uses port
Configure and Install on Linux (Ubuntu 20.04)
Server:
Step 1: Install NFS software
Install the nfs-kernel-server
package onto the server. We need to update the system packages before we install:
sudo apt update
sudo apt install nfs-kernel-server
Step 2: Create a NFS Export Directory
Create a directory that will be shared among all client members. This is also known as the 'export directory' To restrict access to these files we will add the respective users to the specific groups for that share.
sudo mkdir -p /mnt/nfs-share
Step 3: Create Groups, Add Users To Groups and Change Permissions
We will now create a group that the users will belong to to access the files within the shared NFS directory
sudo groupadd nfs_share
To list all the groups we can use the
cat /etc/group
commandWe will now create a user and add that user to the group. We don't want the users to be able to login to the server using ssh (ie no shell) and having a home directory
They must just be able to access the shared directory by their username and that username belonging to the nfs-share group.
We normally user the command adduser <user> command which will create a user and home directory,but if we use the
sudo useradd -M james.smith --shell /bin/false
command and we can create a user without a home directory and no shellsudo useradd -M james.smith --shell /bin/false
sudo passwd james.smith
We want users to belong to the nfs_share group, so we add them using the 'usermod -aG' command which ammends their username to the group G
sudo usermod -aG nfs_share james.smith
We need to change the permissions on the "export directory" we created above:
sudo chown -R nobody:nfsshare /mnt/nfsshare
sudo chmod -R 770 /mnt/nfs_share
S
Last updated
Was this helpful?