Linux Unix help !!

"Give respect to Time, One day at right Time, Time will respect You"

Thursday, January 27, 2011

boot process Linux sort

Boot Process in sort by Shirring Shukla

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
                             hostname
                             system logs
                              date and time
                             keyboard
                             system font
                             swap partitions
                             usb
                             file system checks
                             mount the filesystems read/write
                        =====================================

                        3> /etc/rc.d/rc      { as a subshell }
                           /etc/rc.d/rc3.d/K*
                           /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:#$

# Faced any problem Feedback in above contact me
#============================Scratch=================================#
#                                                      AND Many More .....................Linux is Endless                 #
#========================== Hope you Liked IT ==========================#
#                                                                                    BOOT PROCESS-- BY Shirish Shukla #
#                                                                                                                  RHC Engineer 2010 #
#                                                                                                            shirish.linux@gmail.com #
#                                                                                                          shirishlinux.blogspot.com #
#                          "Give Respect To Time One Day At Right Time, Time Will Respect You" #
#===================================================================#
#                           TRy Hard theres nothing that are un-achievable by HARDdd-WORKkk   #
#===================================================================#
bOOT PROCESS, hoe boot process works linux, boot processing of linux in sort, linux boot process shirish, boot process,boot process, linux, in sort how boot process linux works, linux, boot, process, works date configuration linux, linux, commands, Linux commands, kernel Linux, Linux mantra, linux history command, magic, Linux web, yum server configuration Linux, cron, anacron

LINUX INTERVIEW QUESTIONS


Hello Friends,

We all might have faced various interview questions and well aware of as a beginner how tough to clear it at first attempt almost all have too many questions.

Below are some interview question that have faced during my journey in Linux/Unix journey !!

"TELL ME SOMETHING ABOUT YOUR SELF"

0. As usual !!! "Tell me something about yourself"? An annoying question? but everyone have to face this and have to be well prepared as first impression might be your last impression .

Don't loose your confidence or get afraid as you have to sell your knowledge in this competitive market and if you failed here doesn't mean path has end ..

Let's find out how to answer this in well organized order in < 2-3 minutes .

1. Your NAME in full
2. Your qualification in short start with 1-10th -> 11-12th -> Degree 
3. Fresher -> Your college project brief explained
    Lateral -> Your first job how you got and roles & responsibility
                -    Small intro about your previous all experience
                -   Current Job detailed info like day2day activities, roles
                -   Future opportunity at your current job
                -   Your future goal (Only if have left some time)
4. That's it from my end IF anything else you want to know then please ask !!
Note: - Don't explain much about your family background unless being asked :)
         - Don't be more overconfidence
         - Don't show your ego mean judge interviewer and try your best that Interviewer will not feel like he is more technically stronger than me :)
         - Don't be short tempered
         - Include technical skill-sets for which you have confidence 
         - Don't be too over smart, as that might create negative impression towards like "WILL SEE HIM IN TECHNICAL ROUND!!!  '(';')'   '(';')' ...
         - Keep cool & calm, as this is not your last opportunity many more has to come at your path .

Okay lest start with some Linux interview technical questions :

Basic Level 1 for freshers or < 2 yr exp..
Expert Level for lateral 
  1. What is Linux 
  2. Diff Linux & Unix 
  3. Diff RHEL 5/6 
  4. What's new in RHEL 7
  5. Linux boot process in brief 
  6. Port numbers on FTP 
  7. Port number of telnet, smtp, dns, dhcp, ntp, http, https
  8. How to check/edit other users cron entries
  9. What is user shell
  10. How to check available shells
  11. How to change your current shell 
DNS:
  1. What is DNS 
  2. How DNS works 
  3. Types of DNS
  4. Types of records in DNS 
  5. How to check DNS lookup 
  6. How to update DNS zone without service restart
  7. How to check any error in zone file
  8. What & Why NS record in DNS
  9. Master and slave how it's working 
  10. How to ensure updates send to slaves
  11. Static vs Dynamic DNS zones
  12. How to update dynamic zones & usages 
  13. Fields in zone file 
  14. reload for specifiz domain zone 
CRONTAB:
  1. What is crontab
  2. Fields in crontab
  3. Where is user specific cron file
  4. What is system specific cron, where are they defined  
  5. Use of /etc/crontab file 
  6. Eg. Schedule a script run every day at 11:00pm
          Schedule a script run every 2 minutes
Backup:
  1. Any backup tools you know?
  2. What is diff tar and zip 
  3. gzip pack and unpack 
  4. cat gzip file 
  5. bazip2 pack and unpack 
  6. cat bazip2 file 
  7. extract without effecting current file 
  8. extract to specific dir 
Yum & rpm:
   yum: 
  1. yum package name 
  2. Find current available repos
  3. Install from specific repo
  4. Install local rpm
  5. Find all available version of package
  6. Find when package was installed 
  7. Install a specific version of package 
  8. Check package integrity 
  9. Clear yum cache, required in which case example .
  10. Find package all files 
  11. How to setup YUM server 
  12. How to setup yum client
  13. How to setup yum proxy
    rpm:
  1. rpm package name 
  2. install/update/remove etc 
  3. Find when package last updated
  4. Find package info, files, dependencies 
  5. What is rpmdb
  6. how to re-build
Mail Server:
Do you have experience on any mail server ?
Postfix: 
  1. How Postfix or any mail server works 
  2. What is configuration file
  3. PORT Number 
  4. Check service running or not and listening on which IP
  5. How to send a test mail 
  6. Log file path
  7. Check mailq 
  8. Flush mailq
  9. Resend, force retry all mails in queue 
  10. How to handle maillog rotation 
  11. Listen on localhost why ?
  12. Listen is specific IP why ?
  13. Diff master and client setup basic 
  14. What is master.cf 
  15. Filter any specific user mail -> DISCARD
  16. Mail to specific user -> DISCARD 
  17. Allow mail sent to specific domain only 
  18. Allow only specific set of users to send mail 
  19. Allow mail form a specific subnet
  20. Minimum requirement to setup postfix mail server
  21. Sent mail lost troubleshooting steps .
Specification:
  1. Find Physical or Virtual
  2. Find System vendor name i,e Manufacturer name 
  3. Find total RAM  
  4. Find total swap
  5. Find total socket, Core, CPU's on server
  6. Find System serial number 
  7. Find HBA cards
Troubleshooting:
  1. Total current Load on server, how to check 
  2. What is load average, how and where to find and statics interval
  3. Total cpu utilization on server how to calculate
  4. Total memory utilization
  5. Total swap utilization 
  6. Add additional swap? how ?
  7. Which process consuming more CPU
  8. Which process consuming more RAM
  9. Which process consuming more SWAP
  10. Which process consuming more no of process 
  11. How to find total number of process thread initiated by a process 
  12. What is i/o on system, how to find 
  13. Which process causing high i/o
  14. Diff paging and caching 
  15. What is cpu steal time 
  16. What is memory over-commit
  17. Find troubleshoot memory leak
  18. How to enter in single user mode 
  19. diff single user and emergency mode 
  20. How to recover boot grub password 
  21. How to clear cache, why its required and what would be impact of this 
Boot level :
  1. How to set grub password
  2. How to set default kernel to boot 
  3. How to change kernel parameters during boot 
  4. How to repair FS 
  5. What is GRUB 
  6. Size of MBR, fields in MBR, PT size in MBR
  7. What is rescue mode 
  8. How to enter in rescue mode and why required example 
  9. Take MBR backup and repair 

Networking:
  1. How to assign IP address
  2. How to assign  virtual IP address
  3. How to assign temporary IP address
  4. How to change hostname permanent
  5. How to assign temporary hostname 
  6. What is Gateway
  7. How to assign Gateway 
  8. What is domainname 
  9. TCP vs UDP with example of each 
  10. OSI layer 
  11. How many virtual IP you can assign to a single interface .
  12. What is route table 
  13. How to update route table temporary 
  14. How to update route table permanent
  15. What is bonding
  16. How to setup network bonding for 2 interface 
  17. Mode of bonding 
  18. Steps of bonding 
  19. Check current status of bond interface 
  20. Check members of bond
  21. Bonding vs Bridging in Linux
  22. What is ARP
  23. What is network boot
  24. What is iptables
  25. Tables in iptables
  26. Write iptable to block use of sshd service via port 22 from outside of range 192.168.8.10-192.168.8.50
  27. What is tcpdump 
  28. tcpdump take dump of all packets coming from host1 and host 2 on port 3030 on ethernet eth2 and write to file /tmp/a.pcap
  29. Read tcpdump file 
  30. What is ip_forwarding 
