Hi,
I cant save any php file into www. Gives permission error in text editor. But, i can save with using sudo nano ..... in terminal. In the properties of www directory, it permites only root.
How do i solve this problem?
Thanks
Hi,
I cant save any php file into www. Gives permission error in text editor. But, i can save with using sudo nano ..... in terminal. In the properties of www directory, it permites only root.
How do i solve this problem?
Thanks
Short explanation and safer fixes (builds on and )
The editor error happens because the web folder is owned by root and the directory bits only let the owner write; opening files with elevated privileges (the sudo nano approach you used) works because it runs as root. The “command not found” message was caused by typing the command name with the wrong case (Linux is case‑sensitive), as noted.
Prefer group or ACL-based access over making the directory world‑writable. Two practical, commonly used options:
ls -ld /var/www
sudo chgrp -R www-data /var/www
sudo usermod -aG www-data veledrom A re-login is required for the new group membership to take effect.
sudo setfacl -R -m u:veledrom:rwx /var/www
sudo setfacl -R -d -m u:veledrom:rwx /var/www
getfacl /var/www Notes and cautions (echoing ): do not use global world‑write (777/757) for /var/www unless on a tightly isolated throwaway machine. World‑writable lets any local account — and any vulnerable web script running as the web server — write into the tree. Limit write permission only to the folders that actually need it (uploads, cache, similar) and prefer group/ACL approaches for development.
Jump to Post— jbennet 1,618have you got a gui or not?
Jump to Post— stephen84s 550Hi,
I cant save any php file into www. Gives permission error in text editor. But, i can save with using sudo nano ..... in terminal. In the properties of www directory, it permites only root.
How do i solve this problem?Thanks
Thats because of the file permission system …
Jump to Post— jbennet 1,618use a small C, linux is case sensitive
have you got a gui or not?
Hi,
I cant save any php file into www. Gives permission error in text editor. But, i can save with using sudo nano ..... in terminal. In the properties of www directory, it permites only root.
How do i solve this problem?Thanks
Thats because of the file permission system of Linux. It allows only root to write to the www folder because most probably the owner of that directory is root and the permissions for that folder will be 755.
To just allow your user to write to that folder you could do : -
chown command.chmod command. But this would be a security hazard since anyone and everyone will then be allowed to write to that folder. And if you wish to know how to use the commands theres always the man <command-name> or info <command-name> to assist.
To get a more in depth understanding of Linux file permissions you can go here.
When you say "But this would be a security hazard since anyone and everyone will then be allowed to write to that folder.
", do you mean anyone on the Internet because, i am using this at home and only access to the Internet.
Also when i do
Chmod 757 /var/www/ it generates an error which says "bash : Chmod command not found". i am in terminal.
use a small C, linux is case sensitive
When you say "But this would be a security hazard since anyone and everyone will then be allowed to write to that folder.
", do you mean anyone on the Internet because, i am using this at home and only access to the Internet.Also when i do
Chmod 757 /var/www/it generates an error which says "bash : Chmod command not found". i am in terminal.
Well all you had to do was just copy paste the command from my post. But I still suggest rather than changing the permission to 757, you change the owner of the folder "www" to the one you are using.
If you are just using it at home then I guess it wouldn't be too much of a problem (as long as you do not have a static IP address), but according to me its always best to follow the safer practice everywhere especially if it doesn't take too much effort from your side.
Ok. In the properties of www directory, it permites only root and it is not enabled. Also, there is not other option to let me add my user. How do i do it?
use chmod
Ok. In the properties of www directory, it permites only root and it is not enabled. Also, there is not other option to let me add my user. How do i do it?
you need to run the chmod command or the chown as root, or using sudo whichever is more viable option for you. Also needless to say, it has to be done in the terminal and cannot be modified via the GUI. (Unless your distribution permits the root user to login via the GUI)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.