How to open Visual Studio Code with admin privileges to make effect of the installed extensions
To run with superuser:
$ sudo code --user-data-dir=~/root
By the way you will be able to run without setting params in the upcoming patch 1.5.0.
You can press Shift+Cmd+P in visual studio code and type:
shell command
and press "install" in the PATH
.
Then in your terminal go to the folder that you want to open and type "code ." It'll open the project in visual studio code as root.
You can achieve this in either of following ways :
- Run vscode as superuser:
$ sudo code --user-data-dir=~/root
This will open vscode without your previous settings (fresh) with superuser privileges and you can install your extensions.
OR
- Follow these steps :
sudo chown -R <user> <path_to_your_vscode_installation_directory>
- Hit follwing in terminal
to check the current user on your machine :whoami
for e.g. john - You can find path of vscode directory using following command :
whereis code
e.g. in my case path is : /usr/share/code - Now run :
sudo chown -R john /usr/share/code
This will run vscode with admin privilege - Now install your extensions
- After reset owner back to root
sudo chown -R root /usr/share/code