Tuesday, June 14, 2011

Boot Process Linux Sort

In sort boot process of linux OS ....

power on --> BIOS load into RAM --> BIOS moto is to load OS --> for that he perform POST inventry and calls CMOS to know boot order

---> after getting boot order BIOS load it whatever it finds in first sector of hdd into RAM this is what we called MBR

M ----------------------------- B ----------------------------------- R
<----------------------------- 512 bytes --------------------------->
+--------------BS------------+ +--------PT--------+ +----MN----+
                    446                              64                      2          
M ------------------------------ B ----------------------------------- R

--> Exaine PT of MBR to know where is active partition (AP) -> Then BIOS load whatever it finds on BS of AP
--> BIOS then load 1SBL(1st satge boot loader) which were put there by anocanda during install time.
--> 1SBL gives CHS # of the /boot/boot.map to BIOS to load 2SBL(2st satge boot loader)
--> 2SBL examine the binary format of grub.conf and follows all instructions given there.
--> with the help of BIOS 2SBL loads Linux kernel vmlinuz-2.4.20-8 into the RAM
--> 2SBL uncompress kernal vmlinuz and filled it into ram waht we see in /proc dirr...
--> Now Linux Kernel is into RAM which is much powerfull than 2SBL and takes total control from it.
--> With the help of BIOS Kernal uncompresses the /boot/initrd-2.4.20-8.img to find filesystem driver.
-> Now HDd driver available and Kernel is into RAM
-> Now Kernel Load /sbin/init  program into RAM.
-> /sbin/init* examines /etc/inittab  and
                        1> run level (0-6 what ever is is defined) and run an script name
                        2> /etc/rc.d/rc.sysinit in a subshell of inittab shell
                        which calls /etc/sysconfig/network to load networking
                        and start various functions defined in /etc/init.d/functions
                        and Mounts all local filesystems from /etc/fstab and updates /etc/mtab
                        and now function of ec.sysinit ends
                        Short summary of what rc.sysinit does
                             ===================================== in sort waht done by rc.sysinit
                             system logs
                              date and time
                             system font
                             swap partitions
                             file system checks
                             mount the filesystems read/write

                        3> /etc/rc.d/rc      { as a subshell }
                           /etc/rc.d/rc3.d/S* -->   start & stop of services
                           /etc/rc.d/rc.local  -->

--> shell inittab is active and by defaults there are 6 mingettys out of which all entered into sleep state     
--- except 1
---> this mingetty then executes the /bin/login process and is then it put into sleep state by init
---> and we get promped for username & password
--> * /bin/login execs /usr/bin/passwd which challenges for passwd from
    us which then does authentication and authorization using PAM
---> after Right username and password
---> mingetty then goes into zombie state and is killed by init
---> defined shell loads and we get our shell based command prompt:#$

Linux Interview Questions

1>  Diff between RHEL 4 & 5 ?
2>  About boot process in sort?
3>  Types of DNS?
4>  how dns works?
5>  what is squid?
6>  port number of data ftp, ftp, telnet, smtp, sql
7>  what is sendmail hows it's works
9>  How to block downloading in squid
10> How you handle Load on server?
11> Fields in crontab?
12> Any backup tools you know?
13> what is amanda why to use?
14> How to upadte your server?
15> rpm commands to update, erase, install etc...
16> Use squid to do authentication of users on browser?
17> USe of NFS and samba?
18> Diff NfS & Samba?
19> What is SeLinux?
20> DEfault cache size in Squid?
21> I want to assign NISdomainname via DHCP is it possible how?
22> How to setup networking IP doaminname etc...
23> What is & Difference between find and grep
24> About Raid tool used & level diff
25> I want to do remote login how?
26> Use of NIS?
27> Use of Log files?
28> I sent a mail but lost how to find it where is ..?

Some other

- How to find which user surfed which site? squid not log file
- which command you use for maintaing system info to submit to your manager?
- How you reduce load on your server
- tools used to check system load and performance
- Do you know anything about DHCP on windows server
- Application that you much like can confident about that
- In sort what you know in Linux
- Can you compile C program in linux how?
- about Linux shell scripting any other scripting language you know

Another that some asked to me?
1> why i hire you?
2> what is mean and responsibilities of a sys admin
3> why you chose linux as career?
4> About your current job and responsibilities
5> After doing job in diff field near about 2 years why you want to move your path
6> Why Linux not Windows?  :)
7> What is your strenght?
8> Do you have any question?
9> Anything that you want to ask?
10> What is yor expection?
11> expected salary?
12> notice period how soon you can join?

