Hi,

I use Ubuntu8. I have a folder in /var/www/Project1. When i try to save a php file into /var/www/Project1/ it generates error(writing permition).
This is what i do but doesn't solve my problem:

root@ubuntu:/home/ubuntu# sudo useradd myuser
root@ubuntu:/home/ubuntu# sudo chown myuser /var/www/Project1/
OR
root@ubuntu:/home/ubuntu# sudo chown root /var/www/Project1/

What is missing?

Thanks

Dani AI

Generated

Short diagnostic summary and secure fixes for the “writing permission” error when saving into /var/www/Project1.

Common causes: the account doing the save isn’t the owner or in the directory’s group, a parent directory lacks the execute (traverse) bit, the filesystem is mounted read‑only, or an ACL/AppArmor rule blocks writes. OP tried changing ownership and some replies suggested making the tree world‑writable; that works but is a security risk (as and already noted).

Basic checks (run as a normal shell user to reproduce the problem context):

ls -ld /var/www/Project1
namei -l /var/www/Project1
id -nG $(whoami)
getfacl /var/www/Project1
mountpoint /var/www

What to look for: owner:group from ls; each path component’s perms from namei (every directory needs the execute bit for traversal); group membership from id; any ACL entries from getfacl; and whether /var is on a separate mount that might be read‑only.

Safer fixes (instead of 777): use group ownership or ACLs so only the webserver user/group and the trusted local user(s) get write access. On Ubuntu the webserver often runs as www‑data, so adding the editing account to that group and granting group write, or using POSIX ACLs to give www‑data (or a specific username) rwX on the Project1 tree, solves the problem while avoiding world‑writable permissions. If files are being written by PHP/Apache, ensure the server process user has write permission; if edits are from a desktop editor, use temporary elevation (for single edits) rather than a persistent root shell (see ’s note).

Quick checklist: confirm ownership and path perms, confirm groups, check ACLs, verify mount options (not ro), then apply group-based permissions or ACLs rather than broad 777.

Recommended Answers

All 11 Replies

If you're root, you won't need sudo. If under root you get permission errors, then you have some other issues. Perhaps check how your filesystem(s) are mounted.

Ho do we check "filesystem(s) are mounted" ?

Run mount with no arguments.

-> Alt F2
-> gksu nautilus /directory
->paste there

u can try by changing the permissions

$ su
# cd /var
# chmod 777 www

then anyone can read/write from this folder

Isn't it (chmod 777) security hole, if i have more than 1 user?

OK... it is somewhat a security expose :P .As i use my pc 4 myself i was not concerned about it. But if you want to use it only for yourself then i guess u have to change the owner to yourself. then

chmod 744

should do it.

it's very simple
whenever you are trying to access /var/www, using "cd /var/www"

what you should do...
1)open terminal
2)type "sudo bash"
3)it will ask you for your user account password, fill the password
4) now do "cd /var/www"

This way you have full write access

now do whatever you want to do via terminal

Few things I want to know whether you are trying to write to that folder by your application i.e; Apache/php or simply by terminal using root user?

--
Manoj

If you're root, you won't need sudo. If under root you get permission errors, then you have some other issues. Perhaps check how your filesystem(s) are mounted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.