Tuesday 13 August 2013

Cross check between two files

#!/bin/bash

largo=`wc -l ip|awk '{print $1}'`
echo "Direccion IP |        Dueno">salida.txt
echo "--------------------------------">>salida.txt
for ((i=1;i<=largo;i++))
    do
        ip=$(sed -n ""$i"p" ip|awk '{print $1}')
        owner=`whois $ip|grep owner:`
        dueno=${owner#*owner:}
        echo "$ip | $dueno" >> salida.txt
    done
more salida.txt

Monday 12 August 2013

Read a file line by line and separating from fields

#!/bin/bash

largo=`wc -l ip|awk '{print $1}'`
echo "Direccion IP |        Dueno">salida.txt
echo "--------------------------------">>salida.txt
for ((i=1;i<=largo;i++))
    do
        ip=$(sed -n ""$i"p" ip|awk '{print $1}')
        owner=`whois $ip|grep owner:`
        dueno=${owner#*owner:}
        echo "$ip | $dueno" >> salida.txt
    done
more salida.txt

Friday 12 July 2013

tar and ssh

 tar czf - /path| ssh joebloggs@otherserver.com tar xzf - -C/path

Thursday 25 April 2013

Force shutdown of a Linux server

This could be useful when you really need to shutdown... some kind of a "Vulcan Key" to the kernel :)

#echo 1 > /proc/sys/kernel/sysrq
#echo o > /proc/sysrq-trigger

Monday 4 February 2013

Who's using my port? (AIX)

Sometimes is very useful know what process is using a specific port. In AIX, the netstat command show you this info using the following parameters:

netstat -Aan

So, you must use grep to filter the port you are looking for.

The first column shows a hexadecimal number. Using the rmsock command with the following parameters to see the PID:

rmsock (hexnumber) tcpcb

or udpcb

:)

Wednesday 30 January 2013

Red Hat remote install through VNC

boot: linux vnc vncpassword=qwerty ip=xxx.xxx.xxx.xxx netmask=xxx.xxx.xxx.xxx gateway=xxx.xxx.xxx.xxx dns=xxx.xxx.xxx.xxx ksdevice=ethx