I am using visual studio code with this command in ubuntu linux Running VS Code with the root privileges (not recommended)
sudo code --user-data-dir="~/.vscode-root"
I always use this in command line because normal way visual studio code does not allow me to save my code updates. but today
sudo code --user-data-dir="~/.vscode-root"
this code does not work anymore when i try to run it in command line, it does not open visual studio code anymore. Giving click in vscode icon run normally but it does not allow me to save anything, it asked me retry as sudo, i do and it does not do nothing, i can not enter as sudo in this way. any suggestions on how to solve this issue? Thanks in advance
best way (recommended):
just use this :
sudo code "your-directory" --user-data-dir='.' --no-sandbox
for example to open /etc/nginx/nginx.conf
, use:
sudo code /etc/nginx/nginx.conf --user-data-dir='.' --no-sandbox
vscode will create files where you open terminal because of :
--user-data-dir='.'
another way (not recommended):
use sudo chmod -R 777
But it will give the full access of your project directory to all users on the machine
You can use chown on the project directory to own it only for yourself
cd /location
sudo chown your_username your_project_directory
Example:
let's say I have a directory called project1
in my /var/opt
location and my user name is tom.
cd /var/opt
sudo chown tom project1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With