Cant save files

22 views
Skip to first unread message

Hans Iwan Bratt

unread,
Oct 7, 2019, 3:46:42 AM10/7/19
to ICEcoder
Suddenly it is not any longer possible to save files. I have not changed the permissions. The only thing, that might have something to do with the problem is that I have accessed the files from an another terminal. There is no problem to save files with the editor built in the server software.

Matt Pass

unread,
Oct 8, 2019, 4:36:29 AM10/8/19
to ICEcoder
It sounds like an ownership/group or permissions problem. ICEcoder is PHP based and it can only write files if it has the rights to.

That means it'd be blocking it, either because it's not got the right owner/group or not high enough permissions to write it.

A simple test to prove this is set permissions to 777 (read, write and execute available to anything), you'll now be able to save. However, setting it to 777 is seen as a security risk, so you'll want to maybe change the owner or group instead of raising permission levels.

Explanation you may know/not know: Every dir or file on Linux has an owner and group, eg root / root. It's likely that the user for your web server is www-admin or something similar. If the permissions on the file are say 644 for the file, PHP is going to be denied, as www-admin doesn't own the file (root does), doesn't belong in a group (it's in the root group) and it doesn't have permissions to write it. It fails on all 3 counts.

Changing the files ownership and group from root to whatever your web server is using, (eg www-admin) is the better way to go than raising permission levels.

Hope that all makes sense. Look into chown, chgrp and chmod to give PHP enough rights to write the dir/file. It'll write to that dir/file if it's able to. It's better to give it rights by setting a suitable owner & group though, than raise permission levels. :-)

Summary explanation (assuming www-admin is the user for your web server):

Example 1: file xyz.txt ; owner: root, group: root, permissions: 644 - denied writing as doesn't have rights to write
Example 2: file xyz.txt ; owner: root, group: root, permissions: 777 - allowed writing as while www-admin isn't the owner or group, the file has extremely high permissions allowing anything to write to it
Example 3: file xyz.txt ; owner: www-admin, group: www-admin, permissions: 644 - allowed writing, as www-admin both owns the file and is in it's group. The permissions are more secure at 644 too. This is the better solution.

Hope this helps!

Matt
Reply all
Reply to author
Forward
0 new messages