8

When I open my terminal and run WSL, the following error is shown:

Error shown

The file cannot be accessed by the system.

[process exited with code 1 (0x00000001)]
4
  • 3
    What research have you done and what have you tried to resolve the issue? Please avoid screenshots of text and instead post your code using the appropriate code tags (e.g. {} button). Commented Apr 4, 2022 at 2:46
  • Reset Windows Terminal. Edit your question to include the necessary information to answer your question
    – Ramhound
    Commented Apr 4, 2022 at 3:49
  • 2
    From the Stack Overflow question that you posted, I got the impression that this was happening even if you just ran wsl.exe from CMD or PowerShell, right? This version makes it sound like a Windows Terminal problem, but it sounded more like a permissions problem of some sort on the wsl.exe. Could you clarify? Thanks. Commented Apr 4, 2022 at 4:50
  • Updating to the wsl pre-release fixed this for me. See: superuser.com/questions/1714736/… Commented Mar 29 at 20:30

10 Answers 10

9

I had the same error in Windows 11 Professional. Seemed to happen after rolling back to a system restore point but I am not absolutely sure what triggered it.

For me, I went to "Settings -> Apps -> Installed Apps -> Windows Subsystem for Linux" and clicked the "Repair" option and this resolved the issue.

4

I had the same issue after a black screen. This seems to be caused by corruption of the wsl subsystem. It can be fixed running dism cleanup on an elevated shell:

dism /Online /Cleanup-Image /RestoreHealth
1
  • 1
    I tried this but it did not work for me. I still get "The file cannot be accessed by the system."
    – Frederik
    Commented Mar 15, 2023 at 11:22
4

I had the same issue and what helped was @chrisb solution. However, in w11 home, the Windows Subsystem for Linux is under "Settings -> System -> System Components -> Windows Subsystem for Linux" and click the repair button.

2
  • I can't upvote this yet, but this solved exactly my issue, which I believe the cause was a system restore (as was mentioned elsewhere). I'm sure many other answers are valid for the varying states a user could find themselves in, but this specific answer did the job the best for me. Thank you Jakub!
    – Jimmay
    Commented Apr 8 at 14:57
  • After a system restore, I had the same issue, and this fixed it among all the other solutions stated here. Commented May 26 at 9:00
1

Based on your Stack Overflow question and the error you are seeing:

The file cannot be accessed by the system.

I have a hunch this may be related to compressed or encrypted files. Check a couple of things:

  • In Windows Explorer, open %userprofile%\AppData\Local\. Right click on the Temp folder there and select Properties, then the Advanced button. If either "Compress ..." or "Encrypt ..." options are selected, then unselect them.
  • Repeat the same process for the WSL Distribution Package. In Explorer, open %userprofile%\AppData\Local\Packages, find the Canonical...Ubuntu... folder and check if it is encrypted or compressed.

I'm hoping that solves it for you, but if not, we'll need more information/details in your question.

1

I got this error and uninstalled WSL and Ubuntu via the Start Menu. Then I installed WSL from the Microsoft Store: https://www.microsoft.com/store/productId/9P9TQF7MRM4R and got less issues.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Jan 3, 2023 at 1:12
1

I got this exact same error after restoring windows to previous point, but unfortunately the above methods did not work. This is what worked for me:

  1. Turn on show hidden and system files, in Settings>System>For developers>File Explorer
  2. Go to C:\Program Files, (the hidden folder WindowsApps could not be accessed by my user profile.)
  3. Change ownership/permissions in folder properties > Security > Advanced to give full control

This worked like a charm for me.

1

This is what worked for me:

  1. Uninstall Ubuntu (reboot)
  2. Remove Subsystem from Windows features (reboot)
  3. From the folder C:\Users\yourname\AppData\Local\Packages, search and delete:
    1. CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc
    2. CanonicalGroupLimited_Ubuntu20_04LTS_79rhkp1fndgsc!ubuntu2004
    3. Microsoft_WSL
  4. Reboot and re-install subsystem (reboot)
  5. Go to M$ store and download LTS.
  6. Reboot for the last time and run Ubuntu to continue the installation.

(I know, too many reboots, but this is how it finally worked for me)

0

Here is what worked for me after trying all of the above:

Locate the Ubuntu distro's and delete them (see Vincent's message above for steps: https://superuser.com/a/1832845/447374)

Next I followed Jakub's answer to Repair and Reset WSL(https://superuser.com/a/1836962/447374)

Finally I uninstalled the WSL Kernel Update in Control Panel > Program and Features.

Then I started up Windows PowerShell in Admin mode (Windows START > type PowerShell > right-click the app icon and choose Run as administrator.. option).

In the console type: dism /Online /Cleanup-Image /RestoreHealth wait for the process to complete and reboot your machine.

Start PowerShell in admin mode again and this time type WSL you should see message similar to:

WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel

Do as it says navigate to https://learn.microsoft.com/en-gb/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package and download the kernel update package:

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

Run the MSI file and complete the update (its just a few clicks and done).

Next we need to update the version of WSL as per the WSL manual install guide I just linked up above:

Start a regular PowerShell terminal and type the following:

wsl --set-default-version 2

You should see the message:

For information on key differences with WSL 2 please visit https://aka.ms/wsl2 The operation completed successfully.

Next type wsl to start the native image you should see the message:

