loading...

Discussion on: Visual Studio Code always ask for permission to save files in Linux

Collapse
yzhernand profile image
Yozen Hernandez

I see. Well in that case I think that the problem that you and the questioner on SO have is that you're trying to fight the way the system works a bit. Directories outside of your home have permissions set the way they are for a reason.

I probably don't have to explain it to you, but for others who find this: there are potential security issues with, for example, giving some directory or file full user/group/other permissions (777) because that could grant far more access to a service than it might need (and if there's the potential for executing malicious code, it might be able to do serious damage). If you're running or developing some service, you might want to isolate the sort of damage it might do by creating a new user just for that service, and the directory with all of its files will be owned by that user.

In fact, the answer I like best on that post is this one: stackoverflow.com/a/61939446/876844. In that answer, the solution is simply to add your own user to a group which already has access to the directory. So, if the directory in question had read/write access for the www-data group (common for most web services), just add your user to that group, log out/log in, and work as usual.

In the past I've used a few other alternatives, including using a symbolic link in the outside directory which pointed to the project directory in my home dir, or a slightly more complicated setup where I used git on both sides. In the latter case, I would develop on a local directory, test things as needed, and then commit. When I had something that I felt could go out to the privileged directory, I would switch to a user that had write access there and do a git pull.

I'm not saying either solution is perfect (and maybe other users have better suggestions), but neither of these involve messing with the permissions in a directory like /opt or /var/www in a potentially dangerous manner.

Edit: formatting, spelling.

Thread Thread
rahedmir profile image
Mir Rahed Uddin Author

Well, this is also a helpful explanation indeed. Thank you