<img alt="How to Use Linux Commands on Windows" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/How-to-Use-Linux-Commands-on-Windows-1.jpg/w=800" data- decoding="async" height="420" src="data:image/svg xml,” width=”800″>

As a developer, you’re likely to find yourself split between using Windows in order to access all the tools, games, and software that come with it or using Linux, which is particularly ideal for developers. If you have a single computer, you’ll have to pick one operating system.

If you want to use two operating systems, you either have to dual boot, which is risky and complex, or use a virtual machine which can create performance overhead. Luckily, there’s a way to avoid choosing either of the two operating systems. Why pick when you can easily have both?

<img alt="How to Use Linux Commands on Windows" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/How-to-Use-Linux-Commands-on-Windows.jpg/w=1200" data- decoding="async" height="630" src="data:image/svg xml,” width=”1200″>

The Windows operating system allows you to leverage the power of Linux and Windows all from the same machine. From Windows, you can run Linux applications and Linux commands. The ability to run Linux commands from Windows is a game changer.

First, it allows you to have the best of two operating systems from one machine at no cost. You’ll be able to access all the software that comes with Windows and leverage its beautiful design and user-friendliness while still enjoying the power of the Linux command line. This allows you to automate tasks, work with various open-source tools, and access Windows files and executables directly from a bash shell.

Additionally, running Linux commands on Windows will allow you to easily install and manage your software using Linux package managers; you’ll be able to easily work on cross-platform projects and access Linux utilities such as SSH, grep, sed, and awk.

Finally, using Linux commands from Windows provides a more gentle introduction to Linux for Windows users, making it easier to transition to fully using the Linux operating system in case you need to. The tool that allows you to run Windows on Linux is the Windows Subsystem for Linux.

Windows Subsystem For Linux (WSL)

<img alt="YouTube video" data-pin-nopin="true" data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/maxresdefault.jpg64ec8a47575ac.jpg" height="720" nopin="nopin" src="data:image/svg xml,” width=”1280″>

The Windows Subsystem For Linux (WSL) is a Windows feature first released in 2016. WSL allows you to install a real Linux distribution directly on Windows and run the Linux file system, command line tools, GUI applications, and utilities directly on Windows without installing a virtual machine or dual boot Linux and Windows.

To use WSL, you need to be running Windows 11 or  Windows 10 version 2004 and higher, with build 19041 and higher. WSL supports x64 and Arm CPUs.

WSL allows the installation of Linux distributions such as Ubuntu, OpenSUSE, Kali, Debian, Fedora, Fedora remix, and Arch Linux. All these distributions are available for installation from the Microsoft Store.

With WSL, you’ll have an integrated Linux experience on Windows such that you can invoke Linux executables from Windows and view Linux files from Windows. You can also invoke Windows executables and access Windows files from the Linux Bash Shell.

How the Windows Subsystem For Linux Works

<img alt="How-the-Windows-Subsystem-For-Linux-Works-1" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/How-the-Windows-Subsystem-For-Linux-Works-1.jpg/w=1200" data- decoding="async" height="630" src="data:image/svg xml,” width=”1200″>

Behind the scenes, WSL is not an emulator or virtualizer. WSL acts as a compatibility layer sitting between Windows and Linux. Technically, WSL allows you to run unmodified ELF64 Linux binaries, thus providing an integrated experience.

To do this, WSL provides a Microsoft developed, Linux kernel interface that sits on top of the Windows Kernel. This Linux kernel runs inside of Windows and is built on the core technology of Hyper-V.

Hyper-V is a native hypervisor that is software that can create and run virtual machines. Hyper-V provides hardware virtualization, which means that virtual machines run on virtual hardware. WSL being built on the core technology allows it to provide improved file system performance and better Linux Application support.

To run unmodified ELF64 Linux binaries, WSL translates Linux systems calls from Linux binaries into Windows System Calls for them to be executed at native speed.

