166

Sometimes while using VirtualBox, I have tried copying text from the virtual machine to the host machine but failed. Whenever that happens, I fix it by rebooting the virtual machine. Is there a solution to this because I don't want to keep rebooting again and again.

Note: It is always possible for me to copy text from the host to the virtual machine.

Nicolas Raoul
  • 11,473
  • 27
  • 93
  • 149
sam
  • 6,741
  • 16
  • 47
  • 59
  • 4
    Have you tried just re-installing the Guest Additions in the Virtual Machine? If not, check the answer from Pisu below. You didn't mention how you originally installed VirtualBox (external package from VirtualBox's website, or the virtualbox-ose package from the Ubuntu repositories) Also, what version you are on (both Ubuntu and VirtualBox). This info may help us help you. – Jayson Rowe Sep 30 '11 at 01:58

18 Answers18

165

If your guest OS is ubuntu then running following two commands in ubuntu terminal should help:

$ killall VBoxClient
$ VBoxClient-all
Dmitry
  • 2,191
  • 3
  • 15
  • 12
  • 1
    +1 ,This worked for Ubuntu 12.04 but I used $ killall VBoxService – Ahmed Feb 24 '14 at 00:35
  • 2
    VBoxClient wasn't running on my Ubuntu. `VBoxClient-all` started the tools correctly and fixed host-to-guest pasting (but not the other way). Notice `VBoxClient-all` is the binary name and not a flag! – Air May 22 '14 at 15:18
  • Wow. 2015 and it still works. Thank you! – Mike Jr Feb 21 '15 at 22:00
  • Works on CentOS 6 guest as well. Thanks! – Arkady Jun 17 '15 at 02:19
  • 2
    Worked for me on Ubuntu 14.04 running on a Windows7 host. Thanks! – Paul Sep 10 '15 at 06:56
  • 1
    Host: Win8, guest linux, worked!! – Sunil B N Dec 17 '15 at 07:45
  • @jimsmith do you have any problem with it? – Dmitry Jun 09 '16 at 08:17
  • 16
    Couldn't find a `VBoxClient-all` binary on my system. Just `kill`-ing and restarting `VBoxClient --clipboard` seems to have worked for me. – decimus phostle Mar 13 '17 at 16:56
  • 3
    @decimusphostle In my Ubuntu 16.04 it is located in `/usr/bin/VBoxClient-all` . Actually it is not a binary but a script which executes the following commands: `/usr/bin/VBoxClient --clipboard /usr/bin/VBoxClient --checkhostversion /usr/bin/VBoxClient --display /usr/bin/VBoxClient --seamless /usr/bin/VBoxClient --draganddrop` – Dmitry Mar 13 '17 at 17:28
  • 4
    Worked on Ubuntu 16.04 – qwertzguy Oct 19 '17 at 16:53
  • 2
    fyi, on 17.10 Ubuntu Server (with desktop apps installed), I have no `VBoxClient-all`: poking around the install code, it's referenced in https://www.virtualbox.org/browser/vbox/trunk/src/VBox/Additions/linux/installer/vboxadd-x11.sh - also noticed there used to be a reference to it in Makefile.kmk https://github.com/mdaniel/virtualbox-org-svn-vbox-trunk/blob/166037dcf8564e1d13a3750cd691d4e4597de16d/src/VBox/Additions/solaris/Makefile.kmk#L317 - still not sure what the story is – Ben Creasy Feb 11 '18 at 05:36
  • 2
    Works on Ubuntu 16.04 with these commands: ``killall VBoxService`` && ``VBoxClient --clipboard`` – Juha Untinen Feb 20 '18 at 18:36
  • @JuhaUntinen why `VBoxClient --clipboard` instead of `VBoxClient-all`? You'll restart the clipboard only, losing other functionalities as drag and drop and display management. – Wizard79 Dec 03 '19 at 08:09
  • 2
    Careful with that command if you have anything important opened at the time you run it. It put my graphical screen in an unusable state (the programs are all there, up and running; I can use the console, but the graphical part just does not show anything) – caxcaxcoatl Jun 24 '20 at 02:22
