Network

Sort IP address

Sorting IP addresses using sort is not easy because the dot confuses sort. This line makes it possible to sort by the whole value of the address sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 ipaddresses.txt You can also sort by the last octet sort -r. -n +3.0 ipaddresses.txt

Read More
Web

Shortening Apache Configs using mod_macro

It is possible to use macros in the Apache config files to shorten them and make them easier to read and manage. To use this you have to install mod_macro if it’s not already installed in your distribution. Sample mod_macro usage <Macro VHost $customer $domain> <VirtualHost $domain:80> ServerName $domain ServerAlias www.$domain DocumentRoot /vaw/www/$customer/htdocs/$domain/ ScriptAlias /cgi-bin/ […]

Read More
Linux

Debian daemon control

In RedHat distributions like RHEL, Fedora and also CentOS you have a tool called ntsysv to manage daemons and their runlevels. In Debian there is an alternative tool that lets you determine what daemon you want to run using a text GUI sysv-rc-conf It makes it easy to manage which daemons you would like to […]

Read More
Scripting

Grep recursively through subdirectories

grep recursively through subdirectories for files that match a specific pattern: grep -l -r –include=*.doc regex * The equivalent command unsing find: find . -name ‘*.doc’ -exec grep -l regex \{\} \; The option after grep is the lowercase letter L, not the number 1). Remove the -l to see the actual matches instead of […]

Read More