I am trying to save a .php file to /var/www/html/mysql using VS Code on Fedora 27 but I get an message saying
Also if I try to open VS Code as root I get the following message:
I am trying to save a .php file to /var/www/html/mysql using VS Code on Fedora 27 but I get an message saying
Also if I try to open VS Code as root I get the following message:
You can run Visual Studio Code as root
sudo code /directory-to-open --user-data-dir='/var/www/html/' --no-sandbox
Or
sudo code --user-data-dir="~/.vscode-root"
Running Visual Studio Code as root is not recommended, as it can be dangerous and compromise your system’s security.
Another way
you can change the permissions of /var/www/html/ to allow your regular user to save files there. so you can run VSCode as a normal user and make changes to the file without any problem.
command change the owner of the folder to your user:
sudo chown -R $USER:$USER /var/www/html/
Or
to change the permissions of the folder to allow read and write access for your user:
sudo chmod -R u+rw /var/www/html/
Even though the accepted answer actually works, I don't recommend to change access rights when using LINUX. Your "web" folder is usually owned by web server's user and group, therefore, it's a good practice to keep the same in your DEV (local) environment (i.e. your PC). It is OK to execute your IDE as sudo if you need to, as long as you handle it locally and keep the same access rights as in QA and PRODUCTION environments.
You need to change access rights to the folder. There are 2 options.