iT邦幫忙

2026 iThome 鐵人賽

DAY 8
1
IT Operation

大學生的VirtualBox虛擬機與Ubuntu實戰30天系列 第 8

Day 08|雙向剪貼簿、拖放檔案與認識 Guest Additions

  • 分享至 

  • xImage
  •  

昨天安裝好Ubuntu,並重啟虛擬機之後,輸入密碼後,就能正式進入系統裡面。

https://ithelp.ithome.com.tw/upload/images/20260907/20183886eRxMutQLjs.png
https://ithelp.ithome.com.tw/upload/images/20260907/20183886NkrQ3XR750.png
https://ithelp.ithome.com.tw/upload/images/20260907/20183886nM78vPlZti.png
https://ithelp.ithome.com.tw/upload/images/20260907/20183886XLR7u6e241.png
https://ithelp.ithome.com.tw/upload/images/20260907/20183886GPQjMOe5n9.png

在編寫程式時很常遇到一個問題

「我在Windows查好了一行超長的指令,想要複製貼上進 Ubuntu,按了Ctrl + V卻完全沒反應?」

那是因為虛擬機和實體電腦是兩個完全隔絕的獨立空間,今天我們就來把兩邊的通道徹底打通,實現雙向剪貼簿與檔案拖放功能,並搞懂這背後的功臣——Guest Additions(客體額外功能)!

1.什麼是 Guest Additions?

  • Guest Additions:這是專門給虛擬機內部作業系統(Ubuntu)安裝的一套「專屬硬體驅動與工具包」。只要把這套工具裝進 Ubuntu,它就會在背景建立一個專用通訊管道,主機跟虛擬機之間就能互相溝通。

2.安裝 Guest Additions 套件
請打開 Ubuntu 終端機(快捷鍵Ctrl + Alt + T),貼上以下指令補齊工具包:

sudo apt update (輸入密碼後直接按下Enter)
sudo apt install -y build-essential linux-headers-$(uname -r)

3.啟用「雙向剪貼簿」與「雙向拖放」
(1)在運行中的 Ubuntu 視窗上方點選「裝置(Devices)」 ➔ 「共用剪貼簿(Shared Clipboard)」,預設是「已停用(Disabled)」,請將它改成 「雙向(Bidirectional)」。
https://ithelp.ithome.com.tw/upload/images/20260907/20183886E20qJJWssK.png
(2)點選「裝置(Devices)」 ➔ 「拖放(Drag and Drop)」,同樣切換為「雙向(Bidirectional)
https://ithelp.ithome.com.tw/upload/images/20260907/20183886gA9zrIsIMi.png
(3)點選「裝置(Devices)」 ➔ 「插入Guest Additions CD映像...(Insert Guest Additions CD image...)」,右鍵「autorun.sh」,點擊「以程式執行」後,並輸入密碼
https://ithelp.ithome.com.tw/upload/images/20260907/20183886lcNi2BAL63.png
https://ithelp.ithome.com.tw/upload/images/20260907/20183886TfYFc0LTzx.png
https://ithelp.ithome.com.tw/upload/images/20260907/20183886FtseIiMArV.png
(4)回到終端機重啟虛擬機

   sudo reboot #重新開機

重開機後再次測試,從 Windows 複製任何網址或指令,進 Ubuntu 按下Ctrl + Shift + V,文字就會順暢貼上!

|明日目標:明天我們將設定本機與虛擬機的「共用資料夾」!|


上一篇
Day 07|Ubuntu 安裝流程全紀錄
下一篇
Day 09|設定「共用資料夾」與權限存取
系列文
大學生的VirtualBox虛擬機與Ubuntu實戰30天11
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言