Windows Subsystem for Linux is now available in the Microsoft Store! You can upgrade by running 'wsl.exe --update' or by visiting https://aka.ms/wslstorepage Installing WSL from the Microsoft Store will give you the latest WSL updates, faster. For more information please visit https://aka.ms/wslstoreinfo

I don't recommend visiting the store this is the cause of the problem at least with the Ubuntu images instead in the same terminal window type exit to quit the WSL image and then type:

wsl --list --online

You should see a similar result:

NAME FRIENDLY NAME Ubuntu Ubuntu Debian Debian GNU/Linux kali-linux Kali Linux Rolling Ubuntu-18.04 Ubuntu 18.04 LTS Ubuntu-20.04 Ubuntu 20.04 LTS Ubuntu-22.04 Ubuntu 22.04 LTS OracleLinux_7_9 Oracle Linux 7.9 OracleLinux_8_7 Oracle Linux 8.7 OracleLinux_9_1 Oracle Linux 9.1 openSUSE-Leap-15.5 openSUSE Leap 15.5 SUSE-Linux-Enterprise-Server-15-SP4 SUSE Linux Enterprise Server 15 SP4 SUSE-Linux-Enterprise-15-SP5 SUSE Linux Enterprise 15 SP5 openSUSE-Tumbleweed openSUSE Tumbleweed

Here we want Ubuntu in my case so I typed the following:

wsl --install -d Ubuntu

Defaulting for the latest version you can use one of the specific ones listed for your preference.

Once installed the Ubuntu setup process starts type your chosen username and password to complete the setup process.

Now type sudo visudo at the Ubuntu bash prompt to edit the sudo config file and add modify the following lines:

root ALL=(ALL:ALL) ALL

Add a new line below the root user as follows (where username us the Ubuntu user you just created):

root    ALL=(ALL:ALL) ALL
username ALL=(ALL:ALL) ALL

Press Ctrl+s to save and then Ctrl+x to exit finally type sudo /etc/sudoers to confirm your username is present in the sudo file.

Last but not least do an update of the system:

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade press Y when prompted to continue and ensure the updates were successful.

Now type source ~/.bashrc to reload the environment changes.

Ensure all is okay then close the terminal and reboot Windows - confirm all is okay and WSL is back up and running.

Additional steps:

Set default distro:

Type the following to ensure Ubuntu is the default WSL distro:

wsl --set-default Ubuntu

Now type wsl --list to ensure Ubuntu is the default distro:

Windows Subsystem for Linux Distributions:
Ubuntu (Default)
docker-desktop-data
docker-desktop

type wsl --update to ensure everything is up to date.

Exporting

You could backup your existing distros if you don't want to lose them prior to running the above repair and reset steps you do this by typing the following:

wsl --export Ubuntu "C:\WSL_backups\ubuntubackup.tar"

Location is anywhere suitable to hold at least 25GB of data and the name of the tarball (the zip archive format .tar) can be whatever you want.

The backup process can vary usually completes in a few minutes depends on how big your distro is on disk.

Importing

Type the following to import your backed up distro into your repaired & reset WSL environment:

wsl --import Ubuntu "C:\WSLDistros" "C:\WSL_backups\ubuntubackup.tar"

Here we are telling WSL to import the Ubuntu distro into "C:\WSLDistros" location from the backup location "C:\WSL_backups\... (your locations will vary).

Optional zsh terminal

You can install Oh my zsh an awesome terminal full of candy and goodness following these steps:

sudo apt update 
sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev zsh

Once installed run the following command to install Oh My Zsh terminal:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

When complete you should see the colourful message Oh My Zsh has been installed. Next type the following to set Zsh as the default shell:

chsh -s $(which zsh)

You are now good to go!

Appendix

To check Ubuntu is installed type the following command:

cat /etc/lsb-release

This should show a similar result:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"

If you need to apply environment changes e.g. config update most of the time you can type the following command to reload your terminal:

source ~/.zshrc

Thank you to my dev manger Alan R for the above :-)

Hope this detailed post helps someone feel free to edit the post if I have missed something!

0
-1

I just got this issue also, and I am concerned about a few things.

-sfc /scannow did not resolve

-dism /Online /Cleanup-Image /RestoreHealth did not resolve

-Attempting to run Ubuntu.exe executed the same results (the file cannot be accessed by the system)

-wsl.exe WILL run, but not from the profile dropdown in windows terminal preview.

-If I uninstall, && then reinstall Ubuntu via the Microsoft store, will I lose any of my files and data.? I do not want to uninstall && reinstall if I basically have to wipe all my Ubuntu files

1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Apr 9 at 7:53
-2

Here is what worked for me :

  1. I downloaded Revo Uninstaller (the free and portable version) from

https://www.revouninstaller.com/fr/start-freeware-download-portable/

It'll be used it to completely remove WSL.

  1. Unzip the file and Launch the version compatible with your system

  2. Then go to the second tab "Windows Apps" and look for "Windows Subsystem for Linux". Double click on it to completely uninstall it (make sure you checked the "create restore point"). See the image here

  3. When the it's done, a second step will appear with the registry entries related to WSL. Check them all and delete.

  4. Now disable the WSL and Virtual Machine Plateform.

  5. Restart your computer

  6. Re-enable WSL and Virtual Machine Plateform and Restart your computer again and it's OK.

Hope this will help

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .