Can two PCs with Ubuntu share the clipboard buffer?

If the PCs are on the same network, it is possible. Software like Synergy can do it.

Synergy brings your devices together in one cohesive experience.

  • Seamlessly move your mouse to any computer and start typing.
  • Works on all major operating systems (Windows, Mac OS X, and Linux).
  • Share your clipboard (copy and paste) between your computers.

(For most cases, synergy will be more useful than this - see @jonvon's answer.)

There is a more low-level solution similar to synergy - it's called x2x - like "X to X", joining two X screens together.

With two X displays, it can make the mouse switch to the other display when it touches the edge of the screen that is next to the other screen, which feels like it's just one mouse pointer on one big screen - while it actually moved to another computer, and switched over the keyboard control too.

For the task at hand, x2x shares the X selection between the two computers. When used with windows, it interacts with the clipboard.

It is available as the package x2x in Ubuntu, but there is also a Cygwin build, available from the cygwin setup. The cygwin version allows to connect to a Windows screen, without running X there.

For options, see man x2x.
(Make sure you use one of the options like -west - that activates the more interesting mode of operation.)


You can interact with the X clipboard (and the promary selection) using xclip. The specific task in your question, paste text that was copied elsewhere, requires to copy over the clipboard contents.
You can use ssh to pipe the text from one clipboard to the other. That works best with password-less ssh login of course:

After copying on on firstPc, you run on secondPc:

$ ssh firstPc 'DISPLAY=:0 xclip -o -selection clipboard' | xclip -i  -selection clipboard

Now, you can paste on secondPc.

Note that a clipboard can not only contain text, but also more structured data. It can even contain the same data in multiple formats.