When I open my terminal and run WSL, the following error is shown:
The file cannot be accessed by the system.
[process exited with code 1 (0x00000001)]
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.
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
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.
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:
%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.%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.
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.
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:
This worked like a charm for me.
This is what worked for me:
C:\Users\yourname\AppData\Local\Packages
, search and delete:
CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc
CanonicalGroupLimited_Ubuntu20_04LTS_79rhkp1fndgsc!ubuntu2004
Microsoft_WSL
(I know, too many reboots, but this is how it finally worked for me)
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.
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.
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.
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).
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!
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!
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
Here is what worked for me :
https://www.revouninstaller.com/fr/start-freeware-download-portable/
It'll be used it to completely remove WSL.
Unzip the file and Launch the version compatible with your system
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
When the it's done, a second step will appear with the registry entries related to WSL. Check them all and delete.
Now disable the WSL and Virtual Machine Plateform.
Restart your computer
Re-enable WSL and Virtual Machine Plateform and Restart your computer again and it's OK.
Hope this will help
{}
button).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 thewsl.exe
. Could you clarify? Thanks.