Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
xzn opened this issue Jan 22, 2020 · 23 comments
Closed

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

xzn opened this issue Jan 22, 2020 · 23 comments

Comments

@xzn
Copy link

xzn commented Jan 22, 2020

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
Copy link
Contributor

Can you reproduce this when using C:\ instead?

@xzn
Copy link
Author

xzn commented Feb 16, 2020

Same at /mnt/c

@sirredbeard
Copy link
Contributor

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
Copy link
Author

xzn commented Feb 18, 2020

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
Copy link
Contributor

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
Copy link
Author

xzn commented Feb 18, 2020

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
Copy link

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

@wwlwwww
Copy link

wwlwwww commented May 8, 2020

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

@kudaba
Copy link

kudaba commented Jun 1, 2020

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
Copy link

kudaba commented Sep 25, 2020

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
Copy link

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
Copy link

kudaba commented Dec 4, 2020

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

@EmilyGraceSeville7cf
Copy link

EmilyGraceSeville7cf commented Apr 16, 2021

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
Copy link

kingmathers92 commented Jul 16, 2021

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

@shatanikmahanty
Copy link

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

@georgearmando
Copy link

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

Thanks, this worked for me

@hariadiarief
Copy link

hariadiarief commented Apr 13, 2022

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

you saved my life bro 😊😊😊

@QuyetVV2
Copy link

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

you saved my day 😊 thanks!

@SunSummoner
Copy link

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
Copy link

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

Thanks for this brooo

@cookernetes
Copy link

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

Worked amazingly for me!

@cookernetes
Copy link

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...?

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests