Cloud

How to enable copy and paste in VirtualBox

Frustrated that VirtualBox copy and paste isn't working out of the box? Learn how to enable this feature, and work with your VMs more efficiently.

virtualboxhero.jpg
Image: Jack Wallen

This comes, once again, from the department of "Should be working out of the box." Have you ever needed to type out a long string of text, a line of code, URL, or paragraph, into your VirtualBox guest—knowing said text is sitting there, waiting patiently, on your host? You want to simply copy and paste it, but the action never seems to work.

What if you could make that feature actually work? Better yet, what if you could enable the action so that it would work both ways (from host to guest and guest to host)? That would make working with VirtualBox significantly easier. Well, it's time you made that a reality. And I'm going to show you how.

I'll be demonstrating this on an Elementary OS host and a Fedora 26 guest. The process will be similar for nearly any platform (you'll just need to adjust one particular step).

Install Guest Additions

This is the sticking point. Without the Guest Additions installed, copy and paste will not work. I'm going to walk you through the process of installing the Guest Additions that should work on any Linux distribution (you will have to modify the installation command to suit your distribution's package manager). This process will be similar on a Windows host, only you shouldn't have to mount the drive, and you can simply double-click the .exe installer file.

For installing the Guest Additions on Linux, here's what to do:

  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 dnf install -y dkms kernel-devel kernel-devel-$(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.

If you're working with a Ubuntu-based guest, the command to install the necessary dependencies is sudo apt-get install -y dkms build-essential linux-headers-generic linux-headers-$(uname -r).

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 (Figure A).

Figure A

Figure A

Enabling bidirectional copy and paste between Elementary OS and Fedora 26.

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.

A bonus feature that still doesn't work

One nice bonus to this is that adding the Guest Additions also allows the enabling of Drag and Drop. Or it should. To enable the feature, click Devices | Drag and Drop | Bidirectional. There is one caveat to this, in that Drag and Drop doesn't work with every desktop or every file manager. The feature will not work with Elementary OS, or most desktops that depend upon Wayland. The chances Drag and Drop will not work for you are slim. If so, you'll need to make use of Shared Folders (until the developers work out the associated Drag and Drop bugs).

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox