📝 Introduction
One of the most common frustrations faced by users running Ubuntu Linux in VirtualBox on a Windows host is the inability to copy and paste text—especially command-line instructions—between the two systems. This issue becomes particularly inconvenient when you're trying to copy terminal commands, configuration snippets, or file paths from Windows into Ubuntu, only to find that the clipboard doesn't work as expected. Fortunately, VirtualBox offers a feature called Shared Clipboard, which allows seamless copy-paste between the host and guest operating systems. However, this functionality is not enabled by default and requires proper configuration, including the installation of Guest Additions in the Ubuntu virtual machine. This guide walks you through the steps to enable clipboard sharing and eliminate the hassle of manual retyping.
A. Start Ubuntu in VirtualBox
Log into your Ubuntu VM.
B. Click on Devices then on Insert Guest Addition CD Image....
C. If prompted to run it, choose Run. You might need to enter your password.
If not prompted:
Open Terminal and run:
sudo mkdir /media/cdrom
sudo mount /dev/cdrom /media/cdrom
sudo /media/cdrom/VBoxLinuxAdditions.run
You might need to run them one after the other.
What does each command do?
sudo mkdir /media/cdrom
Creates a new directory called cdrom
inside /media.
sudo
is used to run the command with superuser (administrator) privileges.
sudo mount /dev/cdrom /media/cdrom
Mounts the CD/DVD device (/dev/cdrom
) to the /media/cdrom directory
, making its contents accessible from that location.
sudo /media/cdrom/VBoxLinuxAdditions.run
- Executes the VirtualBox Guest Additions installer from the mounted CD.
- This typically improves integration between a VirtualBox guest OS and the host (e.g., better graphics support, shared clipboard, etc.).
In summary, these commands mount the VirtualBox Guest Additions CD and install the tools inside a Linux virtual machine.
C. Reboot Ubuntu VM
sudo reboot
Furthermore, Enable Shared Clipboard in VirtualBox Settings.
On the Virtualbox start up page, click on setting, then Advanced and under Shared Clipboard, click on Bidirectional.
(Optional) Set Drag and Drop to Bidirectional.
Test Copy and Paste
After rebooting Ubuntu:
- Try copying text from Windows and pasting into Ubuntu (e.g., in Terminal or a text editor).
- Also try copying from Ubuntu to Windows.
Paste in Linux terminal;