On the Linux kernel interface running on Windows and provided by WSL, different Linux distributions can be installed. These distributions provide a container-like environment with all dependencies and package management needed to run Linux applications. Linux applications run within these distributions.

Why Use The Windows Subsystem For Linux?

<img alt="Why-Use-The-Windows-Subsystem-For-Linux" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/Why-Use-The-Windows-Subsystem-For-Linux.jpg/w=908,h=630" data- decoding="async" height="630" src="data:image/svg xml,” width=”908″>

If you have used a virtual machine to run Linux on Windows before, you might be wondering what WSL has to offer you that a virtual machine can’t. Well, for a start, WSL uses fewer computer resources than running a virtual machine.

WSL uses way less storage and memory and does not have a large footprint on your CPU usage like a virtual machine. WSL also allows you to access your Windows files from Linux, a feature that allows you to use Linux command line tools on the same files you use your Windows application on.

Another key feature of WSL is how easy it is to run Linux. Virtualization can be complicated, and WSL avoids all of that. Additionally, it makes it easy to install a variety of Linux distributions and also to change from one Linux distribution to another.

To developers, WSL allows you to enjoy the best of two worlds. You can run Linux and have access to all the unique programming tools and open-source resources developed with Linux in mind, while still enjoying all the features that come with Windows.

With WSL, you won’t run into compatibility issues because you’re using tools that only run on Linux. Additionally, switching between the two operating systems will be much faster and easier and won’t require a complicated setup or an extra computer.

To get started using Linux commands, an easy way to start is to Install Windows Subsystem For Linux on your machine.

How to Install Windows Subsystem for Linux

1. Confirm your computer meets the following requirements: it should be a 64-bit running Windows 11 or Windows 10 version 2004 and higher. The Windows 10 version should be built 19041 and higher. Make sure you are connected to the internet.

2. Open the start menu, search for Powershell, and select Run as administrator to open with administrator privileges.

<img alt="powershell-admin" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/powershell-admin.png/w=704,h=630" data- decoding="async" height="630" src="data:image/svg xml,” width=”704″>

3. On the open PowerShell enter the following command

wsl --install

The command will enable all the features needed to run WSL and make any updates that your operating system might need to run WSL seamlessly. First, a virtual machine platform platform will be installed, and then finally, WSL will be installed. Be patient as this can take a while.

<img alt="installing-WSL" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/installing-WSL.png/w=676" data- decoding="async" height="380" src="data:image/svg xml,” width=”676″>

4. Once the process completes, you can confirm WSL has been installed by running wsl –install again. In case you see a help page for WSL as shown below, the installation was successful.

<img alt="wsl-installed" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/wsl-installed.png/w=859" data- decoding="async" height="483" src="data:image/svg xml,” width=”859″>

5. The next step is to install a Linux distribution to use with WSL. To see all the available distributions that can be installed, enter the following command into PowerShell

wsl --list --online

You’ll get back a list of available distributions as shown below:

<img alt="linux-distros-available" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/linux-distros-available.png/w=664" data- decoding="async" height="374" src="data:image/svg xml,” width=”664″>

6. From the list, you can install any Linux distribution you want by entering

wsl --install -d 

For instance, to install Ubuntu 22.04 Long Term Support, execute the following command:

wsl --install -d Ubuntu-22.04
<img alt="installing-ubuntu" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/installing-ubuntu.png/w=665" data- decoding="async" height="375" src="data:image/svg xml,” width=”665″>

Wait for the process to finish. You’ll then be presented with a message for successful completion an Ubuntu terminal window will open as shown below:

<img alt="unix-username" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/unix-username.png/w=908" data- decoding="async" height="511" src="data:image/svg xml,” width=”908″>

Enter your username and password to set up your Environment. Remember, with Linux, when you enter your password in the terminal, you won’t see any characters as you type. However, your input is still captured.

An alternative to installing a distribution from Powershell is to open Microsoft Store and Search for WSL. You’ll be presented with all available distributions. Click Get to install your desired distribution

