microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.26k stars 812 forks source link

mkdir: cannot create directory ‘a’: Permission denied #4836

Open xzn opened 4 years ago

xzn commented 4 years ago

Cannot create directory with mkdir even though touch, rm, rmdir, mv all works fine.

Microsoft Windows [Version 10.0.19546.1000]

Arch Linux distro created with wsl --export Arch D:\arch.tar wsl --import Arch2 D:\WSL\Arch2 D:\arch.tar --version 2

cd /mnt/d/ mkdir a gives mkdir: cannot create directory ‘a’: Permission denied

Works fine at home directory though cd /mnt/c/Users/user mkdir a no problem here...

Where should I start to look for a solution for this?

sirredbeard commented 4 years ago

Can you reproduce this when using C:\ instead?

xzn commented 4 years ago

Same at /mnt/c

sirredbeard commented 4 years ago

Where did you get your Arch image?

I have tried the one at https://github.com/yuk7/ArchWSL/releases and except for some issues with permissions on the package GPG signatures it worked well for me.

xzn commented 4 years ago

I installed it using a guide from here https://github.com/DDoSolitary/LxRunOffline/wiki

WSL works fine, exporting it to WSL2 and I have trouble with mkdir.

Will try your link for now.

sirredbeard commented 4 years ago

Give the other Arch image a try, I know it's a good image.

What are the permissions in the folder what you are trying to create a folder?

Have you tried chown?

xzn commented 4 years ago

chown, chmod all works alongside touch, rm, rmdir, mv, etc. I just noticed mkdir wouldn't work when git clone gives me permission denied.

Thanks for helping btw! Will try a clean image instead of exporting from one I currently have.

anasalbadi commented 4 years ago

I have the same issue, I am trying to create a directory so that I can mount the drive

wwlwwww commented 4 years ago

I delete a git dict in windows explorer, then mkdir failed in WSL terminal.

kudaba commented 4 years ago

I just upgraded to ubuntu version 2 and I'm getting the same issue. I can't mkdir on my drives in /mnt/c and /mnt/d, but it works fine in my home folder and other areas. All other operations work fine. Even running with sudo doesn't help. My app that I'm working on also can't create folders.

kudaba commented 3 years ago

In my case it was a mount issue, or at least changing the mount options fixed it. Running the following command from https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/ worked for me:

sudo umount /mnt/c && sudo mount -t drvfs C: /mnt/c -o metadata

It's unclear but the command seems to be permanent. I'm not sure what happened during the upgrade from WSL 1 to 2 that affected this.

stu85010 commented 3 years ago

Hello there,

In my case, this issue was solved by: giving the Full control permission to your Windows account for this directory with Security tab image

Said, I'd created a directory at /c/src and trying to develop there, but the "User" group doesn't have Full control permission at that path, so the folder creation is failed in WSL in my case.

Then I was added the Full control permission to my Windows account at that folder, and the mkdir worked perfectly in that directory.

kudaba commented 3 years ago

Turns out my mount solution didn't last through a reboot, but the Full Control to users fixed it, thanks @stu85010.

EmilyGraceSeville7cf commented 3 years ago

I have the same issue on Ubuntu 20.04.2 LTS. Besides other commands like touch and I/O redirection fail with the same error. Why it happens?

Maybe this issue help.

kingmathers92 commented 3 years ago

You have to launch Git Bash as an administrator. Simple as that, it helped me.

shatanikmahanty commented 3 years ago

try command sudo chown -R "yourusername" . replace "yourusername" with the name of the user

georgearmando commented 2 years ago

try command sudo chown -R "yourusername" . replace "yourusername" with the name of the user

Thanks, this worked for me

hariadiarief commented 2 years ago

try command sudo chown -R "yourusername" . replace "yourusername" with the name of the user

you saved my life bro 😊😊😊

QuyetVV2 commented 2 years ago

try command sudo chown -R "yourusername" . replace "yourusername" with the name of the user

you saved my day 😊 thanks!

SunSummoner commented 1 year ago

In my case it was a mount issue, or at least changing the mount options fixed it. Running the following command from https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/ worked for me:

sudo umount /mnt/c && sudo mount -t drvfs C: /mnt/c -o metadata

It's unclear but the command seems to be permanent. I'm not sure what happened during the upgrade from WSL 1 to 2 that affected this.

image This is the error I am getting while trying to run a few jupyter notebooks. Will this command help with this issue?

harshalgunjal69 commented 11 months ago

try command sudo chown -R "yourusername" . replace "yourusername" with the name of the user

Thanks for this brooo

cookernetes commented 9 months ago

try command sudo chown -R "yourusername" . replace "yourusername" with the name of the user

Worked amazingly for me!

cookernetes commented 9 months ago

In my case it was a mount issue, or at least changing the mount options fixed it. Running the following command from https://devblogs.microsoft.com/commandline/chmod-chown-wsl-improvements/ worked for me: sudo umount /mnt/c && sudo mount -t drvfs C: /mnt/c -o metadata It's unclear but the command seems to be permanent. I'm not sure what happened during the upgrade from WSL 1 to 2 that affected this.

image This is the error I am getting while trying to run a few jupyter notebooks. Will this command help with this issue?

That looks less like a linux/system issue, and more like a Python issue for me...?