Setup:
  1. How to install Linux RHEL/CentOS OS 
  2. Types of installation 
  3. What is PXE boot 
  4. What is network boot 
  5. Rapid Kickstart installation 
  6. Any other installation method you know 

Volume Management ( LVM ) :
  1. What is LVM 
  2. What is File system 
  3. Advantage of ext4 over ext3
  4. Advantage of xfs over ext4
  5. What are the fields in /etc/fstab
  6. Ex: create a LV of 5GB and mount of /test
    Disk1: /dev/sda
    Disk1: /dev/sdb
    VG to create: VG01 with above 2 disk
    LV: mytestlv
    Mount with both dump & pass enabled ? What are these fields ?
  7. How to extend LV
  8. how to reduce LV
  9. How to extend VG
  10. how to reduce VG 
  11. How to take snap of LV
  12. How to destroy LV, VG, PV 
  13. Find number of PV's in VG
  14. Find free available size in VG
  15. Create LV with all availabel free size in VG
  16. Change VG parameters .  
Scripting:
  1. Do you have experience on any scripting language
  2. Bash shell scripting ?
  3. What is first line of script eg. "#! /bin/bash" and why it's there
  4. How to pass arguments in script 
  5. How to read arguments in script 
  6. How to define array 
  7. How to define float value
  8. How to define string
  9. How to print no of arguments passed in script 
  10. What is echo $#
  11. What is echo $@
  12. Print 1 to 10 in reverse order
  13. Synatx of for loop
  14. Syntax of while loop
  15. Syntax of if else
  16. Syntax of neted if else
  17. Syntax of case statement
  18. What is getopts
  19. What AWK stands
  20. AWK to print 3rd column
  21. Using grep find how many times word "HELLO" appear in file1
  22. Using egrep find if file1 contains HELLO1 and HELLO2
  23. Diff grep and egrep 
  24. Use sed to replace "hello" to "sello" in file
Others:
  1. USe of ip_farwording
  2. Where is config file of sshd service.
  3. What is tunnel
  4. What is mutt
  5. Fields in top command meanings
  6.     1>load average 2> %id     3> Mem: 4> SWAP
  7. What is the use of swap partition
  8. Can we increase swap partition size how
  9. Syntax of for loop in bash
  10. Can we change vsftpd default directory location
  11. Can we change Default Directory in apache
  12. Can we use index.php insted of index.html as default page in apache how .
  13. visudo command will open file?
  14. Diff RHEL & Centos
  15. Diff LILO GRUB
  16. Advantages of GRUB
  17. What is iptables, Firewall, netfilter ..?
  18. What is cluster & virtualizaton just basic, what you understand by term..
  19. Whats does 2nd column refer in # ls -l output 


 .... N.. MANY MORE COMING SOON .... KEEP LEARNING...!!!!


# Faced any problem Feedback in above contact me
#============================Scratch==============a===================#
#                                                     AND Many More .....................Linux is Endless                #
#========================== Hope you Liked IT ==========================#
#                                                                                       INTVR QSTNS-- BY Shirish Shukla #
#                                                                                                                 RHC Engineer 2010 #
#                                                                                                           shirish.linux@gmail.com #
#                                                                                                         shirishlinux.blogspot.com #
#                         "Give Respect To Time One Day At Right Time, Time Will Respect You" #
#===================================================================#
#                          TRy Hard theres nothing that are un-achievable by HARDdd-WORKkk   #
#===================================================================#
Linux interview question and answers, Linux, interview questions, answers,linux, unix, fedotra, interview, questions,linux+interview+questions+boot+process,BOOT PROCESS, hoe boot process works linux, boot processing of linux in sort, linux boot process shirish, boot process,boot process, linux, in sort how boot process linux works, linux, boot, process, works date configuration linux, linux, commands, Linux commands, kernel Linux, Linux mantra, linux history command, magic, Linux web, yum server configuration Linux, cron, anacron
Linux Interview Questions and Answers,UNIX - LINUX Interview Questions and Answers,Tech Interviews | Unix/Linux,Operating Systems Interview Questions , Interview questions linux,interview questions lin

LOGWATCH LINUX

logwatch - system log analyzer and reporter