42

On a Windows XP guest, I can kill "VBoxTray.exe" using the Task Manager (Ctrl+Alt+Del), then restart it from "Program Files/VirtualBox Guest Additions".

slava
  • 3,787
  • 9
  • 30
  • 65
sam
  • 6,741
  • 16
  • 47
  • 59
32

Install VBoxClient (requirement for next step):

sudo apt install virtualbox-guest-x11

Restart the VBox clipboard module:

pkill 'VBoxClient --clipboard' -f & sleep 1 && VBoxClient --clipboard

DBedrenko
  • 421
  • 4
  • 6
  • Thanks. I was having a problem pasting from guest to host (but not from host to guest) and this solved it for me. – The Unknown Dev Jun 15 '15 at 14:52
  • Should we run this command from guest or host? – Black Jun 01 '17 at 11:48
  • @Black Guest OS. – DBedrenko Jun 01 '17 at 16:30
  • 2
    This does fix the problem when manually run, but the issue comes up every time I restart the machine. I've tried running the command when the machine starts automatically, but doesn't work (I'm assuming the vbox service hasn't initialized yet when the command is run.) -- Anyone else know of an easier solution than manually pasting this in each time I want to copy/paste to my host? – Zachary Schuessler Aug 14 '17 at 18:17
  • @ZacharySchuessler If it takes a bit for the service to startup then add `sleep 3m && the_pkill_command`. There are lots of options. You can edit the service to run the pkill after it starts. – DBedrenko Jan 22 '21 at 18:18
31

In the Oracle virtual box setting go to

Settings > General > Advance

There is a an option Drag n Drop. Select the direction you want to copy the text.

amjad
  • 689
  • 1
  • 8
  • 7
  • Thanks, that helped. I would have had to search for a long time to find that one. – WitchCraft Apr 23 '14 at 20:11
  • 7
    @amjad, Nope, it's already selected. Still not working, you need to restart the vboxtray as the other answers suggested. – Pacerier Sep 02 '15 at 04:59
  • 3
    `Drag'n'Drop`? Are you sure? `Shared Clipboard` should be option for guest-host copy/paste, but the trick is that it stopped working for some reason. – Traxo Aug 08 '18 at 17:15
  • 1
    If it was not enabled, then restarting wouldn't fix the issue for the original question. But this might help some people for whom it NEVER works. – Dobes Vandermeer Aug 15 '18 at 17:10
  • For VirtualBox 6.1, in VirtualBox Manager, it is Machine => Settings => General => Advanced => Shared Clipboard => Bidirectional (was: Disabled). – Atafar Sep 11 '20 at 14:11
  • Does not work for me – mah65 Oct 23 '20 at 08:56
  • strange but true enabling drag&drop fixed the clipboard issue (2022 VBox 6.1.26 Linux host, windows 7 guest)... 10 years have passed and the bug is still the same :) – Gab Feb 17 '22 at 08:36
  • None of those options work for me. Shared Clipboard bidrectional (or any direction) drag and drop bidrectional (or any direction) works for me at ll. – ClayD Oct 30 '22 at 02:32
27

For me, Windows 7 host and Ubuntu 16.04 guest, I had to install VirtualBox guest additions.

  1. Start the virtual machine
  2. Click Devices menu
  3. Select Insert Guest Additions CD image
  4. Change to the directory where your CD-ROM drive is mounted (typically /media/<user>/VBOXADDITIONS_x.x.x/)
  5. Install it sudo sh ./VBoxLinuxAdditions.run
  6. Reboot the virtual machine!

I found the complete steps in this link

xcvbn
  • 105
  • 5
16

In Ubuntu you may need to install virtualbox-guest-x11

sudo apt-get install virtualbox-guest-x11

and then start virutal box client

VBoxClient-all
Jossef Harush Kadouri
  • 4,514
  • 2
  • 20
  • 22
Bala
  • 161
  • 1
  • 2
8

