Ubuntu – Can’t do Chmod on Apache error logs in Ubuntu

apache-2.2chmodlog-filesloggingUbuntu

I am trying to clear the logs and I do not have permission since the file permissions on Apache error logs are like this:
-rw-r—–

When I tried to do something like
chmod 777 error.log

I got this error:
chmod: changing permissions of `error.log.1': Operation not permitted

Any idea how to change my permissions to allow myself to clear out my logs and delete the old error log files?

Thanks,
Alex

Best Answer

You can change the permission of the file if you use sudo to preface the command:

sudo chmod 777 /var/log/error.log

You will need to add yourself to the sudoers file as the root user:

visudo

Alternatively you could create a logs group and add yourself to the group then change the group ownership of all your log files to the logs group.

Related Topic