In user-interface design and human-computer interaction, copy-paste are operations that provide an interprocess communication mechanism for moving data via the user interface of a system. The copy command duplicates the data and saves it to temporary storage (the clipboard). Then this data from the clipboard is pasted into the desired location. The copied data is accessible to any program that supports the functionality and allows itself to transfer data easily.

You may need to write long commands or sentences obtained in a file or on the internet while working on the Ubuntu terminal. You can save your precious time by utilizing copy-pasting techniques rather than entering them word by word. Using the standard keyboard commands Ctrl c and Ctrl v, you may have copied and pasted text multiple times in your Ubuntu Graphical User Applications such as LibreOffice, Gedit, OpenOffice. However, you may be surprised to learn that many common keyboard shortcuts do not work in Ubuntu Terminal.

This article will show you how to copy-paste in the Ubuntu terminal using two different methods. The examples below are executed on Ubuntu 20.04; other Linux distributions can also use the same copy-paste approach. Now, let’s get started!

How to copy-paste on Ubuntu terminal using right-click context menu

You need to utilize the mouse to highlight the text; why not use it to copy and paste? You can use the mouse right-click for copy-paste as you do in other Ubuntu applications. For this, select the text you want to copy, then right-click on it, and from the context menu, click on the “Copy” option. You can paste this copied command to the terminal window, any script, or any other document.

Example 1: In the below-given example, we will copy-paste the command executed in the Ubuntu terminal to a document named “testscript”:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-1.png" data-lazy- height="402" src="data:image/svg xml,” width=”738″>

Firstly, we have selected the command. After that, utilizing the right-click context menu, we will click on the “Copy” option:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-2.png" data-lazy- height="390" src="data:image/svg xml,” width=”740″>

Now, we will paste the copied command in our “testscript” document. Click on the document position, where you want to place the copied command, and then from the right-click context menu, click on the “Paste” option:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-3.png" data-lazy- height="459" src="data:image/svg xml,” width=”789″>

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-4.png" data-lazy- height="414" src="data:image/svg xml,” width=”792″>

Example 2: In Ubuntu, you can also use your mouse’s context menu right-click to copy-paste from a terminal to the other terminal window. For this, select the command and click on the “Copy” option:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-5.png" data-lazy- height="478" src="data:image/svg xml,” width=”843″>

Move into the other terminal and paste the selected command in the following way:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-6.png" data-lazy- height="384" src="data:image/svg xml,” width=”724″>

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-7.png" data-lazy- height="528" src="data:image/svg xml,” width=”1048″>

All done!

How to copy-paste on Ubuntu terminal using keyboard shortcuts

Most computer users are accustomed to using “CTRL c” and “CTRL v” for copy-pasting text. These shortcuts also work on Ubuntu Desktop, but not in the terminal. To copy or paste commands from or to the Ubuntu terminal, you must add the “Shift” key in these keyboard shortcuts.

Rules are simple:

  • To copy text or command from Ubuntu terminal, press “CTRL Shift c
  • To paste text or command in Ubuntu terminal, press “CTRL Shift v
  • To copy text or command from outside of the Ubuntu terminal, press “CTRL c
  • To paste text or command in any document or script, press: “CTRL v

Example 1: In the below-given example, we will try to copy commands from the document “testscript” to our Ubuntu terminal:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-8.png" data-lazy- height="381" src="data:image/svg xml,” width=”795″>

First of all, we will select all of the required commands for copying and then press “CTRL c”:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-9.png" data-lazy- height="408" src="data:image/svg xml,” width=”793″>

After that, we will move towards our terminal window and paste the commands in it by pressing “CTRL SHIFT v”:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-10.png" data-lazy- height="346" src="data:image/svg xml,” width=”739″>

This operation will paste and execute the copied commands in the terminal simultaneously:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-11.png" data-lazy- height="351" src="data:image/svg xml,” width=”737″>

If you paste a command into the Ubuntu terminal with a trailing newline, the command will be executed right away. I have discovered that selecting a command by clicking at the end and dragging it to the beginning is the easiest way to avoid this. We will be able to paste commands in the Ubuntu terminal through this selection method without executing it instantly.

Next, we will select the command from the document by using the method mentioned above. After that, press “CTRL c” to copy it:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-12.png" data-lazy- height="356" src="data:image/svg xml,” width=”787″>

Move into your Ubuntu terminal and press “CTRL Shift v” to paste the copied command:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-13.png" data-lazy- height="280" src="data:image/svg xml,” width=”732″>

The below-given shows that we have successfully pasted the command from our document to the terminal without executing it instantly:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-14.png" data-lazy- height="299" src="data:image/svg xml,” width=”736″>

Example 2: How to copy-paste from Ubuntu terminal to a document using keyboard shortcuts


To copy and paste any command from your terminal window; select it by pointing the cursor at the end of it. After that, utilize the mouse right-click button and drag it towards the start of the command. Once you have selected the command, press “CTRL Shift c” to copy it:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-15.png" data-lazy- height="324" src="data:image/svg xml,” width=”737″>

Next, open up your document where you want to paste the command and press “CTRL v”. Now the “testscript” document will look like this:

<img alt="" data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2021/08/echo/How-to-copy-paste-on-Ubuntu-terminal-16.png" data-lazy- height="410" src="data:image/svg xml,” width=”792″>

Conclusion

There are always options to copy-paste in the Ubuntu terminal whenever you find yourself reusing any text. In Ubuntu, copy-paste enables you to copy and paste text or commands without retyping them repeatedly. This process also saves your time, which you can invest in other things. In this article, you have learned how to copy-paste in the Ubuntu terminal using two different methods. According to our experience, using keyboard shortcuts for copy-paste is easier than utilizing the mouse right-click menu.

About the author

<img alt="" data-lazy-src="https://secure.gravatar.com/avatar/c73b74cd8044d2e9b300610f5af77d0b?s=112&r=g" data-lazy- height="112" src="data:image/svg xml,” width=”112″>

Sharqa Hameed

I am a Linux enthusiast, I love to read Every Linux blog on the internet. I hold masters degree in computer science and am passionate about learning and teaching.