1

If I were to run a command that Ubuntu recognizes, but that I don't have installed, something like the following would take place:

$ command
Command 'command' not found, but can be installed with:
sudo apt install command
:~$

Although most of the time, I could just copy whatever the suggested command by typing it, it would be nice if there was a way to copy sudo apt install command into my clipboard so I could paste it and save time.

Is there any native way to do this in Ubuntu?

Edit: I am using WSL 2 on Windows 11.

muru
  • 197,895
  • 55
  • 485
  • 740
Mailbox
  • 111
  • If you will let us know exactly which terminal application you are using we can help you look it up. – Nmath May 15 '23 at 21:55
  • I always do it this way. Just copy the command on the page and paste in your terminal. Just make sure you know what the command does, some commands can do nasty stuff. There is also a more permanent clipboard like app, where you can copy often used commands/lines, but I forget the name of it right now. – crip659 May 15 '23 at 22:10
  • ^Or you can get it to install the package for you directly. – muru May 15 '23 at 23:13

1 Answers1

1

In a number of modern terminals (the ones I use at least), simply selecting a line copies it to the clipboard by default, while right click (or middle click) inserts (should be configurable).

So for those terminals, simply select the line sudo apt install command, and right or middle click (depending on configuration) to paste it at the cursor position.

I know for a fact that the following terminals support this:

Artur Meinild
  • 26,018