Our HR department will inform you -- Why this?? :(

Some exact questions i don't remember so i just written in short!!!

1>  size of MBR, fields in MBR, PT size in MBR
2>  Dir /abcd have 744 perm to user but file /abcd/file1 has 777 permission can a normal
    user edit file1, if no why?
4>  what called #! /bin/bash
5>  There a parameter in vsftpd conf file without which vsftpd server will not work
6>  Diff GRUP & LILO techinical DIFF ...
7>  Can we authenticate only users login on vsftpd by LDAP how
8>  Port number SAMBA, DHCPD, SQUID, DNS, POP, POP, NTP on secure level, IMAP on secure level,
    sendmail on secure level, Postfix..
9>  Diff TCP/UDP
10> What are 7 Layers TCP/IP eg of each
11> Fields in DNS
12> USe of ip_farwording
13> where is config file of sshd service.
14> what is tunnel
15> What is mutt
16> fields in top command meanings
    1>load average 2> %id     3> Mem: 4> SWAP
17> What is the use of swap partition
18> can we encrease swap partition size how
19> syntax of for loop in bash
14> awk stand for
15> can we change vsftpd default directory location
16> Can we change Default Directory in apache
16> Can we use index.php insted of index.html as default page in apache how .
17> visudo command will open file?
18> Diff RHEL & Centos
19> Diff LILO GRUB
20> Advantages of GRUB
21> What is iptables, Firewall, netfilter ..?
22> write iptable to block use of sshd service via port 22 from outside of range
23> Tables in iptables
24> what is cluster & virtualizaton just basic, what you understand by term..
25> what is domain and hostname concept.
26> can a system have multiple hostname/domainname how?
27> how many virtual ips you can assign to a single interface.

Power of vi editor Linux

# vim /home/suresh/myscripts/scratcher.sh <-- colorfull look
# vi  /home/suresh/myscripts/scratcher.sh  <-- simple
Moving through the text is usually possible with the arrow keys. If not, try:

h -> move Left
l  -> move Right
k -> move up
j -> move down

shift+H : top of file  (or :1 similarly you can go to any line by line number(n) :n)
shift+G : end of file (or :$)

dd       --> delete current line
5+dd   -> delete 5 line from current line (similarly n line)
5+dw   -> delete 5 words from current word
x         -> delete single character from current position
cc        -->cut all current line  content & leave the editor in insert mode
C         --> delete all words from current position to end of line.
s         -->cur the current character and leave te curser in insert mode

yy       -->copy line
n+yy   --> copy n lines
pp       -->paste copied line etc..
n+pp   -->paste n times

Insert Mode:
1> i   or I (cpas i)
2> Insert button
3> a (+move curser to 1 position right)
4> A (+ move the curser at end of line)
5> o  (+ a blank line below current)
6> O (+ a blank line above current)

Command mode:  ESC button

:w   -> Save
ESC+z+z --> Save & exit
:wq  -> Save & Exit
:q    -> Exit
:q!   -> Exit without Save
:w file2 will save the text to file2.
:wq! overrides read-only permission
/find  -->Search string "find"  use "n" to search new location
? find --> same as above but search in opposite dir
:1, $s/shirish/shukla/g  -->replace shirish by shukla throught file

undo & redo:
esc+u --> undo
ctl+r   --> redo
esc .  --> repeate the previous change


step 1> Go to the required word (type ESC+ma) you can use any lowercase  a - z, A - Z, [  ect,..   note that a & A store diff bookmarks etc..
step  2>To go to bookmarked location (type ESC+ `+a  ) note ` is above TAB button, similarly you can give various bookmarkes
* You can go to yu last edited line by -->  ESC+`+ .

:marks   --> Will show  your bookmarks in current file.

Quick Summary of Vim Bookmark Commands

    * ma –> Creates a bookmark called a
    * `a   –> Jump to the exact location (line and column) of the bookmark a
    * ‘a   –> Jump to the beginning of the line of the bookmark a
    * :marks –> Display all the bookmarks
    * :marks a –> Display the details of the bookmark with name a
      `. –> Jump to the exact location (line and column) where the last change was performed
    * ‘. –> Jump to the beginning of the line where the last change was performed


K --> Go to the man page of the word currently under the curser.

tar,zip,bzip,bzip2 linux commands

================== Compress Archiever ===========================

==> tar
tar -cvf file.tar          ----> tared
tar -tvf file.tar                  ----> tabular view content of file
tar -xvf file.tar                  ----> untar

==> compress & uncompress    >>> RH-9 absent in RHEL versions
tar -Zcvf file.tar.Z     ----> compress
tar -Zxvf file.tar.Z                 ----> uncompress

compress file.tar
uncompress file.tar.Z

==> zip & unzip
gip file.tar           ----> ziped
gunzip file.tar.zip              ----> unziped

==> gzip & gunzip
tar -zcvf file.tar.gz   ----> gziped
tar -zxvf file.tar.gz

gzip file.tar
gunzip file.tar.gz
==> bzip2 & bunzip2
tar -jcvf file.tar.bz2   ----> bziped
tar -jxvf file.tar.bz2              ----> bunziped

bzip2 file.tar.bzip2  
bunzip2 file.tar.bzip2

===========>> Test file contents of compressed file
tar -tvf                
    tar -Ztvf               
    tar -ztvf            
    tar -jtvf              

zcat .gz
bcat .bz2   ---> absent in RHEL
cpio -idmv .cpio
zcat .cpio.gz | cpio -idmv

=================== Advanced =======================
1 line gungip and untar
# zcat backup.gz | tar -xvf -

Chaneg Date and Time Linux

============ Treating with date command =================
1> date 081811002007 [mmddhhmmyyyy]--To set the Linux clock to 11th-Aug-2007-11-AM
2> timeconfig --Set your TIMEZONE
3> hwclock --hc to sys--->-->To set the Linux[system]clock from the HW clock
4> hwclock --utc sys to hc -->To set the HWclock from the Linux[system] clock

touch -t yyyymmddhhmm filename

echo "DATE:" `date --date "today" +%d-%m-%Y`             <--DATE:20-12-2010
echo "DATE:" `date --date "yesterday" +%d-%m-%Y`
echo "DATE:" `date --date "+5 minutes ago" +%d-%m-%Y-%M` <--present  -5 min
echo "DATE:" `date --date "-5minutes ago" +%d-%m-%Y-%M`  <---Present +5 min
echo "DATE:" `date --date "1 month ago -5 minutes ago" +%d-%m-%Y-%M`
                                                         <--present -1 month +5 min

Some importnat journal use paramiters
%a  --> Mon
%b  --> Jan
%d  --> date 01..31      %e  --> 1..31
%H  --> hour 0..23)      %k  --> 1..23
%M  --> minute (00..59)
%S  --> Seconds(00..60)
%I  --> hour 00..12)     %m  --> 1-12
%Y  --> year 2010        %y  --> year 10(last 2 digit)
%p  --> AM-PM            %p  --> am-pm
%T  --> %H:%M:%S

=================================== More n more ==================
%%--->a literal %
%a--->localeâs abbreviated weekday name (e.g., Sun)
%A--->localeâs full weekday name (e.g., Sunday)
%b--->localeâs abbreviated month name (e.g., Jan)
%B--->localeâs full month name (e.g., January)
%c--->localeâs date and time (e.g., Thu Mar  3 23:05:25 2005)
%C--->century; like %Y, except omit last two digits (e.g., 21)
%d--->day of month (e.g, 01)
%D--->date; same as %m/%d/%y
%e--->day of month, space padded; same as %_d
%F--->full date; same as %Y-%m-%d
%g--->last two digits of year of ISO week number (see %G)
%G--->year of ISO week number (see %V); normally useful only with %V
%h--->same as %b
%H--->hour (00..23)
%I--->hour (01..12)
%j--->day of year (001..366)
%k--->hour ( 0..23)
%l--->hour ( 1..12)
%m--->month (01..12)
%M--->minute (00..59)
%n--->a newline
%N--->nanoseconds (000000000..999999999)
%p--->localeâs equivalent of either AM or PM; blank if not known
%P--->like %p, but lower case
%r--->localeâs 12-hour clock time (e.g., 11:11:04 PM)
%R--->24-hour hour and minute; same as %H:%M
%s--->seconds since 1970-01-01 00:00:00 UTC
%S--->second (00..60)
%t--->a tab
%T--->time; same as %H:%M:%S
%u--->day of week (1..7); 1 is Monday
%U--->week number of year, with Sunday as first day of week (00..53)
%V--->ISO week number, with Monday as first day of week (01..53)
%w--->day of week (0..6); 0 is Sunday
%W--->week number of year, with Monday as first day of week (00..53)
%x--->localeâs date representation (e.g., 12/31/99)
%X--->localeâs time representation (e.g., 23:13:48)
%y--->last two digits of year (00..99)
%z--->+hhmm numeric timezone (e.g., -0400)
%:z   -> +hh:mm numeric timezone (e.g., -04:00)
%::z  -> +hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z -> numeric time zone with : to necessary precision (e.g., -04, +05:30)
%Z    -> alphabetic time zone abbreviation (e.g., EDT)

Telnet configuration in RHEL5

First check whether telnet-server rpm in installed,
# rpm -q telnet-server
If it is installed, then edit
# vi /etc/xinet.d/telnet
change the line disable = yes to
disable = no
Then # service xinetd restart
Now We can able to telnet connection of linux system.
Note : It works for the system which is not protected with IPtables and Selinux
If you have iptables enabled. then please follow as below,
Make a rule to allow telnet from external clients
# iptables -I INPUT -p tcp --dport 23 -j ACCEPT
# service iptables save
# service iptables restart
Just give following command and make sure that rule is saved.
# iptables -L
This rule is to allow request coming to port number 23 i.e. telnet connections from any client.

My conclusion
1> off firewall
2> chkconfig krb5-telnet on
3> please note do not on krb5-telnet
4> service xinetd restart