Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a file /var/logs/apache2/error.log. And every time I boot, Its file permission is changed to default (unwritable) by the system. So, i have to run chmod command every time i boot-up. How to change it's file permission permanently.

share|improve this question
1  
Question - why? What is it you are trying to do that requires write access? Normal logging processes are generally recommended. –  Rory Alsop Mar 30 '11 at 12:10
    
@RoryAlsop to debug ajax, i need to check into error.log. And this is so full of logs. I normally delete it, and look for changes. But due to it's permission, is not editable. –  Santosh Linkha Mar 30 '11 at 12:15
    
@explorex - good range of tools allow you to manage logs without deleting. I always use a combination of grep and tail, which makes life very easy. –  Rory Alsop Mar 30 '11 at 12:22
    
@RoryAlsop is grep and tail programs or soft packages? –  Santosh Linkha Mar 30 '11 at 12:27
1  
@explorex - both part of unix/linux. Tail lets you look at the last lines of a file (unixhelp.ed.ac.uk/CGI/man-cgi?tail) and grep lets you search through a file for instances you want to find (unixhelp.ed.ac.uk/CGI/man-cgi?grep). Well worth understanding the power of grep - invaluable! –  Rory Alsop Mar 30 '11 at 12:32
show 1 more comment

3 Answers

up vote 3 down vote accepted

As per the discussion in comments, for the purpose the OP is trying to achieve (looking at a simple subset of logs for a specific purpose), this may be an appropriate alternative solution:

Tail will let you look at the last lines of a file

Grep lets you search through a file for instances you want to find

Both are available as part of Unix/Linux and should be part of your essential toolkit.

share|improve this answer
    
please i'll take a little time to accept answer. –  Santosh Linkha Mar 30 '11 at 12:45
add comment

I'm guessing anacron is running logrotate at boot time.

If so, try editing the configuration file /etc/logrotate.d/apache2, and change

create 640 root adm

to whatever you prefer, e.g.

create 666 root adm

But other than the apache2 service, what else needs to write to this file?

If this is on a server, it's probably a bad idea to make the file world writable. For example, if somebody breaks in to your system, they can remove the log entries that would help you find the problem.

If you want read access, it might be better to add yourself to the adm group, e.g.

gpasswd -a `whoami` adm

This would also help if you really do need write access, e.g.

create 660 root adm

would be sufficient.

share|improve this answer
    
The usual reason is letting some customers or some software (traffic analysis, monitoring) access to the logs without granting it extra privileges that could be a security risk. –  Javier Rivera Mar 30 '11 at 10:48
    
Read access, probably OK. But the poster said write access was required too. –  Mikel Mar 30 '11 at 10:51
    
Ouch, now I'm wondering too... –  Javier Rivera Mar 30 '11 at 12:03
add comment

Log files are usually created by logrotate. The apache logfiles definition is stored on /etc/logrotate.d/apache2

The file looks like this in one of my servers:

/var/log/apache2/*.log {
        weekly
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
                        /etc/init.d/apache2 reload > /dev/null
                fi
        endscript
}

If you look at the create option, the values after the keyword are the permissions, user and group. Just edit your file and change this values.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.