--detail level  10/5/0              (high, med, low)
--debug level   0/1/..100           
--service service-name/all          (more , seperated )
--print                             (Print output on screen)
--save /usr/mylogwatch_`date +%d-%b-%Y`
--mailto shirish@server.example.com
--range Yesterday/Today/all/Help  
--archives                          (logwatch searches archived too like messages.1 etc..)
--logdir /var/op/logs/              (Locate your log dirs)



Config FILES (Source REDHAT)
       /usr/share/logwatch/
              This directory contains all the perl executables and configuration files  shipped  with
              the logwatch distribution.

       /etc/logwatch
              This  directory contains local configuration files that override the default configura-
              tion.  See MORE INFORMATION below for more information.
EXAMPLES
       logwatch --service ftpd-xferlog --range all --detail high --print --archives
              This will print out all FTP transfers that are stored in all current and archived xfer-
              logs.
       logwatch --service pam_pwdb --range yesterday --detail high --print
              This will print out login information for the previous day...

range
   --range today
   --range yesterday
   --range '4 hours ago for that hour'
   --range '-3 days'
   --range 'since 2 hours ago for those hours'
   --range 'between -10 and -2 days'
   --range 'Apr 15, 2005'
   --range 'first Monday in May'
   --range 'between 4/23/2005 and 4/30/2005'
   --range '2005/05/03 10:24:17 for that second'

# Faced any problem Feedback in above contact me
#============================Scratch===============================#
#                                                     AND Many More .....................Linux is Endless               #
#========================== Hope you Liked IT =========================#
#                                                                              CMND LOGRATATE-- BY Shirish Shukla #
#                                                                                                                 RHC Engineer 2010 #
#                                                                                                           shirish.linux@gmail.com #
#                                                                                                         shirishlinux.blogspot.com #
#                         "Give Respect To Time One Day At Right Time, Time Will Respect You" #
#==================================================================#
#                          TRy Hard theres nothing that are un-achievable by HARDdd-WORKkk  #
#==================================================================#
,
,boot+process+linux, linux+interview+questions+ bOOT PROCESS, how boot process works linux, boot processing of linux in sort, linux boot process shirish, boot process,boot process, linux, in sort how boot process linux works, linux, boot, process, works date configuration linux, linux, commands, Linux commands, kernel Linux, Linux mantra, linux history command, magic, Linux web, yum server configuration Linux, cron, anacron

change date and time linux

change 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)
%Y--->year
%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)

### Other usefull operation with date command
# date  --date="next Monday"
# date  --date="10 days ago"


#####  Yesterday
# date --date="yesterday"   --OR--
date --date="-1 day"


##### Tomorrow
# date --date="next day"      --OR--
# date --date="-1 days ago"
# date --date='tomorrow'

##### After n  Day/week/month/year
# date --date='101 day'
# date --date='101 week'
# date --date='101 month'
# date --date='101 year'

### Similarly Before n Day/week/month/year Ago
# date --date='101 day ago'
# date --date='101 week ago'
# date --date='101 month ago'
# date --date='101 year ago'

#####  10 hours ago
# date --date='10 hour ago'
##### After 10 hours
# date --date='10 hour'   --OR--
# date --date=-'10 hour ago'     <-- Same applicable for all
##### 10 minutes ago
# date --date='10 minutes ago'
##### 10 seconds ago
# date --date=-'10 seconds ago'

##### Print date after 1 day 5 hour
# date --date='1 day 5 hour'

# date --date='-1 day -5 hour ago'



# Faced any problem Feedback in above contact me
#============================Scratch==============================#
#                                                     AND Many More .....................Linux is Endless               #
#========================== Hope you Liked IT =======================#
#                                                                                          CMDS DATE-- BY Shirish Shukla #
#                                                                                                                RHC Engineer 2010 #
#                                                                                                           shirish.linux@gmail.com #
#                                                                                                         shirishlinux.blogspot.com #
#                          "Give Respect To Time One Day At Right Time, Time Will Respect You" #
#==================================================================#
#                          TRy Hard theres nothing that are un-achievable by HARDdd-WORKkk  #
#==================================================================#
date configuration linux, linux, commands, Linux commands, kernel Linux, Linux mantra, linux history command, magic, Linux web, yum server configuration Linux, cron, anacron

LVM setup linux

----LVM --------- --> Logical Volume Management -- Shirish Shukla

PV -- Physical Volume
VG -- Volume Group
LV -- Logical Volume

---------Create LVM partition------- /myvol/vo

# fdisk /dev/sda

