3

I'm working in Ubuntu as Virtual-Box guest on top of Windows machine (as host)

I have generated a long key which I want to paste to gitlab - yet for some reason I cannot copy and paste it from the terminal.

  • I have gone into the settings and set the shared clipboard to bidirectional and rebooted the machine.
  • I have tried selecting text and right click, copy.
  • I have tried Ctrl + Shift + C.
  • It's definitely not my PC settings as I can copy and paste from elsewhere fine.

How can I solve it?

Yaron
  • 13,173
Louise
  • 141
  • 1
    did you try selecting the text, and copying it with your mouse? – Yaron Jan 04 '18 at 14:23
  • Yes and the option to copy appears, yet even when I click copy, I go to paste the text and nothing – Louise Jan 04 '18 at 14:24
  • You tagged the question as virtualbox , however it isn't clear from your question how is it related to virtualbox - can you please elaborate? do you try to copy/paste in the same machine? – Yaron Jan 04 '18 at 14:29
  • Virtual box is what I am using to host Ubuntu on as I am using a windows pc – Louise Jan 04 '18 at 14:31
  • I know troubles with copy&paste, there are lots of possible reasons. Try redirect/save the text in a file and copy it from an editor. And in respons to Yarons answer right now, open the file from that ugly other system. – Gyro Gearloose Jan 04 '18 at 14:38
  • @GraceLouise - did you install VB Guest Additions (as described in my answer)? – Yaron Jan 04 '18 at 14:54
  • I believe I have installed it now, however I'm having trouble opening the terminal, and on trying to reinstalling am getting the error message, Could not mount the media/drive 'C:\Program Files\Oracle\VirtualBox/VBoxGuestAdditions.iso' (VERR_PDM_MEDIA_LOCKED). – Louise Jan 04 '18 at 15:44
  • @GyroGearloose how would one go about saving the text in a file? – Louise Jan 04 '18 at 15:45
  • The unix way would be, for exmple if you want the output of ls -l, you just say ls -l > myfile.txt and then open the file called myfile.txt . – Gyro Gearloose Jan 04 '18 at 15:53

2 Answers2

3

In order to allow copy/paste in your Ubuntu VirtualBox-Guest-Machine, you'll need to install VirtualBox Guest Additions

  • how to install guest additions in VirtualBox VM

  • Detailed explanation taken from how-to-enable-copy-and-paste-in-virtualbox

    1. Start VirtualBox.
    2. Start the host in question.
    3. Once the host has booted, click Devices | Insert Guest Additions CD Image.
    4. Open up a terminal window in the guest.
    5. Mount the CD-ROM with the command sudo mount /dev/cdrom /mnt.
    6. Change into the mounted directory with the command cd /mnt.
    7. Install the necessary dependencies with the command sudo apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r).
    8. Change to the root user with the command sudo su.
    9. Install the Guest Additions package with the command ./VBoxLinuxAdditions.run.
    10. Allow the installation to complete.

One the installation is finished, reboot the guest operating system.

Enable copy and paste

At this point, copy and paste (from either guest to host or host to guest) can be enabled. Start the VM, and once it's booted, click Devices | Shared Clipboard | Bidirectional

enter image description here

You can now copy and paste from guest to host and host to guest. No more having to retype lines of code or URLs and no more wondering why the feature wasn't working.

Yaron
  • 13,173
1

For any other beginners in using VirtualBox I think this answer might be helpful as I had only discovered after asking my question.

Copying and pasting from the terminal open in VirtualBox to a browser in Windows (for example) proves complicated, but using the Firefox within VirtualBox it is straightforward to copy and paste between the two as you are going within the same system. I'm kicking myself for not copping on to this sooner

Louise
  • 141