Open In App

How to Run Linux Software on Windows

Last Updated : 07 Nov, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Although Windows users could also wish to run Linux software, Linux users frequently desire to run Windows applications on Linux. You can use Linux applications without leaving Windows, whether you’re searching for an improved development environment or strong command-line tools. There are several alternatives to purchasing a new laptop to run the OS for running Linux applications on Windows. Since anybody can set up a virtual machine with a free Linux distribution without the requirement for software licenses, it is simpler than running Windows software on Linux. 

There are two popular methods for running Linux software on Windows, they are

  • WSL (Windows Subsystem for Linux)
  • Virtual Machine

In this article, we’ll discuss how to implement both of these methods briefly.

Note: If you’re using Windows 11, the below steps can be omitted since Windows 11 can run Linux GUI apps out of the box.

Method 1: Windows Subsystem for Linux (WSL) 

The WSL is a feature available in Windows that’ll enable one to run the Linux file system, along with Linux command-line tools and GUI applications, directly on Windows. And they can be completely integrated with Windows tools. But the only drawback of WSL is that they are mainly targeted for command-line tools and cannot be used for graphics-intensive programs.

Step 1: Enable the Windows Subsystem for Linux optional feature

Start PowerShell or Command-Prompt with administrator privileges and enter the following command to enable the WSL services on windows, this may be enabled by default in some systems.

Enable-WindowsOptionalFeature -Online -FeatureName -Microsoft-Windows-Subsystem-Linux

 

Alternatively, you can enable it using the ‘programs and features’ settings.

 

Step 2:  Enable the Virtual Machine platform and Install WSL2 

The virtual machine has to be enabled before installing WSL, this can be done using the following command.

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

 

Once it has been enabled, install WSL by entering the following command in PowerShell or Command-Prompt.

wsl --install

Set the default version of WSL to 2

wsl --set-default-version 2

 

Step 3: Download and Install a Linux distribution

You can download and install any distro of your choice, for the sake of convenience we’ll be installing ubuntu. Navigate to Microsoft Store and search for ‘ubuntu’ then install the application. Once downloaded open the app and follow through with the installation wizard. Once the installation process is complete you’ll be left with the following terminal. Linux Command-line tools can be executed using this terminal.

 

Step 4: Download and Install VcXsrv Windows X Server

The X server is a third-party display manager which is a provider of graphics resources and keyboard/mouse events. Download VcXsrv Windows X Server from the link provided – VcXsrv Windows X Server

Once the setup is complete, make sure to disable the access control option to avoid running into errors while running the GUI applications.

 

Step 5: Setting up the DISPLAY environment variable 

Starting the bash terminal, we have to set the DISPLAY environment variable so it uses the windows host IP address since WSL2 and Windows host doesn’t share the network device. Use any of the following commands to set the DISPLAY variable.

export DISPLAY=$(ip route|awk ‘/^default/{print $3}’):0.0

export DISPLAY=”`grep nameserver /etc/resolv.conf | sed ‘s/nameserver //’`:0″

 

Run the below command to check whether the variable is properly set or not.

echo $DISPLAY

 

The variable is reset every time a session is restarted so as to avoid running the command each and every time we open the terminal. We can add the command at the end of the /etc/bash.bashrc file. Open the bashrc file using nano or vim and then add the command at the end.

sudo nano /etc/bash.bashrc

 

Step 6: Create a .xsession file in the user’s home directory

The following command can be used to create a .xsession file in the user’s home directory /home/<user>/.xsession with the content xfce4-session.

echo xfce4-session > ~/.xsession

Now Windows desktop can run Linux GUI apps.

 

Method 2: Using a Virtual Machine

Using a Virtual Machine is the most efficient and easy way to run Linux apps on Windows, we’ll briefly discuss the installation and setting up a virtual machine with a Linux OS.

Step 1: Download and Install a Virtual Machine 

Download a virtual machine of your choice (Oracle or VMware), here we’ll be using a VMware workstation. Download the software from the below link and follow the installation process. Refer to this How to Install VirtualBox on Windows GeeksforGeeks article for setting up a virtual machine using oracle.

Download VMware Workstation.

 

Step 2: Download a Linux distribution of your choice

You can download any Linux distribution, below are some of the most popular choices along with their links.

Step 3: Installing the OS

Open VMware Workstation, and click on the ‘Create new Virtual Machine’. And then select the installer disc image option and choose the downloaded Linux operating system’s ISO file. 

 

Specify the disk capacity and click on next.

 

Name the virtual machine and move on to the next step.

 

 Start the virtual machine to boot up the OS and follow the installation steps. Once the installation is complete you can run any Linux GUI apps using the virtual machine.

 

Step 4: Starting and Running the applications

You can now run any Linux application while within the virtual machines environment, here are some examples.

$ gedit

 

$ sudo apt install x11-apps -y
$ xcalc

 

$ xclock

 

$ xeyes

 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads