.. / return

How to Run Linux Commands on Windows Without Keeping Software Installed

2025-12-22Mithila Prabahwara

Most developers prefer the Linux shell environment over the Windows Command Prompt or PowerShell. We often rely on Linux commands for essential development work such as configuring servers, managing cloud instances, and automating tasks. To be honest, the Linux CLI is often easier to learn and use than PowerShell.

Many developers use tools like Cygwin, WSL2, or Git Bash to bridge this gap. But what if you want to use Linux commands on Windows without keeping the full software suite installed? That is exactly where MSYS2 comes in.

Today, I will show you how to get native Linux commands on Windows without being tied down by a permanent installation.

Step 1: Get MSYS2

First, you need to acquire the msys2 files. You can download the installer from the official website or use a package manager like Scoop to handle it temporarily.

scoop install msys2

Step 2: Locate the usr\bin Directory

After installation, navigate to the MSYS2 binary directory.

  • Via Scoop: %USERPROFILE%\scoop\apps\msys2\current\usr\bin
  • Manual Install: C:\msys64\usr\bin (or your custom install path)

Step 3: Select Your Commands

In this directory, you will find a multitude of executable (.exe) files. Each file corresponds to a specific Linux command (e.g., ls.exe, grep.exe, sed.exe). Identify and select the specific commands you want to use.

Step 4: Copy to a Portable Location

Create a new folder (e.g., C:\Linux-Tools) and copy your selected .exe files into this directory. This folder will serve as your portable Linux toolkit.

Step 5: Update Your System PATH

To run these commands from anywhere, add your new folder to the Windows PATH environment variable.

  1. Search for "Edit the system environment variables" in Windows.
  2. Click "Environment Variables".
  3. Under "User variables", select Path and click Edit.
  4. Click New and paste the path to your folder (e.g., C:\Linux-Tools).
  5. Click OK to save.

Step 6: Verify and Run

Open a new Command Prompt or PowerShell window and type the name of one of your copied commands (e.g., ls). It should execute just like in Linux!

Step 7: Uninstall MSYS2

Once you have verified that your Linux commands are working, you can uninstall MSYS2. (scoop uninstall msys2 if you installed it via Scoop.)


⚠️ Important Note on Dependencies

Some commands may fail to run because they require additional dependencies, specifically DLL (Dynamic-Link Library) files. If you run a command and get an error about a missing DLL:

  1. Read the error message to identify the missing file name.
  2. Go back to the generic MSYS2 usr\bin folder.
  3. Find that specific .dll file.
  4. Copy it to your portable folder alongside your executables.
  5. Retry running the command.

Repeat this process until all dependencies are met.

Note: Please use this commands with your own risk. I am not responsible for any damage that may occur. Becuase, some of the commands can conflict with the Windows commands.