create new partition 1200Mb of type LVM(8e)

# partprobe -s
# fdisk -l              (Check )

-------------LVM-----------

# pvcreate  /dev/sda10
# vgcreate  myvol   /dev/sda10   (will create VG "myvol")
# vgdisplay                      (Varify VG)
# lvcreate  -L1000M -n vo myvol
# lvdisplay                     
    LV Name   /dev/myvol/vo

# mkfs.ext3 /dev/myvol/vo
# vi   /etc/fstab

Comment
Label=/home ....

and make below entry

/dev/myvol/vo    /home    ext3    defaults    1 2

#umount /home
#mount -a
#mount       (Varify   /home)


xxxxxxxxxxxxxxxxxxxx

Q: Resize LVM to 300M.

    Check lvm status by using
    # lvdisplay
    # vgdisplay
    # df –h

    Case I: current  <  300M

    #lvextend   -L 300M  /dev/myvol/vo
    #resize2fs  /dev/myvol/vo
    #lvdisplay        …check lvsize
    #df   -h           ….varify  size on /home

    Case II: current > 300M

    #umount  /home
    #e2fsck   –f    /dev/myvol/vo
    #resize2fs   /dev/myvol/vo  300M 
    #lvreduce   -L 300M   /dev/myvol/vo
            ---: type yes
    #lvdisplay      ..varify lv size must be 300M
    #mount  -a
    #mount           …..varify
    #df  -h             …..varify

# Faced any problem Feedback in above contact me
#========================  ===Scratch===============================#
#                                                     AND Many More .....................Linux is Endless               #
#========================== Hope you Liked IT =========================#
#                                                                                                     LVM-- BY Shirish Shukla #
#                                                                                                               RHC Engineer 2010 #
#                                                                                                          shirish.linux@gmail.com #
#                                                                                                         shirishlinux.blogspot.com #
#                           "Give Respect To Time One Day At Right Time, Time Will Respect You" #
#==================================================================#
#                          TRy Hard theres nothing that are un-achievable by HARDdd-WORKkk  #
#==================================================================#

vsftpd configuration linux

 Replace your vsftpd.conf by below of myne ...

##!!!!!!!!!!!!!!!! vsftpd: - Shirish Shukla !!!!!!!!!!!!!!!!!!!!!##
#Clinet:
#GUI :gftp
#CLI :ftp

#Server Config:
#Default : /etc/vsftpd/vsftpd.conf
#Some Binary : /etc/vsftpd.conf

#Service:
#/etc/init.d/vaftpd start|stop|restart|condrestart|status
#/usr/sbin/vsftpd &

#vsftpd.conf
#Remember:
#1>Don't use space before or after '=' it's error
#2>All paramiter start from column 1 i.e no space before parameters..
#3>Any misspell result deman not starting
#4>YES/NO and yes/no dosent matter
#============================== vsftpd.conf ==========================
####An Ipportant minimum requirement .

listen=yes

###You FTP Banner
ftpd_banner=WellCome to Shirish Shukla Word OF FTP .
##Can Include File
#banner_file=/etc/vaftpd/ftpbanner
##You Can specify denied users mail id from file .
#deny_email_enable=YES
#banned_email_file=/etc/vsftpd/banned_emails

####=================== Main Configration ======================####
###By default only anon user is allowd #(ftp' and 'anonymous' are VLUs for anonymous.)
anonymous_enable=yes
##Input of anon password IF Default YES straight login no psw
#no_anon_password=YES
##FTP Default Home dir.. default below can change
#anon_root=/var/ftp/
##Dafault FTP username default below can change
#ftp_username=ftp

###Want VLU to use FTP
local_enable=yes
##Auth by PAM
pam_service_name=vsftpd

#       test: pam modulle have to be preseent
#       ldd `which vaftpd` |grep pam

###If local_enable=YES VLU can access to FTP after authentication
##Want VLU to access ther Home dir only..chroot them
#chroot_local_user=YES
##Want to unchroot some listed user
#chroot_list_enable=YES
#chroot_list_file=/etc/vsftpd/chroot_list
##Each users jail based on directory string in /etc/passwd.
#passwd_chroot_enable=NO
##Enabled, all non-anonymous[VLUs]rooted to /var/ftp
#guest_enable=NO
#guest_username=ftp
##Default root dir.. for anon same as anon_root
#local_root=/var/ftp

