Tuesday, June 27, 2006

Linux Snippets.

Linux command tips ******
http://www.pixelbeat.org/cmdline.html


http://www.felixgers.de/teaching/emacs/vi_search_replace.html

Vi: Search and Replace
Change to normal mode with .

Search (Wraped around at end of file):

Search STRING forward : / STRING.
Search STRING backward: ? STRING.

Repeat search: n
Repeat search in opposite direction: N (SHIFT-n)

Replace: Same as with sed, Replace OLD with NEW:

First occurrence on current line: :s/OLD/NEW
Globally (all) on current line: :s/OLD/NEW/g
Between two lines #,#: :#,#s/OLD/NEW/g
Every occurrence in file: :%s/OLD/NEW/g
Command for commenting out N number of lines (N = number of lines) :.,+N s/^/#/g
-----------------------------------
awk and sed commands

file test.txt content is retheesh kumar R
to view kumar R use
#cat test.txtawk '{print $2 $3}'

or you can use sed command and remove retheesh
#cat test.txtsed 's/retheesh//'
this switches retheesh with blank //

vi +5 filename.txt # This will open the filename.txt with the cursor on the 5th line
vi +$ filename.txt # This will open the filename.txt with the cursor on the last line

=========================
Edit Multiple files at one go.
==========================

vi file1 file2 file3
Will open file1
:wnext to move to file2 by saving changes to file1
:next! to move to file2 without saving changes on file1

To move to previous file
:wprevious - To move to previous file by saving changes to the current.
:previous! - To move to pervious file without saving changes to the current

To see the list of file that is being edit and to know the current edite
:args

========================================
Viewing mulitple file on the same vim window
======================================

To split multiple files for easy editing. (Horizontal Split)
vim fileone #original file from the original file type
:split /path/to/filetwo # Another file
Will open up 2 different files you can toggle between both the files using CTRL + W
To save changes type
:wclose - Will save changes to the file
:close! - Will exit without any changes

To split multiple files for easy editing. (Vertical Split)
im fileone #original file from the original file type
:vsplit /path/to/filetwo # Another file
Will open up 2 different files you can toggle between both the files using CTRL + W
To save changes type
:wclose - Will save changes to the file
:close! - Will exit without any changes

================================
New file from existing vim window
===============================
Creat a new txt file from vi console
:new - Will create a new file for edition
Note while saving ensure to use :w filename to save the file
======================
Command to manually set date on the redhat system.

#date -s "MM/DD/yyyy hh:mm:ss"
Example -
#date -s "03/17/2006 02:01:39"
-----------------------------------
For better graphical display during bootup and on command line mode edit grub and
add " rhgb quite vga=0x317"

eg: kernel /vmlinuz-2.6.9-5.EL ro root=LABEL=/ rhgb quiet vga=0x317
---------------------------------

Procedure to register and up2date your machine.

#cat /etc/redhat-release -----------> will show the redhat version you are using

up2date-nox --config
httpProxy :
enableProxy Yes

#up2date-nox -l
This will connect to the server using the proxy details mentioned, and sent the server details to the rhn.redhat.com site. (tab systems).
#run the rpm -keyXXSSXXSSSS
execute command to start updating the packages to the latest
#up2date-nox -u -----------> will start updating all the packages with the latest packages available on redhat site.

Using up2date command to update kernel.
Note: Kernel update will not actually upgrade the kernel but install a new version of kernel and make relevent entries on the /etc/grub.conf file and set the boot parameter to boot with the new kernel.
#up2date-nox -f kernel -----------> either enter kernel* or manually give all the kernel-smp, kernel-Highmem etc to install.

#cat /etc/redhat-release -----------> will show the updated redhat version
--------------------------------------

mke2fs -j -b 4096 / will specifiy 4KB blocksize, this will help in faster fsck.


Saturday, June 24, 2006

bonding network card on linux.

1. Add entires on /etc/module.conf file
alias bond0 bonding
options bond0 miimon=100 mode=1
--------------------------------------
2. lsmod should detect module.
bonding 25220 1
-------------------------------------
3. cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
BROADCAST=3.159.19.255
IPADDR=3.159.17.80
NETMASK=255.255.252.0
NETWORK=3.159.16.0
ONBOOT=yes

cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
ETHTOOL_OPTS="autoneg off speed 100 duplex full"

cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=static
TYPE=Ethernet
ONBOOT=no

cat /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2
BOOTPROTO=static
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
ETHTOOL_OPTS="autoneg off speed 100 duplex full"

cat /etc/sysconfig/network-scripts/ifcfg-eth3
DEVICE=eth3
BOOTPROTO=static
TYPE=Ethernet
ONBOOT=no
==========================================

Wednesday, June 21, 2006

Enable full duplex and disabling autonegotiation for nic cards,

Modifying network settings

Add the following line in
/etc/sysconfig/network-scripts/ifconfig-eth0 &
/etc/sysconfig/network-scripts/ifconfig-eth2

ETHTOOL_OPTS="autoneg off speed 100 duplex full"

Restart network service
#service network restart

This will set network settings to full duplex, Speed: 100Mb/s & auto-negotiation: No

Run following commands to confirm network settings
#ethtool eth0
#ethtool eth1

Saturday, June 10, 2006

Words.. The ever Lasting Words.

Words without thought are dead sounds; thoughts without words are nothing.
To think is to speak low; to speak is to think aloud.
--Max Muller

It is with words as with sunbeams, the more they are condensed, the deeper they burn.
--Southey

Words are things; and a small drop of ink, falling like dew upon a
thought, produces that which makes thousands, perhaps millions, think.
--Byron

Sunday, June 04, 2006

Walk down by the River.

Lazily walking by the river side,ear tunes to the gurgles of water beside, each step leaving the behind a trailing path on the white river bank.Letting out the little shiver of winter, mist masking the view far ahead. Trees dance to the tunes of the wind, early morning birds get more chirpy with each early find.

Sun shined far away, painting the sky with enchanting colours adding a tinge pigment of red to everything the eye could set upon. The early winter sun feels like the comfort of a warm blanket on a chill winter night.

The giant rocks by the bank of the river project out of flowing water, creating ripples and belting out the soul filling melody. The greater rock beneath that braved for centureis the fury of the river, yet stands tall smiling like a buddha bringing scenerity to the surrounding.

New leaves of the season sprout the bare branches, soft and subtle, colours so vibrant that tempt to fondle them, the morning mist droplets wet the tender green grass blades, the droplets on them sparkle like a sprawling diamond field all around waiting to be picked up.

The early wind carrying the scent of the nilgiries and the music of the nature, with it moisture of the river and the wetness of mist,caresing the body bringing it alive with glee,

God said "Adam & Eve, Wasn't this, what i left you as world" ;-)