VSCode in WSL: how to sudo a root file so I can edit it
You can own the file you want to edit, then give it back the ownership afterwards sudo chown myuser /path/to/file code /path/to/file sudo chown root /path/to/file
You can own the file you want to edit, then give it back the ownership afterwards sudo chown myuser /path/to/file code /path/to/file sudo chown root /path/to/file
You can reload the window. It keeps unsaved changes even. Press F1 to search for commands, then search for: Developer: Reload Window Version of VSCode when trying this: 1.53.2.
When you connect to a host it executes a bash script that wgets or curls a tarball and extracts it in a directory in your home directory. Here’s an offline workaround. Attempt to connect, let it fail On server, get the commit id $ ls ~/.vscode-server/bin 553cfb2c2205db5f15f3ee8395bbd5cf066d357d Download tarball replacing $COMMIT_ID with the the commit … Read more
I recommend this VSCode extension: Save as Root in Remote SSH Install the extension on a window opened with Remote-SSH and use “Save as Root” in the command palette instead of Ctrl+S. Basically, it reads the contents of the editor and calls the sudo command to overwrite the file.
Add the absolute file path to a custom SSH config file(C:\Users\{USERNAME}\.ssh\config), and my problem is solved.