Saturday 8 October 2011

Learn 10 good UNIX usage habits

UNIX tips: Learn 10 good UNIX usage habits

Another excellent article from IBM Developer Works!

Creación de archivo parche localtime o ¿Qué hacer cuando al gobierno se le ocurre cambiar el cambio de hora?

Al revisar la configuración estándar de los archivos de hora local (en adelante /etc/localtime) se puede ver que a las 00:00 del 09 de septiembre se adelantará una hora, cambio que ya no es válido según las modificaciones de la autoridad oficial (en rojo):
[root@CentOS ~]# zdump -v /etc/localtime |grep 2011
/etc/localtime  Sun Mar 13 02:59:59 2011 UTC = Sat Mar 12 23:59:59 2011 CLST isdst=1 gmtoff=-10800
/etc/localtime  Sun Mar 13 03:00:00 2011 UTC = Sat Mar 12 23:00:00 2011 CLT isdst=0 gmtoff=-14400
/etc/localtime  Sun Oct  9 03:59:59 2011 UTC = Sat Oct  8 23:59:59 2011 CLT isdst=0 gmtoff=-14400
/etc/localtime  Sun Oct  9 04:00:00 2011 UTC = Sun Oct  9 01:00:00 2011 CLST isdst=1 gmtoff=-10800
Para evitar este cambio, es necesario crear un archivo /etc/localtime que no contenga el evento. Esto se debe hacer mediante el siguiente procedimiento:
Respaldo del archivo /etc/localtime actualmente en uso:
[root@CentOS etc]# cp /etc/localtime /etc/localtime.20111006.ffg.bak
Se debe observar que en algunos sistemas, /etc/localtime es un link simbólico hacia otra ruta en el disco. En estos casos, se debe respaldar el archivo destino del link.
Descargar una definición modificable del archivo tzdata desde http://www.iana.org/time-zones (data)
Una vez descargado el archivo, descomprimir y desempaquetar:
[root@CentOS ntp]# tar -zxvf tzdata2011k.tar.gz
Editamos el archivo southamerica:
[root@CentOS ntp]# vi southamerica
Dentro del archivo, buscamos en las reglas para Chile los eventos relativos a la fecha en cuestión:
# Rule  NAME    FROM    TO      TYPE    IN      ON      AT      SAVE    LETTER/S
Rule    Chile   2011    only    -       Aug     Sun>=16 4:00u   1:00    S
Rule    Chile   2012    max     -       Oct     Sun>=9  4:00u   1:00    S
Rule    Chile   2011    only    -       May     Sun>=2  3:00u   0       -
Rule    Chile   2012    max     -       Mar     Sun>=9  3:00u   0       -

Según el archivo sobre el que estamos trabajando, aparentemente el cambio de hora del 09 de octubre de 2011 ya no está considerado, por lo que procedemos a compilar el archivo usando zic:
[root@CentOS ntp]# zic southamerica
[root@CentOS ntp]# zic backward
El archivo southamerica contiene las reglas para crear el localtime, y el archivo backward la información relativa a los cambios de nombre de zona horaria en Linux/Unix.
Comprobamos que la compilación contenga solamente los eventos registrados para el año 2011:
[root@CentOS ntp]# zdump -v /usr/share/zoneinfo/Chile/Continental |grep 2011
/usr/share/zoneinfo/Chile/Continental  Sun May  8 02:59:59 2011 UTC = Sat May  7 23:59:59 2011 CLST isdst=1 gmtoff=-10800
/usr/share/zoneinfo/Chile/Continental  Sun May  8 03:00:00 2011 UTC = Sat May  7 23:00:00 2011 CLT isdst=0 gmtoff=-14400
/usr/share/zoneinfo/Chile/Continental  Sun Aug 21 03:59:59 2011 UTC = Sat Aug 20 23:59:59 2011 CLT isdst=0 gmtoff=-14400
/usr/share/zoneinfo/Chile/Continental  Sun Aug 21 04:00:00 2011 UTC = Sun Aug 21 01:00:00 2011 CLST isdst=1 gmtoff=-10800
Podemos ver que ya no existe ningún evento para lo que resta de 2011. Además revisamos los eventos para 2012:
[root@CentOS ntp]# zdump -v /usr/share/zoneinfo/Chile/Continental |grep 2012
/usr/share/zoneinfo/Chile/Continental  Sun Mar 11 02:59:59 2012 UTC = Sat Mar 10 23:59:59 2012 CLST isdst=1 gmtoff=-10800
/usr/share/zoneinfo/Chile/Continental  Sun Mar 11 03:00:00 2012 UTC = Sat Mar 10 23:00:00 2012 CLT isdst=0 gmtoff=-14400
/usr/share/zoneinfo/Chile/Continental  Sun Oct 14 03:59:59 2012 UTC = Sat Oct 13 23:59:59 2012 CLT isdst=0 gmtoff=-14400
/usr/share/zoneinfo/Chile/Continental  Sun Oct 14 04:00:00 2012 UTC = Sun Oct 14 01:00:00 2012 CLST isdst=1 gmtoff=-10800
Así, en este nuevo archivo localtime no aparece el evento del 09/10/2011 y se establece el siguiente evento para el 10 de marzo de 2012.

Monday 31 January 2011

Componentes para efectos en Chile

Si necesitas esa pieza en particular para ese efecto que estás trabajando y Casa Royal o San Diego no te lo dan, y no quieres pagar miles por un integrado a RS Chile, tu solución es Kowka.

La mejor experiencia de compra, pides online, pasas a retirar o te despachan, venden los mejores componentes.

Una tienda especializada en electrónica de efectos de guitarra.

Nada que hacer, Kowka la lleva.

www.kowka.cl

How to know the block size of a file system

dumpe2fs /dev/sda1 | grep "Block size"

The output is expresed in bytes:


dumpe2fs 1.39 (29-May-2006)
Block size:               4096

Thursday 20 January 2011

Use linux host as gateway

#Enable the ip forward
sysctl -w net.ipv4.ip_forward=1

#Let iptables do the magic :)
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Using the distro DVD as repo in Red Hat

Firt, mount the distro DVD or ISO.

Create a file /etc/yum.repos.d/dvd.repo.

Open the .discinfo in the root of the DVD or ISO and copy the code of the first line.

Open /etc/yum.repos.d/dvd.repo and fill it as follow:

[dvd]
mediaid=1170972069.396645*
name=DVD for RHEL5
baseurl=file:///path/to/media/Server
enabled=1
gpgcheck=0

Replace the mediaid value with the code copied from the .discinfo file.

Then, use yum with --noplugins

:)

Wednesday 19 January 2011

"Procrastination" Tales Of Mere Existence

Other nice and simple one-liner!

If you want to delete n days old files, you can use a one-liner like this:

find /directory -type f -mtime +n -exec rm -f {} \; 

Or -type d for deleting directories, etc.

Tuesday 18 January 2011

Simple FTP upload script

Using lftp (or other ftp cli client) yo can make a easy upload to a ftp server. Just create a text file with the ftp commands you want to execute, and use like this (using lftp) :

lftp  -uuser,pass  server < text_file_with_commands

Simple!