When you want to share files between Linux and Windows machines you don't have a lot of choice, you end up using Samba. This situation is very common so most Linux distributions including Ubuntu Linux make configuring Samba a breeze. But what if you want to share files between Linux PCs? Sure you can use Samba but you have more flexible and faster choice - NFS (Network File System). In this article I'll show you how to do basic NFS server and client setup on Ubuntu Linux and other Ubuntu based distributions.
First lets install our NFS server. You can paste these commands to your terminal:
sudo apt-get install nfs-common portmap nfs-kernel-server
Second step is to add your directories to the
/etc/exports file using your favorite text editor, I'll use Nano editor like this:
sudo nano /etc/exports
/etc/exports file you will find some examples on how to specify directories and things like allowed clients. For detailed documentation you can consult users manual pages using
man exports command. For basic sharing of your documents directory you would put something like this at the end of
Now save the file by pressing Ctrl^X and run
exportfs command to apply changes. Also make sure
portmap services are started correctly like this:
sudo exportfs -a sudo service nfs-kernel-server restart sudo service portmap restart
On the client PC you must install following packages:
sudo apt-get install nfs-common portmap
Also you must make sure
portmap service is started correctly:
sudo service portmap restart
Documents directory shared from your NFS server you should make destination directory on your client PC like this:
Then you can use following command to mount shared
Documents directory from NFS server with IP address
ServerDocuments directory on NFS client.
sudo mount -t nfs 10.42.43.1:/home/Documents ServerDocuments
That's it. You should now be able to see contents of your
Documents directory from NFS server inside your
ServerDocuments directory on your NFS client.
One more thing. To browse all NFS shares for NFS server with IP address
10.42.43.1 you can use
showmount command like this
showmount -e 10.42.43.1
I wish you happy file sharing!