Sunday, 27 April 2014

What is Rescue Mode?

What is Rescue Mode?                                                                                                                                
Rescue mode is a term used to describe a method of booting a small Linux environment completely from diskettes.
What follows in this section may help you recover from a problem at some point. A copy of these instructions is also available as rescue.txt on your Red Hat Linux 6.0 CD-ROM.
As the name implies, rescue mode is there to rescue you from something. In normal operation, your Red Hat Linux system uses files located on your system's hard drive to do everything -- run programs, store your files, and more.
However, there may be times when you are unable to get Linux running completely enough to access its files on your system's hard drive. By using rescue mode, it's possible to access the files stored on your system's hard drive, even if you can't actually run Linux from that hard drive.
Normally, you'll need to get into rescue mode for one of two reasons:

  • You are unable to boot Linux, and you'd like to fix it.

  • You are having hardware or software problems, and you want to get a few important files off your system's hard drive.
  • Let's take a closer look at each these scenarios.
    Unable to boot Linux
    -- Many times this is caused by the installation of another operating system after you've installed Red Hat Linux. Some other operating systems assume that you have no other operating systems on your computer, and overwrite the Master Boot Record (or MBR) that originally contained the LILO bootloader. If LILO is overwritten in this manner, you're out of luck -- unless you can get into rescue mode.
    Hardware/software problems
    -- There can be as many different situations under this category as there are systems running Linux. Things like failing hard drives and forgetting to run LILO after building a new kernel are just two things than can keep you from booting Red Hat Linux. If you can get into rescue mode, you might be able to resolve the problem -- or at least get copies of your most important files. What do you need to get into rescue mode?
    To get into rescue mode, you'll need a rescue disk set. These are two diskettes that contain the files necessary to boot into rescue mode.
    If you elected to make a boot diskette while you were installing Red Hat Linux, you're halfway there! The first diskette in a rescue disk set is this boot diskette.
    Now on to the second diskette...
    The second diskette is called the rescue diskette. It is produced by writing an image file onto a diskette. The image file is called rescue.img, and is located in the images directory on the first Red Hat Linux CD-ROM.
    To gain access to this file, you'll first need to mount your Red Hat Linux CD-ROM.
    Start by inserting the CD-ROM in your system's CD-ROM drive. You'll need to do this while logged in as root.
    Type the following command:
    mkdir /mnt/cdrom
    Now, type:
    mount /dev/cdrom /mnt/cdrom
    You may get an error message from the first command saying that the file exists. That's fine; we just want to make sure that there is a /mnt/cdrom directory on your system. The second command should issue an informational message that /dev/cdrom is being mounted read-only.
    Please Note: Some systems may not recognize /dev/cdrom. If this is your case, you'll have to replace /dev/cdrom in the command with the appropriate device name for your CD-ROM.
    Next, issue the following command (again, while logged in as root):
    cd /mnt/cdrom/images
    then type:
    ls
    to list the contents of the images directory.
    You should see a file named rescue.img. This is the rescue diskette image file. Next, put a diskette in your first diskette drive, and enter the following command:
    dd if=rescue.img of=/dev/fd0 bs=1440k
    Your system's diskette drive should start writing to the diskette. After a minute or so, the dd command will complete, and you'll get your shell prompt back.
    Wait for your diskette drive's access light to go out, and that's it!
    You now have a rescue disk set. Label this diskette something like ``Red Hat Linux 6.0 rescue diskette'' and store it someplace safe.
    Let's hope you never have to use it.
    If you should ever need to use rescue mode, here's how.
    Boot your system with the boot diskette in the first diskette drive. At the LILO Boot: prompt, enter the word rescue. You will see the usual kernel messages as the Linux kernel starts up.
    Eventually, it will ask you to insert the next diskette, and press [Enter]. Remove the boot diskette, insert the rescue diskette, and press [Enter].
    The rescue diskette will be read into memory. After a minute or so, you should see the shell prompt. That's it -- you're in rescue mode!
    Now what?
    When it comes to rescue mode, that's a bit like asking, ``how long is a piece of string?'' What you require depends a great deal on what your system's problem is, your level of Linux expertise, and several variables we haven't even thought of yet. So we can't give you explicit instructions.
    But we can tell you what programs you have access to while in rescue mode.
    Here's the list:
    badblocks bash bzip2 cat chmod chroot cp cpio dd e2fsck fdisk grep gunzip gzip head ifconfig init ln ls lsmod mkdir mke2fs mknod mount mt mv open pico ping ps restore rm route rpm sed sh swapoff swapon sync tac tail tar traceroute umount vi vim
    You're likely to be unfamiliar with most, if not all of these commands. However, the commands do have man pages. Once you begin to feel more comfortable with commands, you should consider familiarizing yourself them through the man pages. (You may not have that luxury if you have to use these commands...)
    You've worked with some pretty useful commands for your Red Hat Linux system so far. You may not have known much about where those files were in the directory, however.
    For more information about the Linux filesystem, including navigation and working with other useful commands to help you understand your system, turn to the next chapter




    Linux Installation Steps


    RHEL 6 Installation Steps

    RHEL 6 Installation Steps.

    To learn Red Hat Enterprise Linux 6 first of all you have to know about the installation process and how to install the all new Red Hat Enterprise Linux 6. Here I will explain the step-by-step process of installation of RHEL 6.

    Installation of RHEL 6 is one of the objectives of RHCSA and RHCE certification from Red Hat. It is directed that one should know at least the graphical based installation of RHEL 6.
    First of all you have to obtain the DVD/CDs’ or the RHEL6 DVD.iso.
    There are several methods of installing RHEL 6 like: installation from DVD, installation form Hard Drive, Network Installation, Installing via NFS, FTP or HTTP. Steps followed in all the process are same except the media selection from which you will install RHEL 6. I will explain the installation from Local Hard Drive using the Rescue disk (Which can also downloaded from Red Hat website), and the RHEL 6.iso.
    Step 1. Extract the folder “images” from the RHEL 6 DVD. Since the image folder contains the product.img file which is used to start the installation and bring up the anaconda to start installation process.
    Step 2. Make a folder from where you want to install Red Hat Enterprise Linux 6 and in it paste the “RHEL 6 DVD.iso” file and the “images folder “ which you have extracted in the above step.
    I had created the folder in the E: drive of my computer like E:\RHEL6\ and paste the “RHEL 6 DVD.iso” file and the “images folder “ in it. But at the time of installation you have to give the complete path of the “.iso“ image like the hard disk and partition number like “/dev/sdb5/RHEL6/”.
    Step 3. Reboot the System and boot form the rescue disk by selecting boot form CD/DVD from the boot menu. After booting form rescue disk you will see the graphical boot menu.
    Step 4. There are four options in the menu : 1. Install or upgrade existing systems, 2. Install system with basic video drivers,3. Rescue installed system, 4. Boot from local drive.
    Select  the first optionInstall or Upgrade Existing System”.

    Source

    Step5.  Select language and click ok.

    Step 6. Select installation method : Local CD/DVD and click ok.
    RHCSA Objectives
    Step 7. Select partition and determine full path of the folder containing RHEL 6 DVD.iso. In my case the partition is “/dev/sdb5” and the path is “/Operating System/RHEL6/ISO”.

    Step 8. Welcome screen appears click next to continue.

    Step 9. Select Installation Language and Keyboard Type.
    Step 10. Select type of storage device. If you are confused in between select the Basic Storage Devices.
    Step 11. Time Zone Configuration window. Select time and click next to continue.
    Step 12. Set Root password and click next.
    Step 13. Assign storage device from the box on the left side and send it to the box in right. I have to install RHEL 6 in my 80 Gb sata HDD so I seletct the second HDD and move it to right box (Install Target Devices).
    Step 14. In the next step you have to select how you want to use your HDD to install RHEL 6. I prefer to make file systems manually, so I selected create custom layout.
    Select the free space in the HDD (and if no free space is there you have to delete some partitions to create free space.) and click on Create. A dialog box open select the Standard Partition and click next.
    Red Hat Enterprise Linux 6 Installation
    Give the mount point select size and make it primary or extended as per your requirements.
    RHCSA Objectives
    Make at least three partitions :root (/), boot (/boot) and SWAP.
    Take reference from the table given below to make partitions:
    Click next to continue.
    Click on write changes to disk to make changes. Or go back to edit layout.http://linux-rhcsa-rhce.blogspot.com
    Step 15. Install Grub Boot Loader.
    I have my PC dual boot Windows 7 and RHEL so I make an entry of my windows 7 OS and select it to boot by default.
    Step 16. Installation Server type. Select an option according to your requirements or just select Basic Server and Choose Now to select packages.
    Step 17. Wait while packages install.
    Step 18.  Installation Complete .remove bootable media form DC/DVD drive and restart your system.

    Tuesday, 15 April 2014

    Uptime

    uptime

    $ uptime
     21:54:11 up 13 days,  4:29,  1 user,  load average: 0.21, 0.21, 0.12
    • The current time (21:54:11)
    • How long the system has been running (up 13 days)
    • How many users are currently logged on (1 user)
    • The system load averages for the past 1, 5, and 15 minutes (0.21, 0.21, 0.12)

    SSH:See other users SSH sessions in Linux

    Are wondering what your users are doing in their SSH sessions? Do you want to see, whats happening there?

    Try the following:
    # cat /dev/vcs1
    This will show you what happenening on the first console. If someone is typing, you’ll be able to get an output of their keystrokes.

    Note: You should have "root" access for this.

    Replace /dev/vcs1 with /dev/vcs2 or /dev/vcs3 and so on for other consoles.

    Clean reboot of hung Linux server

    In day to day system administration job, you may come across the situation that your Linux server is hung or freeze and your system is not responding even  for Ctrl+Alt+Del in console itself and you must need to do a hard reboot by pressing reset button. As everyone know, the hard reboots is not good and can crash the File systems. so what to do now?

    There is a way in Linux,

    Hold down the Right Alt and SysRq keys and press this sequence:

      R E I S U B

    This will cleanly unmount the drives, terminate the processes and nicely reboot your machine.

    of course, To get this worked, you need to “enable” this feature on the running kernel first !

    On 2.6 kernel

    echo 1 > /proc/sys/kernel/sysrq

    This will do the trick.

    In Some distributions, you may have a way to enable this feature at boot time. 

    On Fedora and RHEL, edit the file /etc/sysctl.conf, and change the line kernel.sysrq = 0 tokernel.sysrq = 1

    Configuring SAMBA server in Linux


    SAMBA(SMB server) is a file sharing server. Which is used to share files between Windows, Linux and Unix Systems. SMB(Server Message Block) is a proprietary protocol which is developed by Microsoft


    This article explains how to install and configure SAMBA in Linux.


    Step 1: Create a directory where you want to keep data and share with other remote systems(either windows/Linux/UNIX).
    #mkdir /sales


    Step 2 : Installing Samba server
    #yum install samba*


    Step 3 : Now we have to configure the samba server. Edit the main configuration file (/etc/samba/smb.conf)


    specify the work group where this server belongs 


    #vi /etc/samba/smb.conf


    search for workgroup word and specify your work group name


    workgroup = SALES-DEPT.


    Why we require this workgroup? 
    When windows user try to access any network resource they first try to access my network places and then search for workgroup then to server. So definitly we have to specify this workgroup entry in smb.conf file.


    Now we have to give a name to this samba server, search for "server string" with out quotes then provide the samba server name (here that name is sales-share)


    server string = sales-share


    Now specify the share details, which folder you want to share. To whom you want to share? Goto last line of the smb.conf file specify your shared folder details as follows.


    [sales-dir]
    comment = "This is the Sales data which is shared with my windows users"
    path = /sales
    valid users = user1 user2
    writable = no
    privatable = no
    browsable =yes. 


    After giving this seven entries just save and exit the file.


    Let me explain each and every thing what we used here.
    a.[sales-dir] -- This is the share name, so when ever any user accessed the samba server through network this will be visible as folder shared.
    b.comment -- This is just a comment, which will help to know what is this share for.
    c.path -- This is used to specify which folder on my samba machine to share.
    d.valid users -- This will specifies which user is having access on this folder.
    e.writable -- This will specify whether users are able to write or not, In this example the can just read the folder and copy.
    f.Privatable -- This will indicate whether this folder is private or not.
    g.browsable -- This is used to specify whether the folder content is browsable or not.


    You can specify the Read-Only and Write Access to specified using keywords "read only" and "write list"


    example: write list = user1, user3
                  read only = user2, user4


    Step 4 : Now create passwords for the users who are going to access this samba share remotely.
    #smbpasswd -a user1
    #smbpasswd -a user2


    generate the passwords for this two users and this passwords will be stored in /etc/samba/smbpasswd


    Step 5 : check for the syntax for your smb.conf file if in case you did any mistake
    #testparm


    Step 6 : Restart the samba service
    #service smb restart


    Step 7 : Permanently on the smb service, So that after rebooting the system too our server will start running.
    #chkconfig smb on


    step 8: change the selinux security context for the shared folder
    #chcon -Rt samba_share_t /sales


    Thats all. You have done configuring the samba server.

    Linux Boot Sequence

    1. When the computer is switched on, it automatically invokes BIOS [a ROM chip embedded in the motherboard].
    2. The BIOS will start the processor and perform a POST [power on self test] to check whether the connected device are ready to use and are working properly.
    3. Once the POST is completes BIOS will jump to a specified location in the RAM and check for the booting device. The boot sector is always the first sector of the hard disk and BIOS will load the MBR into the memory.
    4. Here the boot loader takes the control of the booting process.
    5. LILO or GRUB is the boot loaders commonly available. It will help the user to select various boot options.
    6. Depending on the boot option selected the kernel is loaded.
    7. After kernel is loaded the kernel will take the control of the booting process
    8. initrd will be loaded which contains drivers to detect hardware (Initialization of RAM Disk)
    9. Then it will initialize all the hardware including I/O processors etc.
    10. Kernel then mounts the root partition as read-only
    11. INIT is loaded.
    12. INIT will mount the root partition and other partitions as read/write and checks for file system errors.
    13. Sets the System Clock, hostname etc..
    14. Based on the Runlevel, it will load the services and runs the startup scripts (Network, cups, nfs, etc.)
    15. Finally it runs the rc.local script.
    16. Now the login prompt will appear.

    Monday, 14 April 2014

    AWK usage

    http://www.tutorialspoint.com/listtutorial/Awk-Command-Examples-in-Unix/4117

    Performance and Monitoring Tool
     Uptime,w,who,whoami,free,top,iostat,vmstat,tcpdump,netstat,traceroute,

    /etc/fstab
    ILO
    Kernel Tuning
    NIC Bonding

    Patch Management
    Steps
    1.Need to take backup of config files before start patching or reboot or any changes in configuration
    such as
    df -hP
    fdisk -l
    grub.conf
    /etc/fstab
    ifconfig
    pvs,
    vgs
    cat /proc/net/bonding/bond0

    2.Need to check ILO console whether working properly
    3. Should check dmesg file
    4. Request to Backup team (TSM, Netbackup) to take full system backup.
    5.Download the required patches
    6.Using yum and update the patches
    7. In case server is not coming up after done the patch
          Need to roll back(revert)
          Restore

    Scan and Configure new LUNs on RHEL

    free=total-used
    total=total memory in the system
    Used=The memory currently in use/reserved by running process

    shared=Memory being shared by multiple process

    How much memory really being used
    used- (buffer+cached)

    How much memory is really free
    free+(buffer+cached)

    How to find processor
    uname -r
    grep flages /proc/cpuinfo
      flag lm-long mode CPU 64-bit
      Real mode -16 bit
      Protected mode -32-bit

    32 Bit- i386,i586,i686
    64 Bit - x86_64

    Symbolic link
    Hard Link
    Inode

    Special Permissions
    Sticky bit
    SUID,SGID

    Cron jobs

    Repairing File System

    File Prevention

    File System Creation and Extend

    How to see File system status?

    Manage Linux group using gpasswd command

    Kickstart installation and Configuration

    Basic config, Installation Method, Boot loader option, Partition infm, N/w config, Authentication,Firewall config,Display config

    Remove GRUB Password



    Sunday, 6 April 2014

    Liting file permissions

    '==========================================================================
    '
    ' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0
    '
    ' NAME: Folder Permission
    '
    ' AUTHOR:  Abdelkader, Amine
    ' DATE  : 10/03/2006
    '
    ' COMMENT: Create a file with the name of the folder in HTML format
    '
    '==========================================================================
    Const ForReading = 1, ForWriting = 2, ForAppending = 8

    Const FullAccessMask = 2032127, ModifyAccessMask = 1245631, WriteAccessMask = 118009
    Const ROAccessMask = 1179817



    strComputer = "."
    sParentFolder = InputBox("Please Enter folder to gather information on", "Parent Folder")
    SParentFoldern=replace(sParentFolder,"\","")
    SParentFoldern=replace(sParentFoldern,":","")
    Set fso = CreateObject("Scripting.FileSystemObject")
    'File name Same As Folder Name without special Caracteres
    fullfilename=SParentFoldern&".html"
    'WScript.echo fullfilename

    Set fsOut = fso.OpenTextFile(fullfilename, ForAppending, True)

    On Error Resume Next

    fsOut.Writeline ("<html>"&vbCr&"<head>"&vbCr&"<title>File Permission For Folder under &"& SParentFoldern&"</title>"&vbCr&"</head>")

    strTableHead = "<table border=2 bordercolor='#000010' width='90%' id='Table1'>"
    fsOut.Writeline strTableHead
    fsOut.Writeline "<tr><td width='50%'>Folder</td>" & _
                    "<td width='50%'>User Name</td>"&_
                    "<td width='50%'>Permission</td></tr>"

    strTableFoot = "</table>"
                   
    fsOut.Close



    ShowSubFolders FSO.GetFolder(sParentFolder),fullfilename

    OutputFolderInfo sParentFolder, fullfilename

    Set fsOut = fso.OpenTextFile(fullfilename, ForAppending, True)
    fsOut.Writeline strTableFoot
    fsOut.Close
    MsgBox "Done "
    WScript.Quit

    Public Sub OutputFolderInfo(FolderName , sOutfile)

    Const FullAccessMask = 2032127, ModifyAccessMask = 1245631, WriteAccessMask = 1180095
    Const ROAccessMask = 1179817
    Const ForReading = 1, ForWriting = 2, ForAppending = 8

    strComputer = "."

    'Build the path to the folder because it requites 2 backslashes
    folderpath = Replace(FolderName, "\", "\\")

    objectpath = "winmgmts:Win32_LogicalFileSecuritySetting.path='" & folderpath & "'"

    'Get the security set for the object
    Set wmiFileSecSetting = GetObject(objectpath)

    'verify that the get was successful
    RetVal = wmiFileSecSetting.GetSecurityDescriptor(wmiSecurityDescriptor)
     If Err Then
         MsgBox ("GetSecurityDescriptor failed" & vbCrLf & Err.Number & vbCrLf & Err.Description)
         Err.Clear
     End If


    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\cimv2")
    Set colFolders = objWMIService.ExecQuery("SELECT * FROM Win32_Directory WHERE Name ='" & _
        folderpath & "'")
    For Each objFolder In colFolders
       
        ' Retrieve the DACL array of Win32_ACE objects.
        DACL = wmiSecurityDescriptor.DACL

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fsOut = fso.OpenTextFile(sOutfile, ForAppending, True)
       

        For Each wmiAce In DACL
        ' Get Win32_Trustee object from ACE
            Set Trustee = wmiAce.Trustee
            fsOut.Writeline "<tr><td width='50%'>"&objFolder.Name&"</td>" & _
                    "<td width='50%'>"&Trustee.Domain&"\"&Trustee.Name&"</td>"

            'fsOut.Write objFolder.Name & "," & Trustee.Domain & "\" & Trustee.Name & ","
            FoundAccessMask = False
            CustomAccessMask = Flase
            While Not FoundAccessMask And Not CustomAccessMask
                If wmiAce.AccessMask = FullAccessMask Then
                    AccessType = "Full Control"
                    FoundAccessMask = True
                End If
                If wmiAce.AccessMask = ModifyAccessMask Then
                    AccessType = "Modify"
                    FoundAccessMask = True
                End If
                If wmiAce.AccessMask = WriteAccessMask Then
                    AccessType = "Read/Write Control"
                    FoundAccessMask = True
                End If
                If wmiAce.AccessMask = ROAccessMask Then
                    AccessType = "Read Only"
                    FoundAccessMask = True
                Else
                    CustomAccessMask = True
                End If
            Wend
         
            If FoundAccessMask Then
                'fsOut.Writeline AccessType
                fsOut.Writeline "<td width='50%'>"&AccessType&"</td></tr>"
            Else
                 fsOut.Writeline "<td width='50%'>Custom</td></tr>"
                'fsOut.Writeline "Custom"
            End If
         
        Next

        Set fsOut = Nothing
        Set fso = Nothing

    Next

    Set fsOut = Nothing
    Set fso = Nothing

    end Sub
    Sub ShowSubFolders (Folder,fname)
    On Error Resume Next
        For Each Subfolder in Folder.SubFolders
            Call OutputFolderInfo(Subfolder.Path,fname)
            Wscript.Echo Subfolder.Path
            call ShowSubFolders (Subfolder,fname)
        Next
    End Sub
    http://stackoverflow.com/questions/15995345/vbscript-for-listing-explicit-rights

    https://secure.marumoto.us/motowiki61/tiki-index.php?page=Reading+NTFS+and+Share+Permissions+with+VBScript+and+.Net&amp;structure=ITDocRoot&amp;page_ref_id=221

    https://secure.marumoto.us/motowiki61/tiki-index.php?page=Users+and+Groups&amp;structure=ITDocRoot&amp;page_ref_id=207

    http://www.indented.co.uk/2008/10/22/powershell-get-acl-listing-explicit-rights/

    http://gallery.technet.microsoft.com/scriptcenter/7d96b296-77a0-4d17-9ab8-ca929b88e04a

    http://www.indented.co.uk/2009/10/02/get-dsacl/

    Wednesday, 2 April 2014

    Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
    Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
    Part I The Linux Command Line
    Chapter 1: Starting with Linux Shells ...............................................................................................3
    Chapter 2: Getting to the Shell .......................................................................................................25
    Chapter 3: Basic bash Shell Commands .........................................................................................59
    Chapter 4: More bash Shell Commands .........................................................................................91
    Chapter 5: Using Linux Environment Variables ..........................................................................123
    Chapter 6: Understanding Linux File Permissions .......................................................................147
    Chapter 7: Working with Editors .................................................................................................171
    Part II Shell Scripting Basics
    Chapter 8: Basic Script Building ...................................................................................................201
    Chapter 9: Using Structured Commands .....................................................................................229
    Chapter 10: More Structured Commands ....................................................................................255
    Chapter 11: Handling User Input .................................................................................................285
    Chapter 12: Presenting Data .........................................................................................................313
    Chapter 13: Script Control ...........................................................................................................335
    Part III Advanced Shell Scripting
    Chapter 14: Creating Functions ....................................................................................................363
    Chapter 15: Adding Color to Scripts ............................................................................................385
    Chapter 16: Introducing sed and gawk ........................................................................................419
    Chapter 17: Regular Expressions ..................................................................................................447
    Chapter 18: Advanced sed ............................................................................................................473
    Chapter 19: Advanced gawk .........................................................................................................501
    Part IV Alternative Linux Shells
    Chapter 20: The ash Shell .............................................................................................................533
    Chapter 21: The tcsh Shell ...........................................................................................................557
    Chapter 22: The Korn Shell ..........................................................................................................587
    Chapter 23: The zsh Shell .............................................................................................................611
    ix
    Contents at a Glance
    Part V Advanced Topics
    Chapter 24: Using a Database .......................................................................................................639
    Chapter 25: Using the Web ..........................................................................................................673
    Chapter 26: Using E-Mail .............................................................................................................701
    Chapter 27: Shell Scripts for Administrators ...............................................................................725
    Appendix A: Quick Guide to bash Commands ...........................................................................749
    Appendix B: Quick Guide to sed and gawk ................................................................................759
    Appendix C: Comparing Shells .....................................................................................................771
    Index .............................................................................................................................................777
    x
    Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
    Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
    Part I The Linux Command Line
    Chapter1: StartingwithLinux Shells . . . . . . . . . . . . . . . . . . . . 3
    What Is Linux? ........................................................................................................................3
    Looking into the Linux kernel ......................................................................................4
    The GNU utilities ........................................................................................................12
    The Linux desktop environment ................................................................................14
    Linux Distributions ................................................................................................................20
    Core Linux distributions .............................................................................................21
    Specialized Linux distributions ...................................................................................22
    The Linux LiveCD .......................................................................................................23
    Summary ...............................................................................................................................24
    Chapter2:Getting tothe Shell . . . . . . . . . . . . . . . . . . . . . . . 25
    Terminal Emulation ...............................................................................................................25
    Graphics capabilities ...................................................................................................27
    The keyboard ...............................................................................................................30
    The terminfo Database ..........................................................................................................31
    The Linux Console ................................................................................................................35
    The xterm Terminal ..............................................................................................................36
    Command line parameters ..........................................................................................37
    The xterm main menu ................................................................................................38
    The VT options menu .................................................................................................41
    The VT fonts menu .....................................................................................................43
    The Konsole Terminal ...........................................................................................................45
    Command line parameters ..........................................................................................45
    Sessions ........................................................................................................................45
    The menu bar ..............................................................................................................48
    The GNOME Terminal ..........................................................................................................52
    The command line parameters ...................................................................................52
    Tabs .............................................................................................................................53
    The menu bar ..............................................................................................................54
    Summary ...............................................................................................................................58
    xi
    Contents
    Chapter3:BasicbashShellCommands . . . . . . . . . . . . . . . . . . 59
    Starting the Shell ...................................................................................................................59
    The Shell Prompt ...................................................................................................................60
    The bash Manual ...................................................................................................................63
    Filesystem Navigation ............................................................................................................64
    The Linux filesystem ...................................................................................................64
    Traversing directories ..................................................................................................66
    File and Directory Listing .....................................................................................................69
    Basic listing ..................................................................................................................69
    Modifying the information presented .........................................................................71
    The complete parameter list .......................................................................................72
    Filtering listing output ................................................................................................74
    File Handling .........................................................................................................................75
    Creating files ................................................................................................................75
    Copying files ................................................................................................................76
    Linking files .................................................................................................................79
    Renaming files .............................................................................................................80
    Deleting files ................................................................................................................81
    Directory Handling ................................................................................................................82
    Creating directories .....................................................................................................82
    Deleting directories .....................................................................................................82
    Viewing File Contents ...........................................................................................................83
    Viewing file statistics ...................................................................................................84
    Viewing the file type ...................................................................................................84
    Viewing the whole file ................................................................................................85
    Viewing parts of a file .................................................................................................89
    Summary ...............................................................................................................................90
    Chapter4:MorebashShellCommands . . . . . . . . . . . . . . . . . . 91
    Monitoring Programs .............................................................................................................91
    Peeking at the processes .............................................................................................91
    Real-time process monitoring .....................................................................................98
    Stopping processes ....................................................................................................101
    Monitoring Disk Space ........................................................................................................104
    Mounting media ........................................................................................................104
    Using the df command .............................................................................................108
    Using the du command ............................................................................................109
    Working with Data Files .....................................................................................................110
    Sorting data ...............................................................................................................110
    Searching for data .....................................................................................................114
    Compressing data ......................................................................................................116
    Archiving data ...........................................................................................................120
    Summary ..............................................................................................................................121
    xii
    Contents
    Chapter5:Using Linux EnvironmentVariables . . . . . . . . . . . . . . 123
    What Are Environment Variables? ......................................................................................123
    Global environment variables ...................................................................................124
    Local environment variables .....................................................................................125
    Setting Environment Variables ............................................................................................127
    Setting local environment variables ..........................................................................127
    Setting global environment variables ........................................................................129
    Removing Environment Variables .......................................................................................129
    Default Shell Environment Variables ..................................................................................130
    Setting the PATH Environment Variable ............................................................................134
    Locating System Environment Variables ............................................................................135
    Login shell .................................................................................................................136
    Interactive shell .........................................................................................................139
    Non-interactive shell .................................................................................................141
    Variable Arrays ....................................................................................................................142
    Using Command Aliases .....................................................................................................143
    Summary ..............................................................................................................................144
    Chapter6:UnderstandingLinux FilePermissions . . . . . . . . . . . . . 147
    Linux Security .....................................................................................................................147
    The /etc/passwd file ...................................................................................................148
    The /etc/shadow file ..................................................................................................150
    Adding a new user ....................................................................................................150
    Removing a user ........................................................................................................153
    Modifying a user .......................................................................................................154
    Using Linux Groups ............................................................................................................157
    The /etc/group file .....................................................................................................157
    Creating new groups .................................................................................................158
    Modifying groups ......................................................................................................159
    Decoding File Permissions ..................................................................................................160
    Using file permission symbols ..................................................................................160
    Default file permissions .............................................................................................161
    Changing Security Settings .................................................................................................163
    Changing permissions ...............................................................................................163
    Changing ownership .................................................................................................165
    Sharing Files ........................................................................................................................166
    Summary ..............................................................................................................................168
    Chapter7:WorkingwithEditors . . . . . . . . . . . . . . . . . . . . . 171
    The vim Editor ....................................................................................................................171
    The basics of vim ......................................................................................................172
    Editing data ...............................................................................................................174
    Copy and paste ..........................................................................................................174
    Search and substitute ................................................................................................175
    xiii
    Contents
    The emacs Editor .................................................................................................................176
    Using emacs on the console .....................................................................................176
    Using emacs in X Windows ......................................................................................181
    The KDE Family of Editors .................................................................................................183
    The KWrite editor .....................................................................................................183
    The Kate editor ..........................................................................................................189
    The GNOME Editor ............................................................................................................191
    Starting gedit .............................................................................................................191
    Basic gedit features ....................................................................................................192
    Setting preferences ....................................................................................................193
    Summary ..............................................................................................................................197
    Part II Shell Scripting Basics
    Chapter8:Basic ScriptBuilding . . . . . . . . . . . . . . . . . . . . . 201
    Using Multiple Commands .................................................................................................201
    Creating a Script File ..........................................................................................................202
    Displaying Messages ............................................................................................................204
    Using Variables ....................................................................................................................206
    Environment variables ...............................................................................................206
    User variables ............................................................................................................207
    The backtick ..............................................................................................................209
    Redirecting Input and Output ............................................................................................210
    Output redirection ....................................................................................................211
    Input redirection .......................................................................................................211
    Pipes ....................................................................................................................................213
    Performing Math ..................................................................................................................216
    The expr command ...................................................................................................216
    Using brackets ...........................................................................................................218
    A floating-point solution ...........................................................................................219
    Exiting the Script .................................................................................................................223
    Checking the exit status ............................................................................................223
    The exit command ....................................................................................................225
    Summary ..............................................................................................................................226
    Chapter9:Using StructuredCommands . . . . . . . . . . . . . . . . . 229
    Working with the if-then Statement ...................................................................................229
    The if-then-else Statement ..................................................................................................232
    Nesting ifs ............................................................................................................................232
    The test Command ..............................................................................................................233
    Numeric comparisons ...............................................................................................234
    String comparisons ....................................................................................................236
    File comparisons .......................................................................................................241
    Compound Condition Testing ............................................................................................249
    xiv
    Contents
    Advanced if-then Features ..................................................................................................250
    Using double parentheses .........................................................................................250
    Using double brackets ...............................................................................................251
    The case Command .............................................................................................................252
    Summary ..............................................................................................................................253
    Chapter10:More StructuredCommands . . . . . . . . . . . . . . . . . 255
    The for Command ...............................................................................................................255
    Reading values in a list .............................................................................................256
    Reading complex values in a list ..............................................................................257
    Reading a list from a variable ...................................................................................259
    Reading values from a command .............................................................................260
    Changing the field separator .....................................................................................261
    Reading a directory using wildcards .........................................................................262
    The C-Style for Command ..................................................................................................264
    The C language for command ..................................................................................264
    Using multiple variables ............................................................................................266
    The while Command ...........................................................................................................266
    Basic while format .....................................................................................................267
    Using multiple test commands .................................................................................268
    The until Command ............................................................................................................269
    Nesting Loops ......................................................................................................................271
    Looping on File Data ..........................................................................................................273
    Controlling the Loop ...........................................................................................................274
    The break command .................................................................................................275
    The continue Command ...........................................................................................278
    Processing the Output of a Loop ........................................................................................281
    Summary ..............................................................................................................................282
    Chapter11:HandlingUser Input . . . . . . . . . . . . . . . . . . . . . 285
    Command Line Parameters .................................................................................................285
    Reading parameters ...................................................................................................285
    Reading the program name .......................................................................................288
    Testing parameters ....................................................................................................289
    Special Parameter Variables .................................................................................................290
    Counting parameters .................................................................................................290
    Grabbing all the data ................................................................................................292
    Being Shifty ..........................................................................................................................293
    Working With Options .......................................................................................................295
    Finding your options ................................................................................................295
    Using the getopt command .......................................................................................299
    The more advanced getopts ......................................................................................302
    Standardizing Options .........................................................................................................304
    Getting User Input ..............................................................................................................305
    Basic reading ..............................................................................................................306
    xv
    Contents
    Timing out .................................................................................................................307
    Silent reading .............................................................................................................308
    Reading from a file ....................................................................................................309
    Summary ..............................................................................................................................310
    Chapter12:PresentingData . . . . . . . . . . . . . . . . . . . . . . . 313
    Understanding Input and Output .......................................................................................313
    Standard file descriptors ...........................................................................................314
    Redirecting errors ......................................................................................................316
    Redirecting Output in Scripts .............................................................................................318
    Temporary redirections .............................................................................................318
    Permanent redirections .............................................................................................319
    Redirecting Input in Scripts ................................................................................................320
    Creating Your Own Redirection ..........................................................................................321
    Creating output file descriptors ................................................................................321
    Redirecting file descriptors ........................................................................................322
    Creating input file descriptors ..................................................................................323
    Creating a read/write file descriptor .........................................................................323
    Closing file descriptors ..............................................................................................324
    Listing Open File Descriptors .............................................................................................326
    Suppressing Command Output ..........................................................................................328
    Using Temporary Files ........................................................................................................328
    Creating a local temporary file .................................................................................329
    Creating a temporary file in /tmp .............................................................................330
    Creating a temporary directory .................................................................................331
    Logging Messages ................................................................................................................332
    Summary ..............................................................................................................................333
    Chapter13: ScriptControl . . . . . . . . . . . . . . . . . . . . . . . . 335
    Handling Signals ..................................................................................................................335
    Linux signals revisited ...............................................................................................335
    Generating signals .....................................................................................................336
    Trapping signals ........................................................................................................338
    Trapping a script exit ................................................................................................339
    Removing a trap ........................................................................................................340
    Running Scripts in Background Mode ................................................................................341
    Running in the background ......................................................................................341
    Running multiple background jobs ..........................................................................342
    Exiting the terminal ..................................................................................................343
    Running Scripts without a Console ....................................................................................343
    Job Control ..........................................................................................................................344
    Viewing jobs ..............................................................................................................345
    Restarting stopped jobs .............................................................................................347
    Being Nice ............................................................................................................................348
    The nice command ....................................................................................................348
    xvi
    Contents
    The renice command ................................................................................................349
    Running Like Clockwork ....................................................................................................349
    Scheduling a job using the at command ..................................................................350
    Using the batch command ........................................................................................352
    Scheduling regular scripts .........................................................................................353
    Start At the Beginning .........................................................................................................355
    Starting your scripts at boot .....................................................................................355
    Starting with a new shell ..........................................................................................357
    Summary ..............................................................................................................................358
    Part III Advanced Shell Scripting
    Chapter14:Creating Functions . . . . . . . . . . . . . . . . . . . . . . 363
    Basic Script Functions .........................................................................................................363
    Creating a function ....................................................................................................364
    Using functions .........................................................................................................364
    Returning a Value ................................................................................................................366
    The default exit status ...............................................................................................367
    Using the return command .......................................................................................368
    Using function output ...............................................................................................369
    Using Variables in Functions ..............................................................................................369
    Passing parameters to a function ..............................................................................370
    Handling variables in a function ..............................................................................372
    Array Variables and Functions ............................................................................................375
    Passing arrays to functions ........................................................................................375
    Returning arrays from functions ...............................................................................376
    Function Recursion .............................................................................................................377
    Creating a Library ................................................................................................................379
    Using Functions on the Command Line ............................................................................381
    Creating functions on the command line .................................................................381
    Defining functions in the .bashrc file .......................................................................382
    Summary ..............................................................................................................................384
    Chapter15:AddingColor toScripts . . . . . . . . . . . . . . . . . . . 385
    Creating Text Menus ...........................................................................................................385
    Create the menu layout .............................................................................................386
    Create the menu functions ........................................................................................387
    Add the menu logic ..................................................................................................388
    Putting it all together ................................................................................................389
    Using the select command ........................................................................................390
    Adding Color .......................................................................................................................391
    The ANSI escape codes .............................................................................................392
    Displaying ANSI escape codes ..................................................................................393
    Using colors in scripts ...............................................................................................395
    xvii
    Contents
    Doing Windows ...................................................................................................................397
    The dialog package ....................................................................................................397
    The dialog options ....................................................................................................404
    Using the dialog command in a script .....................................................................407
    Getting Graphic ...................................................................................................................409
    The KDE environment ..............................................................................................409
    The GNOME environment ........................................................................................412
    Summary ..............................................................................................................................417
    Chapter16: Introducingsedandgawk . . . . . . . . . . . . . . . . . . 419
    Text Manipulation ...............................................................................................................419
    The sed editor ...........................................................................................................420
    The gawk program ....................................................................................................423
    The sed Editor Basics ..........................................................................................................430
    More substitution options .........................................................................................430
    Using addresses .........................................................................................................432
    Deleting lines .............................................................................................................434
    Inserting and appending text ....................................................................................436
    Changing lines ...........................................................................................................438
    The transform command ..........................................................................................439
    Printing revisited .......................................................................................................440
    Using files with sed ...................................................................................................442
    Summary ..............................................................................................................................445
    Chapter17:Regular Expressions . . . . . . . . . . . . . . . . . . . . . 447
    What Are Regular Expressions? ..........................................................................................447
    A definition ................................................................................................................447
    Types of regular expressions .....................................................................................448
    Defining BRE Patterns .........................................................................................................449
    Plain text ....................................................................................................................449
    Special characters ......................................................................................................451
    Anchor characters ......................................................................................................452
    The dot character ......................................................................................................454
    Character classes .......................................................................................................455
    Negating character classes .........................................................................................457
    Using ranges ..............................................................................................................458
    Special character classes ............................................................................................459
    The asterisk ...............................................................................................................460
    Extended Regular Expressions ............................................................................................461
    The question mark ....................................................................................................461
    The plus sign .............................................................................................................462
    Using braces ..............................................................................................................463
    The pipe symbol ........................................................................................................464
    Grouping expressions ................................................................................................465
    Regular Expressions in Action ............................................................................................466
    xviii
    Contents
    Counting directory files ............................................................................................466
    Validating a phone number ......................................................................................467
    Parsing an e-mail address .........................................................................................469
    Summary ..............................................................................................................................471
    Chapter18:Advancedsed . . . . . . . . . . . . . . . . . . . . . . . . 473
    Multiline Commands ...........................................................................................................473
    The next commands ..................................................................................................474
    The multiline delete command .................................................................................477
    The multiline print command ..................................................................................479
    The Hold Space ...................................................................................................................479
    Negating a Command .........................................................................................................481
    Changing the Flow ..............................................................................................................484
    Branching ...................................................................................................................484
    Testing .......................................................................................................................486
    Pattern Replacement ............................................................................................................487
    The ampersand ..........................................................................................................488
    Replacing individual words .......................................................................................488
    Using sed in Scripts ............................................................................................................489
    Using wrappers ..........................................................................................................489
    Redirecting sed output ..............................................................................................490
    Creating sed Utilities ...........................................................................................................491
    Double spacing lines .................................................................................................491
    Double spacing files that may have blanks ..............................................................492
    Numbering lines in a file ..........................................................................................493
    Printing last lines .......................................................................................................494
    Deleting lines .............................................................................................................495
    Removing HTML tags ................................................................................................497
    Summary ..............................................................................................................................499
    Chapter19:Advancedgawk . . . . . . . . . . . . . . . . . . . . . . . 501
    Using Variables ....................................................................................................................501
    Built-in variables ........................................................................................................502
    User-defined variables ...............................................................................................508
    Working with Arrays ...........................................................................................................510
    Defining array variables ............................................................................................510
    Iterating through array variables ...............................................................................511
    Deleting array variables .............................................................................................511
    Using Patterns ......................................................................................................................512
    Regular expressions ...................................................................................................512
    The matching operator ..............................................................................................513
    Mathematical expressions ..........................................................................................514
    Structured Commands ........................................................................................................514
    The if statement .........................................................................................................514
    The while statement ..................................................................................................516
    xix
    Contents
    The do-while statement ............................................................................................518
    The for statement ......................................................................................................518
    Formatted Printing ..............................................................................................................519
    Built-in Functions ................................................................................................................522
    Mathematical functions .............................................................................................522
    String functions .........................................................................................................524
    Time functions ..........................................................................................................526
    User-Defined Functions ......................................................................................................527
    Defining a function ...................................................................................................527
    Using your functions .................................................................................................528
    Creating a function library ........................................................................................528
    Summary ..............................................................................................................................529
    Part IV Alternative Linux Shells
    Chapter20:The ashShell . . . . . . . . . . . . . . . . . . . . . . . . 533
    What Is the ash Shell? .........................................................................................................533
    The Original ash Shell .........................................................................................................534
    The Original ash command line parameters ............................................................534
    The original ash built-in commands ........................................................................536
    The ash shell files ......................................................................................................539
    The dash Shell .....................................................................................................................540
    The dash command line parameters ........................................................................540
    The dash environment variables ...............................................................................540
    The dash built-in commands ....................................................................................544
    Scripting in dash .................................................................................................................549
    Creating ash and dash scripts ...................................................................................549
    Things that won’t work .............................................................................................549
    Summary ..............................................................................................................................555
    Chapter21:The tcshShell . . . . . . . . . . . . . . . . . . . . . . . . 557
    What Is the tcsh Shell? .......................................................................................................557
    The tcsh Shell Components ................................................................................................558
    The tcsh command line parameters .........................................................................558
    The tcsh files .............................................................................................................560
    The tcsh login files ....................................................................................................560
    Shell startup files .......................................................................................................561
    The logout files ..........................................................................................................562
    The tcsh environment variables ................................................................................563
    Shell variables ............................................................................................................563
    Environment variables ...............................................................................................569
    Setting variables in tcsh ............................................................................................572
    Using the set command ............................................................................................572
    Using the setenv command .......................................................................................573
    xx
    Contents
    The tcsh built-in commands .....................................................................................574
    Scripting in tcsh ..................................................................................................................577
    Working with variables .............................................................................................578
    Array variables ...........................................................................................................578
    Handling mathematical operations ...........................................................................578
    Structured commands ...............................................................................................578
    The if statements .......................................................................................................579
    The foreach statement ...............................................................................................582
    The while statement ..................................................................................................582
    The switch command ................................................................................................583
    Summary ..............................................................................................................................584
    Chapter22:TheKornShell . . . . . . . . . . . . . . . . . . . . . . . . 587
    The Korn Shell History .......................................................................................................587
    The Parts of the ksh93 Shell ...............................................................................................588
    Command line parameters ........................................................................................588
    Default files ................................................................................................................590
    Environment variables ...............................................................................................590
    Built-in commands ....................................................................................................597
    Scripting in the ksh93 Shell ...............................................................................................602
    Mathematical operations ...........................................................................................602
    Structured commands ...............................................................................................605
    Command redirection ...............................................................................................607
    Discipline functions ...................................................................................................608
    Summary ..............................................................................................................................609
    Chapter23:The zshShell . . . . . . . . . . . . . . . . . . . . . . . . 611
    History of the zsh Shell .......................................................................................................611
    Parts of the zsh Shell ...........................................................................................................612
    Shell options ..............................................................................................................612
    The zsh shell files ......................................................................................................615
    Environment variables ...............................................................................................619
    Built-in commands ....................................................................................................625
    Scripting with zsh ............................................................................................................... 631
    Mathematical operations ...........................................................................................631
    Structured commands ...............................................................................................633
    Functions ...................................................................................................................634
    Summary ..............................................................................................................................636
    Part V Advanced Topics
    Chapter24:Using aDatabase . . . . . . . . . . . . . . . . . . . . . . 639
    The MySQL Database ..........................................................................................................639
    Installing MySQL .......................................................................................................640
    Completing the MySQL configuration ......................................................................642
    xxi
    Contents
    The MySQL client interface ......................................................................................644
    Creating MySQL database objects ............................................................................649
    The PostgreSQL Database ...................................................................................................651
    Installing PostgreSQL ................................................................................................652
    The PostgreSQL command interface ........................................................................654
    Creating PostgreSQL database objects ......................................................................657
    Working with Tables ...........................................................................................................659
    Creating a table .........................................................................................................659
    Inserting and deleting data .......................................................................................661
    Querying data ............................................................................................................663
    Using the Database in Your Scripts ....................................................................................664
    Connecting to the databases .....................................................................................664
    Sending commands to the server .............................................................................666
    Formatting data .........................................................................................................670
    Summary ..............................................................................................................................671
    Chapter25:Using theWeb . . . . . . . . . . . . . . . . . . . . . . . . 673
    The Lynx Program ...............................................................................................................673
    Installing Lynx ...........................................................................................................674
    The lynx command line ............................................................................................675
    The Lynx configuration file .......................................................................................676
    The Lynx environment variables ..............................................................................683
    Capturing data from Lynx ........................................................................................684
    The cURL Program ..............................................................................................................687
    Installing cURL ..........................................................................................................687
    The cURL command line ..........................................................................................688
    Exploring with curl ...................................................................................................688
    Networking with zsh ...........................................................................................................694
    The TCP module .......................................................................................................694
    The client/server paradigm ........................................................................................695
    Client/server programming with zsh ........................................................................695
    Summary ..............................................................................................................................699
    Chapter26:Using E-Mail . . . . . . . . . . . . . . . . . . . . . . . . . 701
    The Basics of Linux E-Mail .................................................................................................701
    E-Mail in Linux .........................................................................................................701
    The Mail Transfer Agent ...........................................................................................702
    The Mail Delivery Agent ...........................................................................................703
    The Mail User Agent .................................................................................................705
    Setting Up Your Server ........................................................................................................708
    sendmail ....................................................................................................................709
    Postfix ........................................................................................................................711
    Sending a Message with Mailx ............................................................................................717
    The Mutt Program ...............................................................................................................720
    Installing Mutt ...........................................................................................................720
    xxii
    Contents
    The Mutt command line ...........................................................................................721
    Using Mutt .................................................................................................................721
    Summary ..............................................................................................................................723
    Chapter27: Shell Scripts forAdministrators . . . . . . . . . . . . . . . 725
    Monitoring System Statistics ...............................................................................................725
    Monitoring disk free space ........................................................................................725
    Catching disk hogs ....................................................................................................728
    Watching CPU and memory usage ...........................................................................732
    Performing Backups ............................................................................................................739
    Archiving data files ....................................................................................................740
    Storing backups off-site .............................................................................................744
    Summary ..............................................................................................................................746
    AppendixA:QuickGuide tobashCommands . . . . . . . . . . . . . . 749
    Built-In Commands .............................................................................................................749
    Bash Commands ..................................................................................................................749
    Environment Variables ........................................................................................................753
    AppendixB:QuickGuide tosedandgawk . . . . . . . . . . . . . . . . 759
    The sed Editor .....................................................................................................................759
    Starting the sed editor ...............................................................................................759
    sed commands ...........................................................................................................760
    The gawk program ..............................................................................................................764
    The gawk command format ......................................................................................764
    Using gawk ................................................................................................................765
    The gawk variables ....................................................................................................766
    The gawk program features ......................................................................................768
    AppendixC:Comparing Shells . . . . . . . . . . . . . . . . . . . . . . 771
    Variables ..............................................................................................................................771
    Environment variables ...............................................................................................771
    User-defined variables ...............................................................................................772
    Array variables ...........................................................................................................772
    Structured Commands ........................................................................................................773
    The if-then, while, and until statements ..................................................................773
    The for statement ......................................................................................................774
    Mathematical Operations ....................................................................................................775
    Index .............................................................................................................................................777
    xxiii

    First, all glory and praise go to God, who through His Son makes all things possible, and
    gives us the gift of eternal life.
    Many thanks go to the great team of people at John Wiley & Sons for their outstanding work
    on this project. Thanks to Jenny Watson, the acquisitions editor, for offering me the opportunity
    to work on this book. Also thanks to Tom Dinse, the development editor, for keeping things
    on track and making this book more presentable. The technical editor, John Kennedy, did an
    amazing job of double-checking all the work in this book, plus making suggestions to improve
    the content. Thanks, John, for your hard work and diligence. I would also like to thank Carole
    McClendon at Waterside Productions, Inc. for arranging this opportunity for me, and for helping
    out in my writing career.
    Finally, I would like to thank my parents, Mike and Joyce Blum, for their dedication and support
    while raising me, and my wife, Barbara, and daughters, Katie Jane and Jessica, for their love,
    patience, and understanding, especially while I was writing this book.
    xxv

    Welcome to Linux Command Line and Shell Scripting Bible. Like all books in the Bible
    series, you can expect to find both hands-on tutorials and real-world practical application
    information, as well as reference and background information that provides
    a context for what you are learning. This book is a fairly comprehensive resource on the Linux
    command line and shell commands. By the time you have completed Linux Command Line and
    Shell Scripting Bible, you will be well prepared to write your own shell scripts that can automate
    practically any task on your Linux system.
    Who Should Read This Book
    If you’re a system administrator in a Linux environment, you’ll benefit greatly by knowing how to
    write shell scripts. The book doesn’t walk through setting up a Linux system, but once you have
    it running, you’ll want to start automating some of the routine administrative tasks. That’s where
    shell scripting comes in, and that’s where this book will help you out. This book will demonstrate
    how to automate any administrative task using shell scripts, from monitoring system statistics and
    data files to generating reports for your boss.
    If you’re a home Linux enthusiast, you’ll also benefit from Linux Command Line and Shell Scripting