Shell

Copying and Pasting Text onto the Linux Terminal

Copying and Pasting Text onto the Linux Terminal

While working with the Terminal, we sometimes require copying a long command, file name or text from the web, a tutorial, or simply from some text file. You might have observed that the simple pasting control, Ctrl+V does not work in the Terminal. We all know that copying a text requires selecting it and then either pressing Ctrl+C (for copying) or Ctrl+X (for cutting); so how do we paste the selected text in the Terminal? In this tutorial we will show you how to do so through a few examples we ran on Ubuntu 18.04.

Example 1: Copying a file name to a command in the Terminal

A few days back I needed to install a .deb package of Google Chrome that I had downloaded through a web browser on my system. I wanted to install it through the dpkg command from the Terminal. While typing the command, I wanted to be sure that I am providing the exact file name of the .deb package. I, therefore, right-clicked the file and selected its name from the Properties and then copied it on my clipboard through Ctrl+C.

Then I opened the Terminal and pasted the file name in my command by right-clicking at the desired location and then by selecting Paste from the menu as follows:

You can see in the following image how the text has now been pasted in my command. This way I was able to ensure that I chose the exact file name for an installation.

Example 2: Pasting a huge chunk of text from a text editor to a Terminal file

Let us suppose you are working on a text file in the Nano editor and need to copy a huge chunk of text from a graphical text editor to this file. You can simply do so by selecting the text from the graphical text editor and copy it to the clipboard through Ctrl+C as follows:

You can then paste this text into a Nano Editor file in the Terminal by right clicking at the desired location and then selecting Paste from the menu as follows:

The copied text will be pasted in your Nano text file as follows:

Example 3: Pasting a long/complicated command to the Terminal

Suppose you are practicing along with one of our tutorials from the web and want to make sure that you run the exact command on the Terminal, without any mistake. Let us try running the following command that lets you view your command history along with the date and timestamp.

$ export HISTTIMEFORMAT="%F %T"

Instead of re-typing the command, you can simply copy it from this tutorial and paste it in the Terminal by right-clicking and then selecting Paste from the menu.

Now when you run this command and then the history command, you will see the output with the exact date and time format you have set from our tutorial.

These are just a few examples where you can utilize pasting text to the Terminal. As you start using this skill, you will be able to save a lot of time and effort that is required in re-typing a text or command in the Terminal.

Open Source Ports of Commercial Game Engines
Free, open source and cross-platform game engine recreations can be used to play old as well as some of the fairly recent game titles. This article wi...
Parhaat komentorivipelit Linuxille
Komentorivi ei ole vain suurin liittolainen Linuxia käytettäessä - se voi olla myös viihteen lähde, koska voit käyttää sitä pelaamaan monia hauskoja p...
Parhaat Linux-peliohjaimen kartoitussovellukset
Jos haluat pelata pelejä Linuxissa peliohjaimella tyypillisen näppäimistön ja hiiren syöttöjärjestelmän sijaan, on sinulle hyödyllisiä sovelluksia. Mo...