VSCode in WSL: how to sudo a root file so I can edit it

后端 未结 5 1217
逝去的感伤
逝去的感伤 2021-02-12 13:21

WSL v.1 -- VSCode v1.40.1 (using \'Remote - WSL\' extension 40.3)

How to open a root-owned file for edit using sudo and VSCode? (without running as root)

5条回答
  •  清歌不尽
    2021-02-12 13:50

    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
    
    

提交回复
热议问题