On Ubuntu 18.04 running on VirtualBox 5.2.22, I did the following:

  1. On VirtualBox Manager, right click Ubuntu VM -> Settings -> General tab on left -> Advanced tab on right`.
    Now choose Shared Clipboard as : Bidirectional

  2. On Ubuntu, on the terminal run the following commands:

    sudo apt install virtualbox-guest-x11
    

Now I had to restart Ubuntu to run the below command run successfully:

VBoxClient --clipboard

After this, the bi-directional copy started working.

Gryu
  • 7,279
  • 9
  • 31
  • 52
Sudheer Kumar
  • 181
  • 1
  • 1
  • This answer worked for me. Do the command line install, restart Linux box, then try that VBoxClient --clipboard. Then try copy and pasting between guest + host and it worked. – AndyUK Jul 29 '22 at 11:52
6

How to fix shared clipboard in VirtualBox (Windows Guest)

  1. In VirtualBox Windows Guest, Open Task Manager
  2. Go to Processes Tab, highlight VBoxTray.exe and select End Process
  3. Go to Applications Tab and select New Task
  4. Browse to the VirtualBox Guest Additions installation folder and select VBoxTray.exe and select OK.

The bidirectional shared clipboard should work afterwards.

user227392
  • 69
  • 1
  • 2
5

In Ubuntu 16.10 I had to run following command to get it to work:

service virtualbox-guest-utils start

In addition to this, set the Shared Clipboard setting to Bidirectional in General/Advanced Virtual box settings.

Dave Jarvis
  • 957
  • 2
  • 11
  • 24
user617342
  • 59
  • 1
  • 1
3

If needed, upgrade VirtualBox to latest version, currently 4.1.2, they solved many issues. Then reinstall Guest Additions on the VM, as copy-paste is managed by guest additions drivers.

Stefano
  • 2,374
  • 18
  • 33
2

Enabling Shared Clipboard on Ubuntu 19.10 Host, Ubuntu 18.04 Guest, VirtualBox 6.1.

VirtualBox VM Menu ->
Machine ->
  General ->
   Advanced ->
    Shared Clipboard: Bidirectional

is set

The guest's Ubuntu terminal commands:

sudo apt install virtualbox-guest-x11 --reinstall
VBoxClient-all --clipboard

I used --reinstall option because of I had virtualbox-guest-x11 package installed and before reinstalling it I had:

$ VBoxClient-all --clipboard
VBoxClient: error: No service specified. Quitting because nothing to do!

After reboot screen resolution jumps to its minimal value, so

VirtualBox VM Menu ->
View ->
  Auto-resize Guest Display

clicking would be required if you want it.

Gryu
  • 7,279
  • 9
  • 31
  • 52
1

As of time of this post,

In my case, I've noticed bidirectional copy/paste doesn't work when VM is started in detachable mode.

For bidirectional copy/paste to work, I had to start the VM in Normal mode.

Ubuntu 20.04, Virtual Box 6.1

Wadih M.
  • 282
  • 2
  • 8
  • Is this still the case, or has there been an update? This seems to be my problem as well. – skjerns Apr 05 '23 at 11:48
  • @skjerns I think it'll probably stay like that, because if they could have made it work by default, it would already function, but I can't tell for sure. What I did is if I plan to do copy/paste and interactively work on the machine, I start it in normal mode, and when I want it to run in background, with no expectation to interactively work on it, I start it in detached mode. I guess perhaps this is what detachable was designed to be used as, non-interactively. But I have no official source, just trying to guess. – Wadih M. Apr 18 '23 at 15:20
1

Copy and paste does work (provided you have installed VBoxGuestAdditions), but there is a few caveats:

  • There is text copy-and-paste and there is file copy-and-paste
  • If your VM is Windows, copy and paste should work for both text and file
  • If your VM is Ubuntu (or a flavor thereof, eg. Lubuntu)
    • text copy and paste should work
    • to copy files, you have to use the VirtualBox file manager...

To use File Manager...

  • In the VM window, choose file manager... open file manager

  • Log in using a linux user that exist on the VM to create a session log in to file manager

  • Then use the copy buttons copy between host and guest

tno2007
  • 141
  • 3
1

I use a Mac Host OS, and Ubuntu Guest (with lubuntu desktop).

Dmitry's answer got me so close! But VBoxClient wasn't running when I looked for it with ps, and trying VBoxClient-all failed:

$ VBoxClient-all
Failed to connect to the VirtualBox kernel service
Failed to connect to the VirtualBox kernel service
Failed to connect to the VirtualBox kernel service
Failed to connect to the VirtualBox kernel service
Failed to connect to the VirtualBox kernel service

Then I found https://www.virtualbox.org/ticket/9332

Turns out, VirtualBox additions didn't launch automatically for some reason. Starting vboxadd manually allowed me to then run the VBoxClient with the clipboard enabled.

arin@arin-VirtualBox:~$ sudo /etc/init.d/vboxadd start
Starting the VirtualBox Guest Additions ...done.
arin@arin-VirtualBox:~$ ps -ef | grep -i vbox
arin      2687 22537  0 10:53 pts/1    00:00:00 grep --color=auto -i vbox
arin@arin-VirtualBox:~$ sudo /usr/bin/VBoxClient --clipboard
arin@arin-VirtualBox:~$ ps -ef | grep -i VBox
root      2693 22100  0 10:53 ?        00:00:00 /usr/bin/VBoxClient --clipboard
arin      2698 22537  0 10:53 pts/1    00:00:00 grep --color=auto -i VBox

And now copy/paste works!

arinmorf
  • 141
  • 3
0

On the guest, apt gets the wrong version! On the host, verify with something like

VBoxManage --version
VBoxManage guestproperty get VM /VirtualBox/GuestAdd/VersionExt
VBoxManage guestproperty get VM /VirtualBox/GuestAdd/Version
VBoxManage guestproperty get VM /VirtualBox/GuestAdd/Revision

where VM is your Virtual Machine name or uuid. You may need to specify the path, e.g.,

"C:\Program Files\Oracle\VirtualBox\VBoxManage" --version
⋮

On the guest, with VirtualBox > Devices > Insert Guest Additions CD Image… and privs (and headers) I mounted the CD and re-installed it. On the host, I verified the versions match. On the guest,

VBoxClient --version
VBoxClient --clipboard

fixed everything without rebooting. YMMV. I wonder what happens if you try

VBoxManage guestcontrol VM updatega --source=guest-additions.ISO
Devon
  • 111
  • 4
0

My configuration is Windows host, Xubuntu guest. I guess it doesn't hurt to restart everything, but this is the client that matters. (VBoxClient-all is merely a script that runs /usr/bin/VBoxClient --clipboard and others.)

$ ps -fe|grep -i clip
tbc       1400     1  0 Jan18 ?        00:00:00 /usr/bin/VBoxClient --clipboard
$
$ p=1400;kill -int $p;ps -fp $p
$ /usr/bin/VBoxClient --clipboard
$ ps -fe|grep -i clip
tbc      30555  1281  0 13:01 ?        00:00:00 /usr/bin/VBoxClient --clipboard
$ pstree -sp 30555
init(1)---lightdm(1094)---lightdm(1261)---init(1281)---VBoxClient(30555)---{VBoxClient}(30556)
$

Note it runs in the background by default. It was owned by init(1), but when I invoked it, it got adopted through a tree I'm not familiar with.

tbc0
  • 163
  • 6
0

I was using VirtualBox 4.3.12. Once I upgraded to 5.0 the latest, the bugs were fixed.

No combination of reinstalling Vbox additions helped.

Solution: always try upgrading to the latest https://www.virtualbox.org/wiki/Downloads

leroneb
  • 3
  • 3
0

Login to your guest machine and open the CD drive where "VirtualBox Guest Additions" should be inserted.

Open this CD drive and execute the file "VBoxWindowsAdditions.exe".

After the installation you have to restart, then it should work!

Black
  • 774
  • 1
  • 7
  • 16