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)
If I open a root file without sudo
, I can't edit it (expected):
$ code /etc/profile.d/custom-profile.sh
$
But, if I try to sudo code
the file, I get:
$ sudo code /etc/profile.d/custom-profile.sh
[sudo] password for xxxx:
sudo: code: command not found
Binarify's answer below shows that I can switch the default user to root
, but I definitely don't want to be running as root, so I'm still looking for another solution.
sudo code
does runcode
asroot
, which seems both clumsy and dangerous. – Window