Share files and printer between two Ubuntu boxes

62,654

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.

Solution 5

You can use the built in Ubuntu One for file sharing easy and straight forward to setup.

This article should help with sharing printer, but it is mostly dependent on the brand of the printer as well.

Goodluck.

Share:
62,654

Related videos on Youtube

klox
Author by

klox

Updated on September 17, 2022

Comments

  • klox
    klox almost 2 years

    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?

  • Anders Wallenquist
    Anders Wallenquist about 12 years
    NFS are a classic, but SSH are more modern, secure and flexible today. With SSH you can use the GUI-dialog in Nautilus to do the mounting.
  • Anders Wallenquist
    Anders Wallenquist about 12 years
    Use SSH and you don't have to know if you can trust the network or not.
  • Anders Wallenquist
    Anders Wallenquist about 12 years
    Samba are for Windows-users, if its Ubuntu-only SSH are a better solution.
  • thecoshman
    thecoshman over 11 years
    Whilst U1 will work for this, there are better ways. Unless you want/need to share with some one who you want to be able to simply configure any machine for access to the data you are sharing, I would stick to SAMBA/NFS/SSH
  • Nabil Kadimi
    Nabil Kadimi over 10 years
  • Andrew Savinykh
    Andrew Savinykh over 7 years
    @AndersWallenquist those solve different problems. If I have a program that is not aware of SSH which needs a path to a (remote) file, I cannot do it with SSH, but with NFS this is not a problem since it's completely transparent for the program.
  • Michael Macha
    Michael Macha about 3 years
    Thank you for that. I was wondering about that funny syntax.