###Enable/Disable FTP Write command
write_enable=YES

###File dir upload permission by default 022
local_umask=755

###BY default below NO Anon user can upload and make dir..
#anon_upload_enable=YES    
#anon_mkdir_write_enable=YES
###messages given to remote users when they enter into dir..
#dirmessage_enable=YES

###data transfer connection f#chown_uploads=YESrom 20
connect_from_port_20=YES
ftp_data_port=20

###If Need any upload to be owned by user shukla
#chown_uploads=YES
#chown_username=shukla

###Want a user totally isolated & unpreviledge user
#nopriv_user=ftpsecure

###Enable ascii uploadation and download Read in depth before
#enabiling this recomended...
#ascii_upload_enable=YES
#ascii_download_enable=YES

###Disable -R option of remote user so to avoid excessive IO
#ls_recurse_enable=NO

###listen vsftpd runs in standalone mode & listens on IPv4 sockets
##To Listen on both socket you ned to run 2 config file of vsftpd
##Make sure comented below
#listen_ipv6=YES

###User based Permission
##IF 'YES' Disable access of user listed in file userlist_file
#userlist_enable=NO
#userlist_file=/etc/vsftp.user_list
##Oppose above IF below 'NO' Enable All User listed in userlist_file only .
#userlist_deny=YES

#### IF Load another config dir same as vsftpd
#user_config_dir=/home/shukla/myfiles


####================== Logs =======================#
###Eable logging of any upload download
#xferlog_enable=NO

###Want log to be saved on my location
#xferlog_file=/var/log/vsftpd.log

###Logs in fromat standard ftpd xferlog
#xferlog_std_format=YES


#### =================== Fine Tuning Part ==================##
###Enable disable TCP-Wrapper based security
#tcp_wrappers=NO
#listen_address=default none
#       test: pam modulle have to be preseent
#       ldd `which vaftpd` |grep pam

###Limit use of FTP Access =0 [unlimited] you can limit by int value
#max_clients=0
#max_per_ip=0
###Timeout, in seconds, for a remote client to establish connection
#accept_timeout=30
#connect_timeout=60

###Limit session below are default you can change as per req .
#idle_session_timeout=600
#data_connection_timeout=120

###Maximum data transfer rate permitted, in bytes per second
#local_max_rate=0
#local_umask=077
#anon_max_rate=0
#anon_umask=077

##NO IF want disallow the PORT method of obtaining a data connection.
#port_enable=YES
##Set to YES if you want to disable the PORT security  check that ensures that
##outgoing data connections can only connect to the client. Only enable if you
##know what you are doing!
#port_promiscuous=NO

# Faced any problem Feedback in above contact me
#========================  ===Scratch===============================#
#                                                     AND Many More .....................Linux is Endless                #
#========================== Hope you Liked IT ========================#
#                                                                                                  VSFTP -- BY Shirish Shukla #
#                                                                                                               RHC Engineer 2010 #
#                                                                                                          shirish.linux@gmail.com #
#                                                                                                         shirishlinux.blogspot.com #
#                             "Give Respect To Time One Day At Right Time, Time Will Respect You" #
#==================================================================#
#                          TRy Hard theres nothing that are un-achievable by HARDdd-WORKkk  #
#==================================================================#

telnet in linux

Telnet configuration in RHEL5
First check whether telnet-server rpm in installed,
# rpm -q telnet-server
telnet-server-0.17-38.el5
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.
============


Myne conclusion
1> off firewall
2> chkconfig krb5-telnet on
3> please not do not on krb5-telnet
4> service xinetd restart
5> do telnet my dude it will now work fine!

Have a niceva day!!!

:wq  :)


               
# Faced any problem Feedback in above contact me                                       
#===============================Scratch===============================#
#                                                            AND Many More .....................Linux is Endless                 #
#========================== Hope you Liked IT ===========================#
#                                                                                                       TELNET -- BY Shirish Shukla #
#                                                                                                                      RHC Engineer 2010 #
#                                                                                                                 shirish.linux@gmail.com #
#                                                                                                               shirishlinux.blogspot.com #
#                                      "Give Respect To Time One Day At Right Time, Time Will Respect You" #
#===================================================================#
# TRy Hard theres nothing that are un-achievable by HARDdd-WORKkk     #
#=====================================================================#

tar,zip,bzip,bzip2 linux commands

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

