Sunday, August 21, 2011

How to modify IP, default gateway in Linux

Use Ifconfig, specifiy the network card to be modify and the values, it should be effective after the command:
  
# ifconfig eth0 192.168.0.20 netmask 255.255.255.0

One can also modify it at the file which specifies the network setting, this method requires a restart of the :

#vi /etc/sysconfig/network-scripts/ifcfg-eth0
          
            DEVICE=eth0
            BOOTPROTO=static
            BROADCAST=192.168.202.255
            HWADDR=00:09:6B:09:0E:BE
            IPADDR=192.168.202.244
            NETMASK=255.255.255.0
            NETWORK=192.168.202.0
            ONBOOT=yes

 Change the default gateway that take in effect immediately:
 # route add default gw 192.168.0.254

or

#vi /etc/sysconfig/network

           NETWORKING=yes
           NETWORKING_IPV6=no
           HOSTNAME=x3451
          GATEWAY=192.168.202.254

Ti restart the network card, the command is:

#/etc/init.d/network restart

Sunday, August 14, 2011

How to move 2Gb or bigger file in a script

#!/bin/sh

find /backup/include -printf '%s %p\n' | while read size name; do
    if [ "$size" -gt 2000000000 ]; then
        mv -i "$name" /backup/exclude
    fi
done