P
P
PendalF892021-08-25 23:55:13
linux
PendalF89, 2021-08-25 23:55:13

File permissions in WSL2?

Hello!
Tell me how best to set up access rights in the following case: there is WSL2 with a configured environment for web development, sometimes files on WSL2 need access from Windows, for example, to edit hosts in Nginx. But you can’t just edit them from the explorer if WSL2 is not running as root. So far I have solved the problem like this: I run WSL2 as root, and I give the necessary project files permissions 777 (so that nginx can access them). I understand that this is not entirely correct, maybe there is a better way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2021-08-26
@bingo347

periodically, files on WSL2 need access from Windows, for example, to edit hosts in Nginx
what was wrong with nano or vim for these purposes? On the edge, you can put on the Windows X server and run any Linux gui editor in wsl with the DISPLAY variable.
If 10 bucks for x410 is expensive for you, there is a free X server , although you will have to get a little confused with it.
Well, another option is to wait for WSLg support or install an insider build or Win11 beta, where it already exists.
But for most tasks like editing the config - nano is more than enough, and if you figure it out with vim, then you definitely don’t want to edit something with a notepad
PS VSCode with the remote WSL plugin can work from Windows inside WSL

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question