==> tar
tar -cvf file.tar <source_files>         ----> 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 <source_file>    ----> compress
tar -Zxvf file.tar.Z                 ----> uncompress

compress file.tar
uncompress file.tar.Z

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

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

gzip file.tar
gunzip file.tar.gz
           

==> bzip2 & bunzip2
tar -jcvf file.tar.bz2 <source_name>  ----> bziped
tar -jxvf file.tar.bz2              ----> bunziped

bzip2 file.tar.bzip2 <source_name> 
bunzip2 file.tar.bzip2

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

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


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

##### zip .
1. zip files
# zip myzip  file1 file2 file3  <--o/p file is myfile.zip

2. zip a directory
# zip -r myzip1 mydr/    <-o/p file  myzip1.zip

3. List zipped contents and sized compressed etc..
# unzip -l myzip1.zip OR
# unzip -v myzip1.zip

4. Add a file in zip archive .
# zip myzip1.zip  newfile.cf

5. get size of ziped contents .
















# Faced any problem Feedback in above contact me
#===============================Scratch===============================#
# AND Many More .....................Linux is Endless                 #
#========================== Hope you Liked IT ========================#
#                        CMNDS(tar,bzip, bzip2.. -- BY Shirish Shukla #
#                                                   RHC Engineer 2010 #
#                                             shirish.linux@gmail.com #
#                                           shirishlinux.blogspot.com #
# "Give Respect To Time One Day At Right Time, Time Will Respect You" #
#=====================================================================#
# TRy Hard theres nothing that are un-achievable by HARDdd-WORKkk     #
#=====================================================================#

nmap command magic linux

nmap : Network exploration tool and security / port scanner
   Display open port number and protocol, service name, and state
  
   Syantax:
   nmap options hostnames/IPaddresses/networks
   -A, to enable OS and version detection(A detailed scan)
   -T4 for faster execuation of cmd
   -iL InputFileName contain list of IPS/hostname etc..
   --excludefile ExcludeFileName
   -sL: List Scan
   -sP: Ping Scan
   -pPortNo  EG: -P22 etc...
   -e eth0 : scan particulat interface
   --packet-trace  IP/Hostname : Show all packets sent and received
   --iflist : list all active links info MAc add etc..
  
If system ports have been changed for a particular application service
and is open then you can trace it
EG:
server1.example.com : vi /etc/ssh/sshd_conf
#Port 22  --> Port 1022 (For ssh changed to 22 to 1022 )

Now scan from system1.example.com:
# nmap -v -A server1.example.com  (An detailed OS scan)

1022/tcp open  ssh         OpenSSH 4.3 (protocol 2.0)
  
OR:
#nmap -T4 -sV server1.example.com (An detailed open port scan)

Examples:  
# nmap -T4 -p22 192.168.8.10          :Scan for port 22
# nmap 192.168.8.10 |grep -i tcp      :Opend TCP ports

# nmap -sP 192.168.8.*                :Which hosts in my subnet
eg. output:
Host ntp.example.com (192.168.8.7) appears to be up.
MAC Address: 00:0C:29:3C:4D:66 (VMware)
Host ns1.example.com (192.168.8.8) appears to be up.
MAC Address: 00:0C:29:3C:4D:66 (VMware)
Host mail.example.com (192.168.8.9) appears to be up.
MAC Address: 00:0C:29:3C:4D:66 (VMware)
Host server.example.com (192.168.8.10) appears to be up.
MAC Address: 00:0C:29:3C:4D:66 (VMware)
Host client.example.com (192.168.8.20) appears to be up.
Nmap finished: 256 IP addresses (5 hosts up) scanned in 9.375 seconds


# Faced any problem Feedback in above contact me
#===============================Scratch===============================#
# AND Many More .....................Linux is Endless                 #
#========================== Hope you Liked IT ========================#
#                                       nmap cmd -- BY Shirish Shukla #
#                                                   RHC Engineer 2010 #
#                                             shirish.linux@gmail.com #
#                                           shirishlinux.blogspot.com #
# "Give Respect To Time One Day At Right Time, Time Will Respect You" #
#=====================================================================#
# TRy Hard theres nothing that are un-achievable by HARDdd-WORKkk     #
#=====================================================================#

fg and bg command linux

=================== foreground background processes ====================
run process in backgrounbd foreground

