Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WSL Bash Permission denied to create files and directories

I've set up WSL (Windows Subsystem for Linux) on my Windows 10 to utilize Bash. I've created a Linux user, installed the latest updates and upgrades, and I know how to access the Windows files through /mnt/c/Users etc. When I try to create a new file on my desktop, it denies permission:

rupert@DESKTOP-GT4APR9:/mnt/c/Users/zolta/OneDrive/Desktop$ touch
file.txt touch: cannot touch 'file.txt': Permission denied

How can I grant my Linux Bash user permission to create and modify files and directories on my Windows user desktop? Is that possible at all?

like image 583
Zoltan Szokodi Avatar asked Dec 20 '25 03:12

Zoltan Szokodi


2 Answers

I would use sudo, i.e. sudo touch file.txt. Works for me in WSL2 Ubuntu (which is Debian based)

like image 98
hndcrftd Avatar answered Dec 21 '25 23:12

hndcrftd


The path with which you are having problems,

rupert@DESKTOP-GT4APR9:/mnt/c/Users/zolta/OneDrive/Desktop

appears to live on OneDrive: While I am not a OneDrive expert, my understanding is that to access it from the command line, the remote data stored on OneDrive has to synced locally.

If you cd rupert@DESKTOP-GT4APR9:/mnt/c/Users/zolta, can you touch file.txt there?

What about accessing these folders from cmd or pwsh?

like image 27
Peter Whittaker Avatar answered Dec 21 '25 23:12

Peter Whittaker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!