Share files and printer between two Ubuntu boxes

I have two Ubuntu boxes and want to share files and printer between them. I'm reading about Samba but I have a question: Is Samba only for sharing thing between Ubuntu and Windows? Another question: There is a lot of information describing hot to share files and printer between Ubuntu and Windows, but what about two Ubuntu boxes? How can I do that? Is there how-to I can follow?


Solution 1:

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).

Solution 2:

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

Solution 3:

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).

Solution 4:

The above NFS mounting instructions worked for me - with one exception. I am trying to mount a shared directory on my Linux PC from a Raspberry Pi running the latest version of Raspbian (stretch). When I used the above format in the fstab on the Pi I got a format error. This was corrected by changing the entry "rsize=8192 and wsize=8192" to "rsize=8192,wsize=8192". After that I was able to do a "sudo mount -a" and everything mounted perfectly.