[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: how to i return a filesize to "0"....?



> Assuming you want to make file "/var/log/X" zero length you'd do (as root,
> or somebody with write permission for this file):
>
> rm /var/log/X
> touch /var/log/X
>

Don't do this.  This can lead to SERIOUS security problems.  When you
"touch" a file an empty plain file is created, yes.  However, it is created
with the default permissions specified by your umask and group.  If you
forget to chmod/chown/chgrp the file/directory you could possibly create a
security hole.

Try:

cat /dev/null > /path/to/my/file

The file ownership and permissions should remain correct.



Mario Paz  -  Paranoid and loving it!  ;)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]