Share files and printer between two Ubuntu boxes

Use NFS to share file between systems if there is no windows involved, it is so easy.

Install nfs-kernel-server Install nfs-kernel-server and nfs-common Install nfs-common on the computer that has the files to be shared. These can be installed in the Software Center, or however you prefer to install packages. You can install them on the command-line with:

sudo apt-get update && sudo apt-get install nfs-kernel-server nfs-common

You need to edit the exports file that shows what to share and with whom. So run:

gksu gedit /etc/exports

For example, to give full read and write permissions, allowing any computer from 192.168.1.1 through 192.168.1.255, add this line to /etc/exports:

/directory_to_share 192.168.1.1/24(rw,no_root_squash,async)

My daughter's export file looks like this (I am .201--we are not using a range, just one IP):

/home           192.168.0.201(rw,sync,no_root_squash,no_subtree_check)
/srv/nfs        192.168.0.201(rw,sync,no_subtree_check)

Restart the NFS server by running:

sudo /etc/init.d/nfs-kernel-server restart

(Or reboot the computer.)

From now on after editing the /etc/exports file, you can just run sudo exportfs -a to apply the changes.

The showmount command will tell you that all went well--for example, on my daughter's computer, it shows she will share these two things with my computer @ .201 (me) if requested

$ showmount -e
Export list for jamie-desktop:
/srv/nfs 192.168.0.201
/home    192.168.0.201

Then install nfs-common Install nfs-common on the computer that wants to mount the export shares as part of its file system.

An fstab entry must be added to have your computers nfs-client mount another computers exports @ boot time. gksu gedit /etc/fstab will edit the required file.

 192.168.0.200:/srv/nfs  /media  nfs  rsize=8192 and wsize=8192,noexec,nosuid

Reboot and the share is mounted in /media.

Set up a server on the client and client on the server for two-way shares.

You can print to a shared printer with CUPS (as mentioned in this answer).


For sharing files between Linux/Unix hosts over a trusted network NFS is usually the best option.


You can use Samba the same way to share between 2 Ubuntu machines.

Alternatively, you can also use CUPS directly to share printers, and one of the other supported network filesystems to share files (or if you have a SSH server set up, just use sftp:// in Nautilus).

One possible advantage of using Samba is that it will also work if you ever need to share something with a Windows or Mac OS X user (e.g. a visitor with a laptop).