Skip to main content

Terminal Basics

Copy Paste in Ubuntu Terminal

Ctrl+C, Ctrl+V does not work for copy paste in the terminal. Here is what you should do instead.

If you are switching from a different platform such as Windows or macOS, knowing how much basic tasks differ in the Linux world is a must.

Copying and pasting are one of them.

Sure, you may already know how you'd select text and then copy-paste but what choices you're left with when you don't have access to the cursor?

In this tutorial, I will walk you through two possibilities of how you can copy and paste in an Ubuntu terminal:

  • When you have access to the cursor
  • When you don't have access to the cursor

So let's start with the first one.

Copy and paste in the Ubuntu terminal (easy methods)

If you are using any Desktop environment or window manager, the cursor must be there and it will make this task pretty easy.

To copy and paste in the terminal, you'd have to follow three simple steps:

  1. Select text using the mouse pointer
  2. Press Ctrl + Shift + C or Ctrl+Insert to copy the selected text
  3. Use Ctrl + Shift + V or Shift+Insert to paste the selected text
copy and paste text in Ubuntu terminal using mouse cursor

And there you have it.

Alternatively, you can also use the context menu of the terminal to achieve the same results. Let me show you how.

Method 2: Use the context menu for copy-paste in the Terminal

This method is similar to the above but here, you don't have to use the shortcuts but the context menu to copy and paste the text.

To use this method, you'll have to follow 3 simple steps:

  1. Select text
  2. Right-click and the context menu will appear. Select Copy option
  3. Move the cursor where to paste, right-click again and select Paste option

That's it!

Copy paste text in Ubuntu terminal using mouse

Pretty simple. Isn't it?

Using screen command to copy paste (complicated method)

If you are using a Ubuntu server directly, you won't be given any desktop environment as the server are meant to be as minimal as possible.

So how would you copy and paste in that situation?

For this purpose, you'd have to install a program called Screen which will let you select and copy any output generated by the command.

And to install Screen, you'd have to use the following command:

sudo apt install screen

Once done, start the screen by simply executing screen in your terminal window:

screen 

Now, you'll see a prompt. Simply hit Enter key:

use screen software to copy paste text from terminal without mouse in ubuntu

Your terminal is ready.

Now, you can execute any command and it will get you the expected output. But this time, you can select the text and copy it without using any mouse cursor.

To do so, you'll have to follow the given simple steps:

  1. Execute a command to generate output that needs to be copied.
  2. Enter copy mode by pressing Ctrl + a + [
  3. Navigate from where the text needs to be copied
  4. Press the Enter key to start the selection
  5. Use arrow keys to select text as per your needs
  6. Hit the Enter key again and your text is copied
  7. Use Control + a + ] to paste the text

Sounds too complex? Let me get more into details.

Here, I will be copying a text file output from the simple text file named Hello.txt. And to do so, I will be using the cat command:

cat Hello.txt
use cat command to print text content of file

Simple 2 lines of code!

Now, to activate the copy mode, press Ctrl + a + [:

enable copy mode to copy text from ubuntu terminal without mouse

As you can see, the copy mode was activated!

From here on, you can use arrow keys to navigate to where the text needs to be copied (it can be selected from any direction so you can also go to the last part of the output).

navigate from where the text needs to be selected and copied

Once done, press the enter key and use the arrow keys to select the text:

After selecting the text to be copied, hit the Enter key again to deactivate the copy mode and it will show you how many characters are copied:

Hit enter key to deactivate the copy mode

Finally, you can use Control + a + ] to paste the copied text anywhere in the terminal.

For example, here, I copied text from the standard output and pasted it into the nano text editor:

copy and paste text in Ubuntu terminal without using mouse

And there you have it!

Do more with shortcuts

If you are just getting started, I would highly recommend you check out our detailed guide on keyboard shortcuts that every user should know:

13 Keyboard Shortcuts Every Ubuntu User Should Know
Knowing keyboard shortcuts increase your productivity. Here are some useful Ubuntu shortcut keys that will help you use Ubuntu like a pro. You can use an operating system with the combination of keyboard and mouse but using the keyboard shortcuts saves your time. Note: The keyboard shortcu…

I hope you will find this guide helpful. Have any suggestions? Drop a comment.