Monday, October 22, 2007

Some essential LINUX network Interface commands

#ifconfig .....command used to display information abt the currently active interface..
The information comprises of :
  • The type of interface like eth0,eth1 n so on
  • The IP address information like inet address 192.168.0.1,Bcast ip:192.168.0.255 Mask :225.255.225.0, RX-TX packets received-dropped-overrun-frames-collision
  • Hardware address HWaddress :00.ad.cc.15.25.22 (6 octate address or 48bytes
  • various other statistics

So therefore to know the inactive interfaces we must run :

# ifconfig -a

To start and stop the interfaces or in other sense bringing up and gringing down the eth0 we can run following commands:

# ifup interfacename

#ifdown interfacename

#service network restart/start/stop

#chkconfig network on/off

#netconfig interfacename .........to set the IP to the interface

The file which get modified is :

/etc/sysconfig/network-scripts/ifcfg-ethx

DEVICE=ethx

BOOPRO=dhcp/static

ONBOOT=yes

IPADDR=XXX.XXX.XXX.XXX

NETMASK=XXX.XXX.XXX.XXX

last two inputs are acceptable only if BOOTPRO is static

Global Network paramaters are available in following file :

/etc/sysconfig/network

NETWORKING=yes/no

HOSTNAME=fqdn by default

GATEWAY=XXX.XXX.XXX.XXX

NISDOMAIN=whatever

/etc/hosts For small LAN it act as a replacement for DNS

127.0.0.1 localhost.localdomain localhost

l'm suffering from some back pain so might come into my pace soon...

by the time this might act an appetiser for you Linux gigs

Thursday, October 11, 2007

The Magical Linux Boot Sequence

Its been a long time,i wrote anything abt Linux itself in detail….
Today I want to suppress my hunger by highlighting the BOOT sequence of Linux OS from scratch…..till the Login promp appears…

1)On a very basic level BIOS(Basic Input/Output System) which is the interface between the Hardware and Software provides the basic set of instruction used by any flavor of OS through CMOS(Complementary Metal Oxide Semiconductor).The CMOS which is about 64 bytes grabs and stores the hardware peripheral configuration permanently powered by a small battery located in Motherboard.
It’s the magic of this battery that CMOS retains the setting like date,time etc.. even when PC is turned off .Thus BIOS Has performed the POST(Power On Self Test) and now it looks for peripherals and a device to BOOT from.
Remember , BIOS reads and execute the first physical sector (about 512 bytes )of the chosen boot device.

2)Now appear the BOOT Loader Components
Boot Loader is responsible for loading and starting Linux or any other OS successfully.

But how is Boot loader invoked... tats the question ?
Answer : Certainly in below two possible ways :

1)BIOS passes the control to IPL(Initial Program Loader) installed within the in MBR(Master Boot Record).
2)BIOS passes the control to another Boot Loader (like ntldr of Xp ,LILO of Suse) ,which passes the control to IPL installed in boot partition ( /boot of abt 514MB ).


Remember IPL must not exceed the space of 446bytes

3)Hence IPL for GRUB is the First stage of Linux whose vital function is to locate and load a SECOND STAGE boot Loader (the blue splash screen)which actually do the most of the work to boot the system…

4)The Grub Boot Screen
A graphical Splash screen can be accessed by pressing enter key when GRUB starts up from First Boot Loader.This screen has got bootable image stanzas which can also be edited temporarily .Here we can also set Grub Password at Grub Command Line.

5) Now GRUB reads the Grub configuration file i.e. /boot/grub/grub.conf….available on the only fs which GRUB can understand i.e ext2/ext3, FAT,minix,FFS and reiserfs.If this file is missing Boot Loader will leave us alone with GRUB command Line which
a)can be used to write temporary boot commands from scratch..
b)View contents of files on fs,
c)perform diagnostic tests
d)experiment with GRUB configurations if file is available…

6)NOW The Kernel(http://kernelcoder.blogspot.com/) initialization files generate some output which scrolls in microseconds…i.e Device drivers compiled into the kernel are called …and locate their corresponding devices. Successful locations of device logs output to the kernel message buffer.(/var/log/dmesg).But essential drivers for ext3 fs, LVM, Software RAID and SCSI controller supports comes in modules and Kernel gets these modules from /lib/modules/$(uname) path. BUT Linux kernel still has to mount the root fs???????????????

Hhhhahahahahahah Big Question ..answer to this will be available in my next BLOG

I will welcome guesses , answers and comments …


7)After all drivers are located and loaded successfully the kernel mount the root fs ro.

8)INIT ----The first Process with (PID)process ID =1 is then loaded and control is now handed over to INIT .
Init reads /etc/inittab .which defines the default runlevel to pop into.
And further child processes can be run further.

9)But who initializes the intended runlevel ?
Answer ….
The file /etc/rc.d/rc has the responsibility to run or initialize the default runlevel specified in /etc/inittab and also acknowledge to start/stop the services with change in the runlevel.
Moreover, Each runlevel has its own corresponding directory with its scripts to run the daemon programs in background.But /etc/rc.d/rc.sysinit has many countless tasks to perform before any runlevel could be started.
/etc/rc/rcX.d
And then Symbolic links in corresponding run level directories call the /etc/rc.d/init.d scripts with start and stop argument.
Now Custom scripts are always run from /etc/rc.d/rc.local before getting Login Prompt

10)By default , init process respawns the mingetty services defined in /etc/inittab for each 6 VC. And the First VC /dev/tty7 is reserved for X server(gdm).The contents displayed by each VC is defined by expandable content in /etc/issue.
The mingetty and getty services are run for mentioned terminals.They read their configuration file /etc/mingettydefs.

11) As per gettydefs file getty process determines the speed of Terminal and Login Prompt with username appears. As we Login with authentic password…the username and passwd are matched with /etc/passwd and /etc/shadow. If match is successful then ,the init run the process mentioned at the of field of /etc/passwd .And we get the bash shell in Linux and bourne in UNIX ….About Xp Login, I donnt know…..God knows…..or may be U.

That’s it guys hope u might have true eclectic blend of fun, excitement ,anxiety and Mindblowing Power booster capsules.

Do leave your valuable comments and modifications if applicable…….

Thanking You

Nitin (kevin)