WSL Bash Permission denied to create files and directories
Solution 1
I would use sudo, i.e. sudo touch file.txt
. Works for me in WSL2 Ubuntu (which is Debian based)
Solution 2
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
?
Zoltan Szokodi
Updated on December 11, 2022Comments
-
Zoltan Szokodi over 1 year
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?