1819882 Members
2629 Online
109607 Solutions
New Discussion юеВ

log file permissions

 
SOLVED
Go to solution
Shivkumar
Super Advisor

log file permissions

I have some log files generated in a directory. Right now their permissions are 600. I want to change the permission to 644. Will the new log file generated have the permissions 644 or 600 after change ?

Thanks,
Shiv

23 REPLIES 23
Pete Randall
Outstanding Contributor
Solution

Re: log file permissions

If you mean that the files are removed and re-created, then no, the permissions you set on them now will have no effect on the new files. If the files do not go away, the process of adding to them will not affect the permissions you set now.


Pete

Pete
James R. Ferguson
Acclaimed Contributor

Re: log file permissions

Hi Shiv:

You can always set the 'umask' of the process creating the files to 022 to yield files with an octal permission of 644. See the manpages for 'umask' for more information.

Regards!

...JRF...
Vibhor Kumar Agarwal
Esteemed Contributor

Re: log file permissions

Have a look at umask
Vibhor Kumar Agarwal
Raj D.
Honored Contributor

Re: log file permissions

Default umask is 022 , and if its set the new file will be created with permission
Files with = -rw-r--r-- , i.e 644.

Directories = drwxr-xr-x , i.e 755.

------
you have to make minus , to umask value, to get to know what will be the generated permission :
1) For file : 666-umask value.
2) For Dir : 777-umask value.


---
You can change the umask accordingly to change the default file creation permission.

Cheers,
Raj.

" If u think u can , If u think u cannot , - You are always Right . "
Shivkumar
Super Advisor

Re: log file permissions

Dear Sirs,

I think if i change new value to umask 022 it might change all new file generation with defualt permissions 644.
I have seen some file permissions in system related directories where file permision has been set to 600 and don't want to change them.

Actually, i just want to set the value so that the new log file generated has permission 644 in the apache log directory only.

Appreciate any suggestion.

Thanks,
Shiv
Raj D.
Honored Contributor

Re: log file permissions

Hi Shiv ,

It seems that the logfile permissions set to 600 , and if you want to set it 644 for the newly generated logfiles you have to change the umask.

1. Check which usre resposible for generating those logfiles.
2. Check the user profile

3. Check the current umask .
# umask
4. To set the umask (022) need to midify the profile and you can set.
# vi .profile
umask 022 [ edit the existing entry ]
save & exit.

Please let us know further,

Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Alessandro Pilati
Esteemed Contributor

Re: log file permissions

I would put this command in a cronjob of root that runs every minute:

chmod 644 //*.log

or set a 022 umask for the apache logger user.
if you don't try, you'll never know if you are able to
Shivkumar
Super Advisor

Re: log file permissions

Raj,

The apache log files are generated by the root user. Instead of changing .profile of root, can i use umask 022 from command line ?

I am not pure sys admin on these boxes but web server admin.

My concern is if i change .profile of root user that might be concern to sys admin team.

Thanks,
Shiv
Tvs
Regular Advisor

Re: log file permissions

Hi

If you want to change the permission of a file you can use chmod command. it will not effect the old file permission and the new file permission you are going to create .if you want to change it permanent you can use umask ( and normally umask is different for root user (022 ) and the normal user (022).

You can set the umask for each user by editing there .profile
Raj D.
Honored Contributor

Re: log file permissions

Shiv ,

Both way it will change the entire umask to 022 , either you put in .profile of root , or you run through command.

If you want to change the specific log files permissions , you can put a command in cron as mentioned Pilati, that will make the job easier.

You can give 2min , 5min or 10 min interval as you wish. And it will not interact with other files and dirctories . So it will be safe.

Hope this will help ,

Cheers,
Raj.


" If u think u can , If u think u cannot , - You are always Right . "
Alessandro Pilati
Esteemed Contributor

Re: log file permissions

Shiv,
putting that instruction in the cronjobs is not system-performance-lowering, and it's the only way to have a permission control about single files within the same creator (root in your case)...

Regards,
Alex
if you don't try, you'll never know if you are able to
Raj D.
Honored Contributor

Re: log file permissions

Hi Shiv ,

Please letus know, if you need any help regarding crontab .

It seems you wanted the logs to be read by everyone as permission 600 will not allow that , 644 will allow.
And hope you can do that successfully,

Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Alessandro Pilati
Esteemed Contributor

Re: log file permissions

If can be helpful for you,
to add the entry in the crontab of root follow these steps:

as root, run:
crontab -e
then add the following row:
* * * * * chmod 644 //*.log
then save the crontab file as in vi (digit ESC and then :wq! )

Wait the next minute and you'll have your log permissions as you wanted.

Regards,
Alex
if you don't try, you'll never know if you are able to
Shivkumar
Super Advisor

Re: log file permissions

Alessandro Pilati; The script doesn't show any time ?
Raj D.
Honored Contributor

Re: log file permissions

Hi Shiv ,

You can do like that :

1.
#crontab -e

add

10,20,30,40,50,59 * * * * chmod 644 //*.log


cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Shivkumar
Super Advisor

Re: log file permissions

Will it work if i give the command in log directory: $chmod -R 644 access_log*
Alessandro Pilati
Esteemed Contributor

Re: log file permissions

Shiv,
the entry "* * * * * ..." in crontab means that the script will be executed every minute of every hour of every day of every month...

regards,
Alex
if you don't try, you'll never know if you are able to
Alessandro Pilati
Esteemed Contributor

Re: log file permissions

Shiv,
yes, it will work, but if more logs will be created in that directory, you will have to run that command again...

good luck
Alex
if you don't try, you'll never know if you are able to
Vibhor Kumar Agarwal
Esteemed Contributor

Re: log file permissions

-R is for recursive

So instead of
$chmod -R 644 access_log*

Better give
chmod -R 644 log_dir/
Vibhor Kumar Agarwal
Shivkumar
Super Advisor

Re: log file permissions

If i change the umask value as "umask 022" as a root user or in the .profile of root user; i understand it would generate files with the permissions 644 for those processes which are being run as a root user.

Please suggest if i understood correctly.

Thanks,
Shiv
Alessandro Pilati
Esteemed Contributor

Re: log file permissions

Shiv,
Yes you are right...

Think about cronjob solution maybe the nearest to your needs.

Regards,
Alex
if you don't try, you'll never know if you are able to
Arunvijai_4
Honored Contributor

Re: log file permissions

chmod -R 644 is a good option to consider. .

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Yogeeraj_1
Honored Contributor

Re: log file permissions

hi,

note that you can also display the current file mode creation mask value by issuing the command commands:
umask -S

also, if you want it for all the users, you can add the command to /etc/profile

regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)