General Tips, for Linux
DeveloperSide.NET Articles
Manually rotate Apache2 logs
...]# mv access_log access_log.old...]# mv error_log error_log.old...]# apachectl graceful
Automatically rotate Apache2 logs, with cronolog
Cronolog is a simple filter program that uses a file template and the current date/time to rotate log files. The benefit of cronolog, over Apache's rotatelogs, is in cronolog's dynamic nature. Files are rotated when "%x" variables change. With rotatelogs, files are rotated with a previously specified time period. Also, with cronolog, you can specify a directory structure, such as %y/%m/%d, which will store access_log under the year/month/day hierarchy.
- Rotate access_log every midnight, producing access_log.day|month|year
- Edit /usr/local/apache2/conf/httpd.conf, replacing CustomLog/TransferLog for access_log with...
CustomLog "|/usr/local/sbin/cronolog /usr/local/apache2/logs/access_log.%d%m%y" combined
- Edit /usr/local/apache2/conf/httpd.conf, replacing CustomLog/TransferLog for access_log with...
Filter error_log of favicon.ico requests (can account for 99% of the log, hiding important msgs)
...]grep -v '.ico' error_log | less
Resolve IP to HOST under Apache2 logs
...]# logresolve -s stats_new -c <access_log> access_log.new
[use <> around access_log]- -s : specifies a filename to record statistics to
- -c : apply DNS checks
- After resolving IP to hostname, logresolve will lookup the IP address of the hostname and check that one of the resulting IP addresses matches the original IP address.
Search file for a string
...]# grep -i 'string-to-search-for' file
[-i: case insensitive]
[use '-v' to invert match]
Test the speed of your connection
Download a file from a backbone of the Internet
...]# wget ftp://ftp.uu.net/uumap.tar.Z
Test your hard drive performance
...]# hdparm -Tt /dev/hda
IP/HOST and DNS info
...]# dig www.msn.com
[DNS and IP info]...]# host www.msn.com...]# host 207.68.171.244...]# resolveip www.msn.com...]# resolveip 207.68.171.244...]# whois www.msn.com
[Registrar info]...]# traceroute www.msn.com...]# traceroute 207.68.171.244
[Trace the path of the packet from source to destination]
Un-Compressing
- .tar.gz, .tgz, .gz
tar -xzf pkg
- .tar.bz2, .bz2
tar -xjf pkg
- tar -options
- x: extract
- z: gunzip format
- j: bzip2 format
- f: file name
Compressing
- .tar.bz2
tar -cvjf pkg.tar.bz2 pkg
- tar -options
- c: compress
- v: verbose
- j: bzip2 format
- f: file name