Error when running bash on Windows terminal: No such file or directory

Abstract: Resolve the No such file or directory error when running bash on Windows by verifying WSL installation and using wsl.exe instead of legacy commands.

Created: 2026-10-23 by

The "No such file or directory" error when running bash on Windows typically occurs because the command is not found in your system PATH or the Windows Subsystem for Linux (WSL) distribution is corrupted. To fix this, verify that WSL is installed, ensure you are using the correct executable path like wsl.exe, and check for missing Linux binaries within your specific distribution.

Understanding the Root Cause

This error is distinct from a missing Windows application. When you type bash into the Windows Command Prompt or PowerShell, the operating system searches for an executable named bash.exe in your system's PATH environment variables. If WSL is installed but not configured correctly, or if the default distribution is missing its core files, Windows cannot locate the binary.

A common misconception is that bash.exe should exist in C:\Windows\System32. It does not. The Bash shell runs inside the Linux subsystem. Therefore, the error usually indicates that either the WSL feature is disabled, the default distribution failed to install properly, or you are attempting to run a legacy command without using the modern wsl.exe launcher.

Verifying WSL Installation Status

Before troubleshooting the specific file error, confirm that the underlying infrastructure is present. Open PowerShell as Administrator and run the following command:

wsl --list --verbose

If this command returns an error stating that WSL is not installed, or lists no distributions, the subsystem itself is missing. In this case, you must enable the feature via Settings > Apps > Optional Features > Add a Feature and search for "Windows Subsystem for Linux." Alternatively, run wsl --install in PowerShell to perform a default installation of Ubuntu and the necessary kernel components.

If the command works but shows a status of Stopped or Error, the distribution may be corrupted. You can try repairing it by uninstalling and reinstalling the specific distro using the Microsoft Store or by downloading the tarball directly from the vendor's GitHub repository.

Using the Correct Launch Commands

Modern versions of Windows 10 and 11 include wsl.exe as the primary interface for interacting with Linux distributions. Instead of typing bash, which relies on legacy compatibility layers that may be broken, use:

wsl

This command launches the default distribution defined in your WSL configuration. If you have multiple distributions installed, you can specify one explicitly:

wsl -d Ubuntu-20.04

If you specifically need the bash shell for scripting purposes and encounter the error, ensure you are calling it from within the WSL environment. Once inside WSL, simply typing bash will work because the Linux filesystem contains the actual /bin/bash binary. The error only persists when Windows tries to execute a Linux binary directly through the NTFS layer without the WSL bridge.

Checking Environment Variables and PATH

In rare cases where you have manually added WSL paths to your Windows environment variables, a typo or incorrect path can cause this issue. Check your System Environment Variables under Control Panel > System > Advanced System Settings > Environment Variables.

Look for any entries pointing to %LOCALAPPDATA%\Microsoft\WindowsApps. This folder often contains shims that redirect commands like bash.exe to WSL. If this path is missing or corrupted, Windows loses the ability to route the command. Reinstalling the Windows Terminal app from the Microsoft Store often repairs these shims automatically.

Additionally, if you are using a third-party terminal emulator, ensure it is not overriding the default behavior. For instance, some older versions of Git Bash or Cygwin might conflict with WSL integrations. Try launching the built-in Windows Terminal to isolate whether the issue is with the host application or the WSL installation itself.

Repairing Corrupted Distributions

If wsl --list --verbose shows a distribution but it fails to launch, the internal file system may be damaged. You can attempt a repair by exporting and re-importing the distribution, though this is complex. A simpler approach is to delete the corrupted instance and create a new one.

Run the following to unregister the broken distro:

wsl --unregister Ubuntu

Then, reinstall it via the Microsoft Store or by running wsl --install Ubuntu. This process recreates the necessary directory structure and installs fresh copies of core utilities like bash, ls, and apt.

For more complex issues involving logon sessions or update errors, refer to our guide on Can't Launch WSL: A Guide to Fixing Windows Subsystem for Linux Issues. If you are experiencing performance issues after repair, check out Slow moving folder with a lot of files from Windows to WSL to optimize file access speeds.

Frequently Asked Questions

Why does bash work in WSL but not in CMD?

Bash is a Linux executable located in the Linux filesystem, not the Windows NTFS partition. CMD cannot natively execute Linux binaries without the WSL translation layer. You must use the wsl command to bridge the gap between Windows and Linux environments.

How do I reset WSL handlers if they are broken?

There is no single command to reset handlers. The most effective method is to uninstall all WSL distributions using wsl --unregister and then reinstall them. This forces Windows to rebuild the registry keys and shim links associated with each distro.

Is bash.exe located in System32?

No. bash.exe does not exist in C:\Windows\System32. Any reference to it in that location is likely a shim or a leftover from a different toolchain. The actual binary resides inside the virtual hard disk of your WSL distribution.

What if I get a "Logon Session Not Found" error?

This error often accompanies WSL update failures. It suggests a mismatch between the Windows user session and the WSL service. Ensure your Windows account has administrative privileges and try restarting the computer to clear stale session tokens before attempting to launch WSL again.

Can I use PowerShell instead of CMD?

Yes. PowerShell supports the same wsl commands as CMD. In fact, PowerShell offers better integration with Windows features and is the recommended shell for managing WSL instances programmatically. The "No such file or directory" error will appear in PowerShell if the underlying WSL installation is missing.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More