<img alt="get-linux-distro-" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/get-linux-distro-.png/w=802" data- decoding="async" height="452" src="data:image/svg xml,” width=”802″>

7. After entering your username and password, you’ll be able to access Ubuntu on Windows as shown below:

<img alt="start-using-ubuntu" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/start-using-ubuntu.png/w=900" data- decoding="async" height="506" src="data:image/svg xml,” width=”900″>

Feel free to start using your favorite Linux commands.

Your installed Linux Distribution can easily be found from the start menu any time you want to open it

<img alt="how-to-find-your-linux-distro" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/how-to-find-your-linux-distro.png/w=760" data- decoding="async" height="427" src="data:image/svg xml,” width=”760″>

In your file explorer, you’ll also notice a new storage location called Linux, where all your distributions and Linux files are stored.

<img alt="linux-in-file-manager" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/linux-in-file-manager.png/w=675" data- decoding="async" height="381" src="data:image/svg xml,” width=”675″>

Windows Subsystem for Linux is an excellent way to run Linux commands on Windows. In case you are unable to install WSL on your machine, probably because your computer does not meet the requirements needed to install WSL, there are excellent alternatives to WSL that you can install. Let us look at two emulators that can help you run Linux commands on Windows.

Use Linux Commands on Windows using Cygwin

Cygwin is a large collection of GNU and Open Source tools which together provide functionality that is similar to that of a Linux distribution on Windows.

Cygwin is a UNIX emulator and provides a UNIX shell environment on Windows giving you access to a variety of tools from the Linux ecosystem. 

As their tagline states, Cygwin aims to provide a Linux feeling on Windows. However, Cygwin does not allow you to run Linux applications on Windows. Cygwin works with all x86_64 versions of Windows, starting from Windows 7.

To install Cygwin:

1. Navigate to their installation page download the setup-x86_64.exe file and run it

<img alt="Cygwin-install-page-1" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/Cygwin-install-page-1.png/w=794" data- decoding="async" height="447" src="data:image/svg xml,” width=”794″>

2. Go through the first few screens on the installation wizard screen, clicking Next to keep the default selections. This will keep the Download source to Install from the internet, use the default suggested root and package directory, and use the System Proxy Settings.

3. When it comes to choosing a site from which to download Cygwin packages, click on any of the provided links the click on Next.

<img alt="download-sites-cygwin-6" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/download-sites-cygwin-6.png/w=532" data- decoding="async" height="393" src="data:image/svg xml,” width=”532″>

4. When selecting the packages to install, keep the default section. That is Under view; make sure it is Category that is selected then click on Next. This will take you to the review and confirm changes screen. Click on Next to start installing Cygen.

<img alt="install-default-cygwin-7" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/install-default-cygwin-7.png/w=532" data- decoding="async" height="393" src="data:image/svg xml,” width=”532″>

5. Wait for the installation process to finish.

<img alt="installation-cygwin-9" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/installation-cygwin-9.png/w=532" data- decoding="async" height="393" src="data:image/svg xml,” width=”532″>

6. Click on Finish to complete the installation process. You can uncheck the boxes in case you don’t want to create a Cygwin icon on the Desktop and the Start Menu.

<img alt="finish" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/finish.png/w=532" data- decoding="async" height="393" src="data:image/svg xml,” width=”532″>

7. You can find Cygwin’s icon on the start menu or on the Desktop. Double-click to launch Cygwin

<img alt="Termina-Cygwin-open" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/Termina-Cygwin-open.png/w=760" data- decoding="async" height="427" src="data:image/svg xml,” width=”760″>

8. Cygwin will open with a bash shell window where you can start using Linux commands just like you were on a Linux machine.

<img alt="use-the-terminal" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/use-the-terminal.png/w=581" data- decoding="async" height="370" src="data:image/svg xml,” width=”581″>

Use Linux Commands on Windows using QEMU

QEMU is a generic and open-source machine emulator and virtualizer. QEMU is commonly used as a system emulator where it provides a virtual model of another machine where you can run a different operating system from the one you are on.