commands :
1> (sleep 282828282 ) &                < - process 1
1> (sleep 9090909090 ) &              < - process 2

# jobs
# fg %1    ^Z       stop
# bg %1         start again in bg
# fg  %1    start in fg
# kill %1     terminate %1  or
# fg %1     ^C    to terminitae command

# Faced any problem Feedback in above contact me
#===============================Scratch===============================#
#                                                            AND Many More .....................Linux is Endless                 #
#========================== Hope you Liked IT ===========================#
#                                                                                                          FG-BG -- BY Shirish Shukla #
#                                                                                                                       RHC Engineer 2010 #
#                                                                                                                  shirish.linux@gmail.com #
#                                                                                                                 shirishlinux.blogspot.com #
#                                       " Give Respect To Time One Day At Right Time, Time Will Respect You" #
#===================================================================#
#                                      TRy Hard theres nothing that are un-achievable by HARDdd-WORKkk     #
#=================================================================== #

Tuesday, January 4, 2011

remove spaces fom filename

Having a space in the file name is never a good idea.
If you are in need to remove space from all file names
within your current directory you can use a following
command to do so:

ls | grep " " | while read -r f; do mv -i "$f" `echo $f | tr -d ' '`; done

In case that you wich to substitute space within a file
name to underscore ( or any other character ) use a following
command to do so:

ls | grep " " | while read -r f; do mv "$f" `echo $f | tr ' ' '_'`; done

How it works? ls and grep will feed while loop with all files within
a current working directory which contain a space in their file name.
In the body of the while loop we will next execute mv command a translate
it file destination with tr command. Make sure to keep -i option enabled
when using mv command to avoid accidentally overwrite files.

scripting sort hand


## Count the occurrences of a specific word in a .txt file in bash shell.
# tr -s ' ' '\n' < myfile.txt | grep -c 'searchword'
# cat mydr/myfiles-1-* |grep -c "searchtest"

## Find Days in months(eg apr:30 days)

# tmnth=$(cal 4 2010 | egrep -v '[A-Za-z]' | wc -w)  

## gunzip & untar in 1 cmd
# cat May-2010.tar.gz | gunzip -d | tar -xvf -               
##
# gzcat test123.tar.gz | tar -xvf -
##
# tar -zcvf   May-2010.tar.gz


## Check is your variable is numeric or not?
# cat  isnum.sh
#!/bin/bash
# Script to test variable is numeric or not
# Shirish Shukla
# Pass arg1 as number
a1=$1
a=$(echo "$a1" |awk '{if($1 > 0) print $1; else print $1"*-1"}'| bc)
b=$(echo "scale=2;$a2/$a2 + 1" | bc -l 2>/dev/null)
if [[ $b > 1 ]]
then
    echo "$a1 is Numeric"
else
    echo "$a1 is Non Numeric"
fi

## Output
# sh isnum.sh 12
12 is Non Numeric

# sh isnum.sh 12-5+4
12-5+4 is Non Numeric

# sh isnum.sh abc
abc is Non Numeric

# sh isnum.sh shirish-shukla
shirish-shukla is Non Numeric

IFS bash variable

The IFS internal variable
One way around this problem is to change Bash's internal
IFS (Internal Field Separator) variable so that it splits
fields by something other than the default whitespace
(space, tab, newline), in this case, a comma.

eg:
#!/bin/bash
IFS=$',' # seperate input by comma
vals='/mnt,/var/lib/vmware/Virtual Machines,/dev,/proc,/sys,/tmp,/usr/portage,/var/tmp'
for i in $vals; do echo $i; done
unset IFS

with unset IFS, so that it returns to its default value.
This will avoid any potential problems that could arise
in the rest of your script.


$IFS (internal field separator) : This variable determines how Bash recognizes fields,
or word boundaries, when it interprets character strings.
$IFS defaults to whitespace (space, tab, and newline), but may be changed, for example,
to parse a comma-separated data file. Note that $* uses the first character held in $IFS.


Fields seperator:
echo $datapath | awk -F "/" '{print $NF}'|awk 'BEGIN { FS="[- . ]" } {print $1}'

The logic is that the intialisation
BEGIN{FS="[ ]|[;]|[,]"} ; OFS=","}
sets up the Field Separator variable FS as a regular expression which matches any one of " " ";" ","
and the Output Field Separator OFS to be ",".

 

Followers

Pls LIKE my Story !!!