Is there a way to access Windows file with administrative rights using WSL?
sudo vi /mnt/c/Users/a/admin/file.txt
I wrote a script that makes this easy: https://github.com/Chronial/wsl-sudo. Using it, you can just run wudo vi /mnt/c/Users/a/admin/file.txt
. It behaves just like normal sudo, but gives you windows admin rights instead of unix admin rights.
If all you need is a shell with admin privileges, you can just run powershell.exe Start-Process -Verb runas -FilePath wsl
.
Is there a way to access Windows file with administrative rights using WSL?
Yes; All that is required in order to do so is to have elevated the command prompt that launched the WSL instance.
A Bash session with Windows admin privileges may access cd /mnt/c/Users/Administrator while a Bash session without admin privileges would see a "Permission Denied" error.
Microsoft describes the permissions within a WSL instance as the following:
Source: User Accounts and Permissions for Windows Subsystem for Linux