Linux: How To Copy and Paste From the Command Line

Q. How do I copy and paste text or output from a shell prompt? How do I copy text from one terminal window and paste it on diffrent server window using mouse?

A. You can easily copy and paste between multiple shell prompts or the terminals using nothing but your mouse only. This is useful to transfer configuration lines from one terminal to another all opened over ssh session.

Advertisement

Most Linux distros are configured the click of a middle mouse button as paste operation. All you have to do is select text, move your most to another window and hit the middle mouse button. If you have a scroll wheel, just press on it to past the text. If you see only two buttons, just hit both button simultaneously i.e. you can emulate a third, “middle” button by pressing both mouse buttons simultaneously.

Optional: Linux Mouse configuration

Usually you can reconfigure mouse by editing /etc/X11/xorg.conf file or your distributions mouse configuration tool. You can also use xmodmap utility for modifying keymaps and mouse pointer button mappings in X. Here is my sample PS2 wheel Mouse entry:

Section "InputDevice"
         Identifier      "Configured Mouse"
         Driver          "mouse"
         Option          "CorePointer"
         Option          "Device"        "/dev/input/mice"
         Option          "Protocol"      "ImPS/2"
         Option          "ZAxisMapping"  "4 5"
EndSection

Further readings:

  • man pages xorg, xmodmap, xsetpointer etc

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

14 comments… add one
  • ocj Sep 13, 2014 @ 12:43

    Thank you for this article, it helped me a lot.

  • mike2008and2008 Nov 3, 2015 @ 18:59

    How To Copy and Paste From the Command Line is misleading and should be “Use Mouse to copy and paste in console”. I was looking the command line args to copy and paste and this has not one thing to do with that but it sounds like it does.

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.