User Home dir permission?


how can I avoid that the user can delete his /log /stat … dir in his home folder. They should belong to root, but in my case the owner of them is the user. The same problem in the File Browser. I think the user can delete every directory in his home dir.

EDIT: I forgot to say that I found a solution for FTP, but not for the FileManager. In FTP the top dir is set to public_html so I cant browse outside this directory, but in the FileManager it is still “home/ftpuser/”.


the folders belong to the user (not root) and he is able to delete them.
to avoid that you can run the cmd “chttr +1” on the folders and files. Then not even root can delete the files and folders until you did a chttr -1.

however if you want to prevent the user from deleting these folders so your Apache won’t crash, there is a better way.
In the server template set the following:
Virtualmin - system settings - Server templates - click your template and go to Apache website, then Write logs via program?
(Handles missing log directory) set it to yes.

As an aside, sometime in the Virtualmin 3.6x series I believe it is – the default for creating logs changed.

By default, they now go into /var/log/virtualmin/ (which is owned by root) – and all the $HOME/logs/ dir does is symlink to the various logfiles owned by the user.

So for all semi-new installations, the “Write logs” feature shouldn’t be needed any longer.


Odd as this is not so on my centos system with 3.70 pro, I don’t even have a /var/log/virtualmin. Although it is so on my other server running GPL though…


Well, it would only be the case for a new install; so if you installed awhile ago (you’ve been using Virtualmin forever!), that wouldn’t have changed.

Have a good one!


Ok, logfiles still work even I delete the logs foldr in $HOME, but when I delete the awstats folder I get a error message when viewing AWstats report.

Error: AWStats database directory defined in config file by ‘DirData’ parameter (/home/ftpemscuola/awstats) does not exist or is not writable.

Setup (’/etc/awstats/’ file, web server or permissions) may be wrong.
Check config file, permissions and AWStats documentation (in ‘docs’ directory).

Well, I usually tell hosting customers that if they delete the stats dir, it prevents the stats from working :slight_smile: However, as you may have discovered, that doesn’t always stop them from deleting it…

So, you could try Ronald’s suggestion above, where he offered changing the “chattr” attributes on the directory.

You could also put a root-owned file in the directory, named something like “.nodelete”. That won’t prevent them from deleting the current stats, but it will prevent them from accidentally deleting the folder.


the chttr +1 can also be done with the filemanager as root.
It is the button with the hammer and the option is, do not allow modification

alternatively you can create an with the following in it:
cd /home ; find -type f -name php.ini -maxdepth 4 | awk {‘print "chattr +i "$1’} |sh
cd /home ; find -type d -name etc -maxdepth 2 | awk {‘print "chattr +i "$1’} |sh

replace php.ini and folder etc to what you want.
create with the code but then chttr -1 to undo

you can make the file run as a “command to run after creation of virtual server”