To install QEMU, 

1. Go to the downloads page and download the qemu setup .exe file for 64-bit computers and run it once the download is complete

<img alt="QEMU-downloads-page" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/QEMU-downloads-page.png/w=794" data- decoding="async" height="447" src="data:image/svg xml,” width=”794″>

2. You’ll be presented with the QEMU setup wizard window. Click Next to proceed. In the next screens, agree to the license agreement, click next to install the default selected components, and select your installation location or leave the default selected Local disk C. For simplicity, do not change your installation location

<img alt="qemu-welcom-screen" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/qemu-welcom-screen.png/w=499" data- decoding="async" height="388" src="data:image/svg xml,” width=”499″>

3. Wait for the installation to complete and click Finish.

<img alt="qemu-installation" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/qemu-installation.png/w=499" data- decoding="async" height="388" src="data:image/svg xml,” width=”499″>

4. The next step is now adding the file path to where QEMU was installed to our environment variable. To do this, navigate to My Computer -> Local Disk C -> Program Files -> qemu as shown:

<img alt="file-explorer-qemu" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/file-explorer-qemu.png/w=675" data- decoding="async" height="476" src="data:image/svg xml,” width=”675″>

5. Highlight and copy the file path to where QEMU is installed in your machine

<img alt="file-path-windows" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/file-path-windows.png/w=794" data- decoding="async" height="559" src="data:image/svg xml,” width=”794″>

6. Open Windows Settings, click on System, scroll the left menu bar, and select About. In the About page click on Advanced system settings to open the System Properties window

<img alt="windows-about-page-advance" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/windows-about-page-advance.png/w=753" data- decoding="async" height="425" src="data:image/svg xml,” width=”753″>

7. In the System Properties Window in the Advanced tab, click on Environment Variables

<img alt="System-Properties-Windows" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/System-Properties-Windows.png/w=790" data- decoding="async" height="544" src="data:image/svg xml,” width=”790″>

8. On the Environment Variables page, double-click on Path, to add the path where QEMU was installed.

<img alt="path-variables" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/path-variables.png/w=618" data- decoding="async" height="585" src="data:image/svg xml,” width=”618″>

9. Click on New then paste in the path URL you copied and click on Okay to add it. Click on Okay on the Environment Variables Windows and System Properties windows to save the changes and close the windows.

<img alt="add-environment-variable" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/add-environment-variable.png/w=527" data- decoding="async" height="501" src="data:image/svg xml,” width=”527″>

10. To confirm QEMU was successfully installed and its path successfully added to the environment variables, open PowerShell and execute the following command:

qemu-img --help

In case both processes were a success, you’ll see such a window showing the version of the qemu-img installed and its help page.

<img alt="qemu-help-menu" data- data-src="https://kirelos.com/wp-content/uploads/2023/08/echo/qemu-help-menu.png/w=793" data- decoding="async" height="442" src="data:image/svg xml,” width=”793″>

11. To start emulating a Linux operating system, you’ll have to download the .iso image of the Linux distribution you want to emulate using QEMU. Then, from Powershell, navigate to the storage location of the .iso file and execute

qemu-system-x86_64.exe -boot d -cdrom  -m 

To emulate Ubuntu 22.04.3 from an iso file I have downloaded, I’d navigate to where the .iso file is located and execute:

qemu-system-x86_64.exe -boot d -cdrom ubuntu-22.04.3-desktop-amd64.iso -m 2048

This will open a bash shell window where you can start using Linux commands.

Conclusion

When using Linux on Windows, it is important to keep in mind that while you can access Windows files from Linux and vice versa, file paths may need adjustments.

Some OS-specific commands may not also work as expected, file permissions between the two operating systems are handled differently, and you’ll need to handle resource allocation for the two systems to ensure both have enough to run seamlessly. Additionally, make sure to always back up your important files in case anything goes wrong.

You may also explore WSL2 Capabilities, the installation process, and how to use it effectively.