How to change timezone in Ubuntu / Debian from command-line

This guide assumes that you use Ubuntu or Debian-based GNU/Linux distro. There are two ways to change timezone from bash command line.

sudo dpkg-reconfigure tzdata

or,

sudo ln -sf /usr/share/zoneinfo/Asia/Kuala_Lumpur /etc/localtime

You can also specify other timezone in the second method, for example:

sudo ln -sf /usr/share/zoneinfo/GMT /etc/localtime

or for Eastern Standard Time (US)

sudo ln -sf /usr/share/zoneinfo/EST /etc/localtime

This command is handy when administrating multiple servers across different continents.

IPdeny.com – Download collections of Country IP Addresses

IPdeny.com is a service which offers a free collection of Regional and Country IP address blocks list.

ipdeny

The IP address blocks is useful for application developer and system administrator to enhance their system. For example, application developer can use the information redirect users from certain countries to regional websites or pages, or a system administrator can use the IP address information to isolate users from different countries.

Stop Comment spams with IP Blacklist Cloud

Comment spams is the bane of any website operator that rely on real human interaction. Stopping comment spams by hand is a tedious process especially when comment spam attacks are sophisticated and are launched from Botnet. There are several techniques that can be employed to fight comment spams including behavioral analysis and also IP analysis.

In maintaining WordPress and Joomla sites, I myself has analyzed several web logfiles and Cloudflare logs to learn that most comment spam originated from certain ip blocks and countries. Therefore, I decided to completely deny access from those affected ip block through firewall (which keep the comment spam low and saves web server resources!)

ipblc_server

However, recently I found a new service IP Blacklist Cloud which list the top most blacklisted ip address through collaborative effort. Normally I find blacklisting by ip address is tedious and probably harmful to legitimate visitors, however after conforming the ip addresses that I found inside my spam logs, I decided the list is legitimate and decided to firewall-block some of the worst offenders in the list.

IP Blacklist Cloud free WordPress plugins, which I personally does not use due to my policy of keeping my installation lean with minimal (to no plugins!), however I see that there’s no harm giving a shot!

Debian: Force users to use more secure login password with pam_cracklib

One of the factor that makes your system easily crackable is the weak password. PAM cracklib forces users to choose stronger password by analyzing the password strength, length and entropy.

To enable pam_cracklib in Debian / Ubuntu operating system, you need to install libpam_cracklib:

sudo apt-get install libpam_cracklib

Then edit the “/etc/pam.d/common-password” file using your favorite editor. Then, add and uncomment the following line at the end of the file.

password required pam_cracklib.so retry=3 minlen=6 difok=3

difok determines the number of same characters that allowed to be present in the old and new passwords.

How to find fastest Debian apt-get mirrors with netselect-apt

Using the nearest server to your location does not guarantee that you will get faster connection speed, other factors such as network congestions, faulty routers and bandwidth may affect the speed of your software installations.

Thus it is best to update the sources.lst file from time to time to keep updated with the fastest mirror to you, to ensure faster software installation and updates on your computer.

Generally there are two ways to do this, one is by using Synaptic to check for the fastest mirror (works for Ubuntu too!) and secondly by using netselect-apt (currently does not work for Ubuntu).

How to get fastest apt-get mirror with netselect-apt (Debian)

Firstly you need to install netselect-apt. then just run the command by typing “netselect-apt distribution name” to get the fastest mirror. Append -n switch, if you want to include the non-free repository too

Example :
# netselect-apt lenny

Example (non-free repos) :
# netselect-apt -n lenny

The application will test each apt-get mirrors it could find on debian.org site and perform some connection to estimate its speed. At the end of the test, the fastest mirror will be selected and used in the /etc/apt/sources.lst file.

Nice, but does it work on Ubuntu?
Note that although Ubuntu has netselect-apt, the application is currently broken under Ubuntu
( as of Gutsy Gibbon ). Ubuntu users should try the Synaptic method instead.