Copy and Paste

While most applications support the mechanism for cut, copy & paste that most people are used to from other operating-systems, X11 also has another mechanism which is faster once you get used to it. It even works between two linux/unix-computers across the network

Picking the menus

As you know from other operating-systems, you can pick the items “cut”, “copy”, and “paste” from the “edit” manu. Works as expected.

Keyboard shortcuts

As you know from other operating-systems, you can cut, copy and paste by pressing the control-key together with “x”, “c”, “v”. The X is nice to remember for to cut. The C is for copy, and the V looks like the insertion mark we used in school when we forgot a letter in the middle of a word. Works as expected.

X11-Goodie: Mouse only!

In X11, selecting a text with the mouse is enough to put it into the X11-clipboard. You can insert it by pressing the middle mouse button. If your mouse has a wheel, this is the button you need to press. If your mouse has only two buttons, X11 is usually configured to use a simultaneous click on both of them instead.

This can be really fast. For example, I have configured my browser to start without a page loaded, the URL-field is already empty. So I can use this fast method to copy URLs into the browser.

From one box to another

So, you have more than one computer connected. You can use the technique described above to copy text from one Linux-PC to another.

You connect to the other box using
ssh -X user@computer 
where user is the username you need to log in, and computer is the ip-adress of the computer you want to log into.

After giving your password, any command you type in that shell runs on the other computer but displays output and windows on your screen. And then you can copy to and from. Works like expected :)

Can you give me an example, please?

Sure, glad you asked.

I have a workstaion called “vivid” configured so that two nfs-exports from the server (called “files”) are mounted. Also, a removable drive can be used. All this information is inside /etc/fstab. For my laptop, I want to have the same lines, so I can have the same environment. I do this by a simple copy and paste operation across the network:

  1. I log into the the other computer using ssh. For the screenshot I used
    ssh -X root@192.168.1.191 
    but as I realize now, I could have done it as user.
  2. I display the text I am interested in. While I could have done so using “cat” or “less”, I chose “emacs”. Emacs displays the hostname in the window-title, so you can see where you are.
    emacs /etc/fstab
  3. I selected the lines I want to reuse by moving the mouse over them while pressing the left mouse-button. It gets highlighted.
  4. In another shell, I start emacs locally. I chose some example-filename, but in real life, I would have taken /etc/fstab directly.
  5. Inside the local emacs-window, I push the middle mouse-button. The text gets inserted.
  6. After finishing my remote-work, I can log out by typing “exit”, “logout”, or simply by pressing ctrl-D

Do you have a screenshot of that example?

I sure do. Here you are: copy-n-paste-screenshot
But watch out: It is 1400×1050. I love big screens :)

How can I learn more about the wonderful world of networking?

On LinuxBasics.org: Networking and remote access

No comments yet.

Leave a Reply

Comments links could be nofollow free.