Setting up a virtual Linux client on Windows host to do C++ programming
I recently needed to setup a virtual Linux machine on my Windows 10 system to do a C++ programming assignment for an online course.
To help others and as a reminder for myself I've documented what I went through. This includes any original links I found helpful, plus a summary in case the links go down. Originally writted April 2020. Updated October 2021.
- Installing the VMware virtual machine.
- Installing Debian 10 on VMware.
- Configuring Debian
- Copying files between Windows and your Linux client
- Transferring to another machine
- Our configuration
- Contact us
- Download VMware Workstation Player for Windows. This not the Pro version. Workstation Player is free for non-commercial, personal and home use. The latest version (October 2021) is VMware Workstation 16 Player.
- Install it. Accept all default options
- Download the file debian-10.3.0-amd64-netinst.iso from Debian - Getting Debian at Debian.org.
Put this in a "permanent" folder on your system where it can be found later.
- October 2021: Debian 11 is now available, but VMWare Workstation Player 16 does not seem to recognise it. We'll stick with the older Debian 10 for now.
- Open VMware Workstation Player on its home page.
- Click Create a New Virtual Machine.
- Select Install a disc image ISO and browse to where you stored the file from step 1. It should automatically detect Debian 10.
- I used Debian with Xfce. If you choose another option some customising advice below may not work.
- Follow the prompts and select the default settings. (I know the article above suggests using Custom Settings, but this worked for me).
- Once the installation is complete, click Power on this virtual machine. Select Graphical Install and follow the prompts.
- Enter a decent password for root and write it down somewhere!
- Set up a user account for yourself, say newuser. It helps to have an easy-to-type password for this because you'll be typing it a lot.
- Select All files in one partition for disk partitioning.
- The install program will download what is required and finish the setup. This will take some time!
You will also be prompted to install VM-tools. Unfortunately, what VMware suggests to do does not work anymore. See below.
While the standard Linux commands are usually the same for different packages, configuring each variant can be markedly different. Be warned: a lot of advice on the internet is either (a) old and out-of-date or (b) does not work on your particular configuration. Be prepared to keep looking and trying different ways. Don't pull out all your hair. This is just how Linux is.
sudo apt install build-essential"sudo" being a way to invoke super-user (root) privileges by an ordinary user. But then you get an error message
newuser is not in the suodoers list. It seems the default on the latest Debian installations is not to include new users in the sudoers list.
usermod -aG sudo newuser command did not work for us.
Log in as su: -- note the dash. It should give you the # prompt. su - cp /etc/sudoers /etc/sudoers.original Use the nano editor to open the sudoers file. nano /etc/sudoers and copy the line for root below and change the name to your own # User privilege specification root ALL=(ALL:ALL) ALL newuser ALL=(ALL:ALL) ALL Press control-O (Write Out) followed by 'Enter' to accept the filename and save, then control-X to exit the editor. Then type 'exit' to quit being superuser.The above advice was in a comment somewhere but, sorry, I can't remember where. Thanks to the contributor.
VMware Tools gives you the ability to copy-and-paste between your Linux client and your Windows host. This is really useful.
Don't bother with the tar download you get when you try to use the VMware menu options to add VMware Tools. It doesn't work anymore. Instead do the following from a command-line console.
sudo apt-get install open-vm-tools
Then you'll find that copy-and-paste and drag-and-drop still do not work. You also need open-vm-tools-desktop.
sudo apt install open-vm-tools-desktop
Then shut down your Debian virtual system and start it again: Player > Power > Shut down Guest.
Ref: How to Install GCC Compiler on Debian 10 Linux by Linuxize. A quick summary of the important bits:
First, update the packages list: sudo apt update Install the build-essential package by running: sudo apt install build-essential You may also want to install the manual pages that includes documentation about using GNU/Linux for development: sudo apt-get install manpages-dev To confirm that the GCC compiler is successfully installed type gcc --version: gcc --version
Consider buying Linuxize a coffee. We did. Thanks, guys.
Again, the advertised way to do this
sudo apt install netbeans did not work for us.
Ref: Installing NetBeans IDE on Debian 10 by Shahriar Shovon. Summary:
sudo apt install openjdk-11-jdk java -version2. Download the latest file netbeans-12.5-bin.zip from Apache NetBeans Releases. (The latest version as at October 2021 is 12.5 - edit the instructions below if you have a different version number).
cd ~/Downloads ls -lh sudo unzip netbeans-12.5-bin.zip -d /opt sudo nano /usr/share/applications/netbeans.desktop3. This creates a new file. Enter the following... and type control-W then control-X to save and exit the editor.
[Desktop Entry] Name=NetBeans 12 IDE Type=Application Encoding=UTF-8 Exec=/opt/netbeans/bin/netbeans Icon=/opt/netbeans/nb/netbeans.png Categories=GNOME;Application;Development; Terminal=false StartupNotify=true4. Finally
sudo chmod +x /usr/share/applications/netbeans.desktopNetBeans 12 IDE should now be available in your Applications > Run Program selections.
The C/C++ interface no longer comes as default with the NetBeans IDE. You need to add it. Update October 2021:
- Go to the Plugin Manager (Tools > Plugins > Settings)
- Enable the checkbox for NetBeans 8.2 Plugin Portal
- Click on the "Available Plugins" tab and click "Check for Newest"
- Check the "C/C++" box and click "Install"
Then use the Activate Features option to activate the C/C++ interface.
Update October 2021: And just to prove that last point, things are different this time when we installed the newer version 4.19.208-1 of Debian10 vs the old one 4.19.98-1 back in April 2020. This time we need to edit the LightDM configuration file.
sudo nano /etc/lightdm/lightdm.conf Uncomment and edit the lines: [Seat:*] autologin-user=<yourusername> autologin-user-timeout=0
Open the daemon.conf file in the Nano editor through the following command: sudo nano /etc/gdm3/daemon.conf Uncomment and edit the lines: AutomaticLoginEnable=true AutomaticLogin=<yourusername>
To avoid the delay when you start Debian 10, edit the GRUB configuration file and set GRUB_TIMEOUT to zero.
sudo nano /etc/default/grub GRUB_TIMEOUT=0
This is from the excellent page 30 Things to Do After Installing Debian 10.
You will find various methods described on how to set up a virtual directory to copy files between your Linux client and your windows host. This usually involves a convoluted "mount" command. It rarely works and if it does, it's a pain. Here's a better way.
- Install WinSCP on your Windows host.
- In a command-line console on your Linux client run
ip aThis will give you output similar to:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:0c:32:6f:cc:0d brd ff:ff:ff:ff:ff:ff inet 192.168.74.143/24 brd 192.168.74.255 scope global dynamic noprefixroute ens33 valid_lft 1791sec preferred_lft 1791sec inet6 fe80::00c:32ff:fe6f:cc0d/64 scope link noprefixroute valid_lft forever preferred_lft forever
- Take note of the IP address on line 9 after the word "inet". In this case it is "192.168.74.143".
- Start WinSCP and click on Login New Site.
- Under Host Name enter the IP address from above.
- For User name enter your Linux username and for Password your Linux user password. Then click on Login.
- This should log you into your Linux client and allow you to transfer files to and from your Windows host.
Note that the IP address will change from time to time. We found the WinSCP Synchronise option with Local as the target directory to be most useful.
If the above procedure fails to connect, you may need to install a OpenSSH server on your Linux client. There is an option somewhere in the Debian install procedure to check a box for this, which we missed.
sudo apt install openssh-serverTo start it, either reboot or do
sudo systemctl start ssh
Ref: Enable SSH on Debian 10 by Shahriar Shovon.
If you need to transfer VMware to another machine, follow the instructions at Techwalla's How to Transfer VMware VM to Another Computer by Chris Hoffman.
- Power down the virtual machine on your old computer (important).
- Copy the entire Working Directory for the virtual machine to your new computer.
- Install and start VMware on your new computer, select "Open Virtual Machine", browse to the new Working Directory you just copied, and double-click on the VMX file.
We hope this has helped you. If we've missed something or not acknowledged your work, please let us know.
For reference, here is our configuration as at 12 October 2021.
OS Name: Microsoft Windows 10 Home, 64-bit, version 20H2 OS Version: Version 10.0.19042.1237 VMware Workstation 16 Player 16.1.2 build-17966106 Guest operating system: Linux Version: Debian 10.x.64-bit uname -a Linux debian 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64 GNU/Linux echo $XDG_CURRENT_DESKTOP XFCE gcc --version gcc (Debian 8.3.0-6) 8.3.0 About NetBeans: Product Version: Apache NetBeans IDE 12.5 Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 2 Java: 11.0.12; OpenJDK 64-Bit Server VM 11.0.12+7-post-Debian-2deb10u1 Runtime: OpenJDK Runtime Environment 11.0.12+7-post-Debian-2deb10u1 System: Linux version 4.19.0-18-amd64 running on amd64; UTF-8; en_AU (nb)
And back in the day on 19 April 2020.
OS Name: Microsoft Windows 10 Pro OS Version: 10.0.18362 N/A Build 18362 VMware Workstation 15 Player 15.5.2 build-15785264 Guest operating system: Linux Version: Debian 10.x.64-bit uname -a Linux debian10 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64 GNU/Linux echo $XDG_CURRENT_DESKTOP XFCE gcc --version gcc (Debian 8.3.0-6) 8.3.0 About NetBeans: Product Version: Apache NetBeans IDE 11.3 Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 2 Java: 11.0.6; OpenJDK 64-Bit Server VM 11.0.6+10-post-Debian-1deb10u1 Runtime: OpenJDK Runtime Environment 11.0.6+10-post-Debian-1deb10u1 System: Linux version 4.19.0-8-amd64 running on amd64; UTF-8; en_AU (nb)
To contact us or comment on this page, please send us a message. If you have a suggestion to improve the advice on this page, please tell us. If you can't get it to work, sorry, you are on your own together with Google. That's just how Linux is. But, hey!, it's free.
This page first published 19 April 2020. Last updated 17 March 2022.