Tuesday, May 17, 2011

YUM Configuration


Features:
1. The ability to centralize packages (updates)

Installation & Setup:
1. Install 'createrepo*rpm'
2. Setup directory structure
a. /srv/www/Linuxtutorial.com/RH5/yum

3. Run 'createrepo /srv/www/Linuxtutorial.com/RH5/yum'

4. Publish the yum repository using HTTP

5. Configure yum client to use HTTP to fetch the RPMs
a. /etc/yum.conf
a1. ###Included as our first repository on the SUSE box###
[0001]
name=Linuxtutorialsuse1
baseurl=http://192.168.75.100/RH5/yum

Note: Ensure that about 3GBs are available for the yum respository


tar -cjvf yum_metadata.bz2 repodata

Yum Usage:
1. Search for packages
a. 'yum search gftp'

2. Install packages - Requires RedHat GPG Key for RPMs
rpm --import http://192.168.75.100/RH5/i386/RPM-GPG-KEY-redhat-release
a. 'yum -y install gftp'
b. 'yum -y install gftp dhcp' installs 2 packages

3. Remove Package
a. 'yum -y remove gftp'

RPM

Features:
1. Provides package management
a. Query
b. Install
c. Uninstall
d. Upgrade
e. Verify
2. Auto-verifies packages using GPG, MD5, SHA1SUMs
3. Automatically reports on unresolved dependencies

'rpm'

Query:
1. rpm -qa - dumps all installed packages
2. rpm -qa | wc -l - this dumps all packages and provides a count
3. rpm -qa | grep -i nano
4. rpm -qi nano - dumps info. about the 'nano' package as it's recorded in the local RPM database
5. rpm -qf /usr/bin/nano - dumps package membership info. for the 'nano' file
6. rpm -qpi http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm - dumps info. about the uninstalled 'dhcp' package, which resides on the repository
7. rpm -ql package_name - returns all included files


Verify:
1. rpm -Va - verifies ALL packages on the system, returning info. only if there are discrepancies from the original installation

2. rpm -Vf /usr/bin/nano

Task: Change '/usr/bin/nano' then verify

SM5....T /usr/bin/nano

S(file size), M(mode or permissions), 5(MD5), T(mod time)
3. rpm -Vp nano


Install (Does NOT overwrite previous package):
Note: Use this method to install a new version of the kernel
1. rpm -ivh *.rpm
2. rpm -ivh http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm



Upgrade (Installs or overwrites existing package):
1. rpm -Uvh *.rpm
2. rpm -Uvh http://192.168.75.100/RH5/i386/Server/dhcp-3.0.5-7.el5.i386.rpm

Freshen (Updates an existing package):
Note: Will NOT install the package, if it doesn't exist locally

1. rpm -Fvh *.rpm - freshens the current version of a package


Removal:
1. rpm -ev *.rpm - removes a pacakge
Note: removal process considers dependencies and will complain if the removal will break 1 or more packages. To get around this, use '--nodeps' option with 'rpm -ev --nodeps *.rpm'

2. rpm -ev gftp


Package Management GUI:
1. Add/Remove Software
2. system-config-packages

RAID

Features:
1. The ability to increase availability and reliability of data


Tasks:
1. Create a RAID-1 Device (/dev/md0..n)
a. fdisk /dev/sdb - to create usable raw partitions
b. partprobe /dev/sdb - to force a kernel update of the partition layout of the disk: /dev/sdb
b. mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb5 /dev/sdb6
c. cat /proc/mdstat - lists active RAID (md) information
d. mke2fs -j /dev/md0 - overlays a file system on the RAID device
e. mount /dev/md0 /raid1
f. update: /etc/fstab

Note: use 'mdadm --query /dev/md0' to get information about a RAID device


Note: You may create RAID volumes/devices on a single or on multiple disks
Ideally, your RAID volumes should span multiple physical disks to improve:
a. reliability
b. performance
c. availability

2. Remove the RAID-1 device
a. umount /dev/md0
b. mdadm --manage --stop /dev/md0

3. Create a RAID-5 Volume
a. fdisk /dev/sdb - to create a partition number 7
b. partprobe /dev/sdb - to update the kernel's view of the partition table
c. mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb5 /dev/sdb6 /dev/sdb7
d. watch cat /proc/mdstat - refreshes every 2 seconds
e. Overlay a file system: mke2fs -j /dev/md0
f. mount /dev/md0 /raid5
g. Test I/O to RAID-5 device
h. Update: /etc/fstab

Logical Volume Management (LVM)


Features:
1. Ability to create volume sets and stripe sets
2. LVM masks the underlying physical technology (ATA,ATAPI,IDE,SCSI,SATA,PATA,etc.)
3. LVM represents storage using a hierarchy:
a. Volume groups
a1. Physical volumes (/dev/sda2, /dev/sdb2, etc.)
b. Logical Volumes
b1. File systems
3. LVM physical volumes can be of various sizes
4. Ability to resize volumes on the fly

Note: Volume groups join: physical volumes (PVs) and Logical Volumes (LVs)


6 Steps to setup LVM:
1. Create LVM partitions via fdisk or parted
a. fdisk /dev/sda, /dev/sdb, /dev/sdc
b. n
c. p
d. +10G
e. t - change to type '8e' (LVM)
f. w
g. partprobe /dev/sda

2. Create Physical Volumes using 'pvcreate'
a. pvcreate /dev/sda3 /dev/sdb3 /dev/sdc3

3. Create Volume Groups using 'vgcreate'
a. vgcreate volgroup001 /dev/sda3 /dev/sdb3 /dev/sdc3
Note: Volume groups can be segmented into multiple logical volumes

4. Create one or more Logical Volumes
a. lvcreate -L 10GB -n logvolvar1 volgroup001
b. lvcreate -L 10GB -n logvolusr1 volgroup001

5. Create File system on logical volume(s)
a. mke2fs -j /dev/volgroup001/logvolvar1
b. mke2fs -j /dev/volgroup001/logvolusr1

6. Mount logical volume
a. mkdir /var1
b. mount /dev/volgroup001/logvolvar1 /var1
c. mkdir /usr1
d. mount /dev/volgroup001/logvolusr1 /usr1


Note: Be certain to update: /etc/fstab so that volumes are mounted when the system reboots

3-tiers of LVM display commands include:
a. pvdisplay - physical volumes - represent raw LVM partitions
b. vgdisplay - volume groups - aggregate physical volumes
c. lvdisplay - logical volumes - file systems - mount here


Rename of Logical Volume:
1. lvrename volume_group_name old new - used to rename volumes

Task: Rename 'logvolvar1' to 'logvolopt1'
a. lvrename volgroup001 logvolvar1 logvolopt1
Note: LVM is updated immediately, even while volume is mounted
However, you must remount the logical volume to see the changes
b. umount /var1 && mount /dev/mapper/volgroup001-logvolopt1 /opt1
c. Update /etc/fstab


Remove Logical Volume:
Task: Remove 'logvolusr1' from the logical volume pool
a. umount /usr1
b. lvremove /dev/mapper/volgroup001-logvolusr1
c. use 'lvdisplay' to confirm removal


Resize Logical Volume:
Task: Grow (resize) 'logvolopt1' to 20GB
a. lvresize -L 20GB /dev/volgroup001/logvolopt1
b. lvdisplay - to confirm new size of logical volume
c. df -h - will still reveal the current size
d. Resize the file system to update the INODE table on the logical volume to account for the new storage in 'logvolopt1'
'resize2fs -f -p /dev/volgroup001/logvolopt1'

Note: You may resize file systems online if the following are met:
1. 2.6x kernel series
2. MUST be formatted with ext3

Task: Shrink (resize) 'logvolopt1' to 15GB
a. lvresize -L 15GB /dev/volgroup001/logvolopt1
b. lvdisplay
c. df -h
d. resize2fs -f -p /dev/volgroup001/logvolopt1
Note: online shrinking is not supported
e. df -h

Note: Check disk utilization prior to shrinking to reduce the risk of losing data

LVM GUI Utility:
system-config-lvm

Create Swap based on File


Features:
1. The ability to provision swap space based on a file, similar to pagefile.sys in Windows NT, etc., if you have no available disk space to partition.

2. Doesn't waste partitions


Task:
1. Create 512MB swap file
a. dd if=/dev/zero of=/home1/swapfile1 bs=1024 count=524288
b. mkswap /home1/swapfile1 - overlays swap file system
c. swapon /home1/swapfile1 - makes swap space avaialable to the kernel

2. Ensure that when the system reboots, the swapfile is made avialable to the kernel
a. nano /etc/fstab - /home1/swapfile1 swap swap defaults 0 0


3. Create 2GB swap file
a. dd if=/dev/zero of=/home1/swapfile2 count=2G

Swap Partitions & Files


Features:
1. Extra, virtual RAM for the OS


Steps:
1. Identify current swap space
a. swapon -s - enumerates partitions and/or files, which constitute swap storage

b. free -m

2. Select target drive and provision swap partition
a. fdisk /dev/sdb
b. n
c. 2
d. 500
e. +512 (cylinder 562) - 63 cylinders are required for 512MB
f. t - change type
g. 82 - Linux Swap/Solaris
h. w - committ changes to disk

3. Create the swap file system on the raw partition: /dev/sdb2
a. mkswap /dev/sdb2

4. Enable swapping - publish the swap space to the kernel
a. swapon /dev/sdb2 - this enables swapping on /dev/sdb2

5. update /etc/fstab
a. /dev/sdb2 swap swap defaults 0 0

swapoff /dev/sdb2 - disables swapping on /dev/sdb2

Task:
1. Improve system performance by distributing swapping to /dev/sdb2
a. swapon /dev/sdb2
b. swapoff /dev/sda6
c. disable /dev/sda6 via /etc/fs

File Types - Permissions - Symlinks


Features:
1. The ability to restrict/control access to files

Note: 10 bits represent permissions for files (including directories)

Note: use 'ls -l' to examine permissions or GUI application like 'Nautilus'

-rwxrwxr-x 1 linuxcbt linuxcbt 681 Jan 13 11:31 regextest.pl

1st bit = file type. '-' = file, 'd' = directory
2nd - 4th bits = owner's permissions
r = read = 4
w = write = 2
x = execute = 1
- = none = 0

5th - 7th bits = group owner's permissions
r = read = 4
w = write = 2
x = execute = 1
- = none = 0

8th - 10th bits = everyone (world)
r = read = 4
w = write = 2
x = execute = 1
- = none = 0

Task:
1. Manipulate file permissions using 'chmod'
a. chmod -x regextest.pl

-rw-rw-r-- 1 linuxcbt linuxcbt 681 Jan 13 11:31 regextest.pl
rw = 6 or 4+2 for owner
rw = 6 or 4+2 for group owner
r = 4 for everyone else (world)

Octal notation: 664 for file 'regexetest.pl'

chmod 664 regextest.pl - removes execution for ALL users
chmod 775 regextest.pl - enables execution for ALL users


2. Ensure that 'regextest.pl' is rw by owner and noone else
a. chmod 600 regextest.pl

Note: File will now be rw by owner (linuxcbt) and 'root'

3. Ensure that 'regextest.pl' is r by owner and noone else
a. chmod 400 regextest.pl && ls -l regextest.pl

Note: chmod supports string values, which represent octal values
chmod +/- x file
chmod +/- w file
chmod +/- r file

chmod +/- u+x file - updates owner's execute permissions on the file
chmod +/- o+x file - updates other's execute permissions on the file
chmod +/- g+x file - updates group's execute permissions on the file

chmod a+rwx = chmod 777


chown - permits changing of ownership of files
a. chown root regextest.pl - changes ownership to 'root'
b. chown linuxcbt:sales regextest.pl - changes owner and group to 'linuxcbt:sales'

Task:
Update 'regextest.pl' so that owner and group owner may modify the file

a. chmod 660 regextest.pl


SETUID:
Features:
1. ability to execute file as owner

chmod 4760 regextest.pl - this will ensure that the perl script always executes as the user 'linuxcbt'
-rwsrw---- 1 linuxcbt sales 787 Jan 28 16:08 regextest.pl

's' in the execute position means that the program will execute as that user


SETGID:
Features:
1. Ability to enforce permissions to a directory structure

mkdir /sales
chmod 2775 /sales

Create a file in the '/sales' directory as 'linuxcbt'
seq 1000000 > linuxcbt.1million.txt


chgrp:
Permits updating of group permissions


Sticky Bit:
Features:
1. Ability to ensure that users cannot delete others' files in a directory

drwxrwxrwt 23 root root 4096 Jan 28 15:05 /tmp/


/tmp - users cannot delete other user's files in '/tmp'

chmod 3777 /sales - ensures that /sales will not lose files from incorrect users

Task:
1. Set '/sales' using sticky bit and test
a. chmod 3777 /sales && ls -ld /sales OR chmod 777 /sales && chmod +t /sales

User/Group Management


Features:
1. The ability to control users and groups

Primary tools:
1. useradd - used to add users and modify group membership
2. system-config-users

Task:
1. Create a user named 'student1' using 'useradd'

Note: Default user settings derive from: /etc/login.defs
a. useradd student1
b. set password for user 'student1': passwd student1


Default User Accounts DB: /etc/passwd
student1:x:501:501::/home/student1:/bin/bash

username:shadow_reference:uid:gid:Description(GECOS):$HOME:$SHELL
Note: /etc/passwd is a world-readable file
Note: /etc/shadow now stores passwords in encrypted form
Note: /etc/shadow is NOT world-readable

Fields in /etc/shadow:
student1:$1$XSFMv2ru$lfTACjN.XxaxbHA0EkB4U0:13891:0:99999:7:::

1. username:
2. encrypted_password:
3. Days_since_Unix_epoch_password_was_changed (01/01/1970)
4. Days before password may be changed
5. Days after which the password MUST be changed
6. Days before password is to expire that user is warned
7. Days after password expires, that account is disabled
8. Days since Unix epoch, that account is disabled
9. Reserved field (currently unused)


2. Modify user 'student1' to have password expire after 45 days
a. usermod


Groups:
1. groupadd - adds new group
2. groups - lists groups on the system: /etc/group
/etc/group - maintains group membership information

Task: Create a 'sales' group and add 'linuxbbt' and 'student1' as members
1. groupadd sales
2. usermod -G sales linuxbbt
3. usermod -G sales student1

Note: 2 types of groups exist:
1. Primary - used by default for a user's permissions
2. Supplemental - used to determine effective permissions

Note: use 'id' to determine the group information of user
Note: Create a new shell session to realize new group membership information

userdel/groupdel are used to delete users and groups, respectively

System Utilities


Features:
1. Process listing
2. Free/available memory
3. Disk utilization


1. ps - process status/listing
a. ps -ef or ps -aux

2. top - combines, ps, uptime, free and updates regulary

3. uptime - returns useful system utilization information:
a. current time
b. uptime - days, hours and minutes
c. connected users
d. load averaged - 1,5,15 minute values

4. free - returns memory utilization
a. RAM
b. SWAP
free -m - for human readable format

5. df - returns disk partition/mount point information
a. df - returns info. using kilobytes
b. df -h - returns info. using megabytes/human readable (gigs/teray/etc.)

6. vmstat - reports on: processes, memory, paging, block I/O, traps, CPU activity

a. vmstat
b. vmstat -p /dev/hda1 - returns partitions stats for /dev/hda1 (/boot)

7. gnome-system-monitor - GUI, combining most system utilities
8. ls -ltr /proc
a. cat /proc/cpuinfo

9. kill PID - kills the process with a given PID
10. runlevel - returns runlevel information using 2 fields:
a. represents previous runlevel
b. represents current runlevel

Grep,Awk,Sed


GREP

Features:
1. The ability to parse lines based on text and/or RegExes
2. Post-processor
3. Searches case-sensitively, by default
4. Searches for the text anywhere on the line


1. grep 'linux' grep1.txt
2. grep -i 'linux' grep1.txt - case-insensitive search
3. grep '^linux' grep1.txt - uses '^' anchor to anchor searches at the beginning of lines
4. grep -i '^linux' grep1.txt
5. grep -i 'linux$' grep1.txt - uses '$' anchor to anchor searches at the end of lines

Note: Anchors are RegEx characters (meta-characters). They're used to match at the beginning and end of lines

6. grep '[0-9]' grep1.txt - returns lines containing at least 1 number
7. grep '[a-z]' grep1.txt


8. rpm -qa | grep grep - searches the package database for programs named 'grep'

9. rpm -qa | grep -i xorg | wc -l - returns the number of pacakges with 'xorg' in their names

10. grep sshd messages
11. grep -v sshd messages - performs and inverted search (all but 'sshd' entries will be returned)
12. grep -v sshd messages | grep -v gconfd
13. grep -C 2 sshd messages - returns 2 lines, above and below matching line

Note: Most, if not all, Linux programs log linearly, which means one line after another, from the earliest to the current

Note: Use single or double quotes to specify RegExes
Also, execute 'grep' using 'egrep' when RegExes are being used

Awk

Features:
1. Field/Column processor
2. Supports egrep-compatible (POSIX) RegExes
3. Can return full lines like grep
4. Awk runs 3 steps:
a. BEGIN - optional
b. Body, where the main action(s) take place
c. END - optional
5. Multiple body actions can be executed by separating them using semicolons. e.g. '{ print $1; print $2 }'
6. Awk, auto-loops through input stream, regardless of the source of the stream. e.g. STDIN, Pipe, File


Usage:
1. awk '/optional_match/ { action }' file_name | Pipe
2. awk '{ print $1 }' grep1.txt

Note: Use single quotes with awk, to avoid shell interpolation of awk's variables

3. awk '{ print $1,$2 }' grep1.txt

Note: Default input and output field separators is whitespace

4. awk '/linux/ { print } ' grep1.txt - this will print ALL lines containing 'linux'

5. awk '{ if ($2 ~ /Linux/) print}' grep1.txt

6. awk '{ if ($2 ~ /8/) print }' /var/log/messages - this will print the entire line for log items for the 8th

7. awk '{ print $3 }' /var/log/messages | awk -F: '{ print $1}'

Sed - Stream Editor

Features:
1. Faciliates automated text editing
2. Supports RegExes (POSIX)
3. Like Awk, supports scripting using '-F' option
4. Supports input via: STDIN, pipe, file

Usage:
1. sed [options] 'instruction[s]' file[s]
2. sed -n '1p' grep1.txt - prints the first line of the file
3. sed -n '1,5p' grep1.txt - prints the first 5 lines of the file
4. sed -n '$p' grep1.txt - prints the last line of the file
5. sed -n '1,3!p' grep1.txt - prints ALL but lines 1-3
6. sed -n '/linux/p' grep1.txt - prints lines with 'linux'
7. sed -e '/^$/d' grep1.txt - deletes blank lines from the document
8. sed -e '/^$/d' grep1.txt > sed1.txt - deletes blank lines from the document 'grep1.txt' and creates 'sed1.txt'

9. sed -ne 's/search/replace/p' sed1.txt
10. sed -ne 's/linux/unix/p' sed1.txt
11. sed -i.bak -e 's/3/4' sed1.txt - this backs up the original file and creates a new 'sed1.txt' with the modifications indicated in the command

Note: Generally, to create new files, use output redirection, instead of allowing sed to write to STDOUT

Note: Sed applies each instruction to each line

BASICS OF REDHAT LINUX 5

REDHAT LINUX 5 Features:

1. 2.6x kernel (2.6.18)
a. 'uname -a' returns OS/Kernel information
Note: 'uname -a' returns the following useful info:
1. OS - Linux
2. Fully Qualified Domain Name (FQDN)
3. Kernel version - 2.6.18...
a. 2.6 = major version
b. .18 = minor version
c. anything else after the minor version indicates that the kernel was patched by the distributor
4. Date and time that the kernel was compiled


2. Supports multiple versions:
a. Basic - Red Hat Enterprise Linux Server
a1. supports 2 physical (Socket) CPUs
a2. Up to 4 virtual guests

b. Advanced Platform
b1. supports unlimited physical CPUs
b2. supports unlimited virtual guests

Note: Virtualization limits pertain to the virtualization technology included with Red Hat Enterprise Linux. NOT third-party software (VMWare)


3. Supports the following platforms:
a. Intel 32/64-bits
b. AMD 32/64-bits
c. IBM - POWER and z-series, S/390

Note: Memory limitation is based on hardware


Note: Common uses of the various versions of RHEL
1. RHEL Basic Version
a. File & Print
b. Web server
c. Infrastructure server (DHCP, DNS, Proxy, etc.)

2. RHEL Advanced Version
a. Application server (Apache Tomcat, JBOSS, Weblogic, WebSphere, etc.)
b. Database server (MySQL, PostgreSQL, Oracle, Ingres, etc.)
c. Clustering

File System Hierarchy of LINUX


Logical File System is the type which LINUX follows for organisation of files of different category.
Root (/) is the starting point  of Linux. And now Root divided the structure into different folders as given under:
Bin – Binary-Got general purpose commands
Sbin – Super User Binary- All Administrative commands
Home – Home directory of Users created
Root – Administrator Home directory
Etc – All configuration files are here under
Var – All the data which is changing  in OS
Temp – All the working process are stored here
Dev – All the devices information stored
Mnt – The mount points of removable devices
initrd – Initial Ramdisk image, booting of the OS starts frm here
Proc – All the active process information
Opt – Optional
Usr – Unix System resource,contains the bulk of installation and system files
Boot – Contains image of kernel and booting files
Lib – Library files stored here
Misc – Miscellaneous
Lost+Found
Media – for mounting cdroms,removable drive

User Administration


User Administration is the most important part of System Administration in LINUX.
User creation,modification,deletion are major parts in User Administration.
useradd    :    User creation
passwd       :  Give password for user aftre creation
userdel     :    User deletion
userdel -rf     :  Forcibly remove user and its related home directory and files.
usermod        :   to modify the user data.
Options include  —-   -u: to change UserID (UID),   -g: to change GroupID (GID),  -d: to change Home Directory,  -s: to change the shell,  -c: to change or assign a  comment,  -L: to lock user account,  -U: to unlock the user account,  -l: to remove the user account,  -o: to overrite/duplicate the User or Group ID.
SU  –     —-Switch User from other user.
The UID starts for a manually created User is 500.
/etc/passwd :  Contains all user information
/etd/shadow : Contains all Password information
/etc/group : Contains all the groups information
Whena user is created LINUX assumes it as mail user and the mailbox of the user is stored in /spool/mail.
Home Directory of the user is stored in /home
When a user is created some default skeleton files are created in the directory called /etc/skel. The following are the hidden files created :
.bash_profile,  .bash_logout, .bashrc, .emacs, .gtkrc
The default shell for a user is Bash and the prompt will be ‘$’ .
The prompt for Root is ‘#’.
A user created can be a member of one or more groups.
Maximum number of users created in LINUX OS are 60,000.
The kernel supports upto 1.6 million user and group accounts.
0-499 are reserved for System accounts.
500-60000 are General purpose users.

The Partition /etc Described


The configuration partition /etc, where all the configuration files are stored.
     etc/shells  :  To see the number and type of shells
     etc/passwd  :  User information
     etc/shadow   :  Password information
     etc/group   :  Groups information
     etc/skel  :  information of defaults of user
     etc/inittab   :  Run levels
     etc/rc.d  :  run controls
     etc/sysconfig/network  :  Hostname to be edited here to make it permanent
     etc/hosts  :  Add the hostname,  to ping with the hostname in network.
     etc/resolv.conf  :  DNS information
     etc/samba : Samba server information
     etc/httpd  :  Webserver information
     etc/vsftpd : FTP server information
     etc/exports  :  NFS configuration
     etc/named  :  DNS configuration
     etc/mail  : Mail server details
     etc/dhcpd.conf  :  DHCP configuration

GRUB – define and working


Linux boot loader is GRUB – Grand Unified Boot loader
originally designed and implemented by Erich Stefan Boleyn.
GRUB is dynamically configurable. This means that the user can make changes during the boot time, which include altering existing boot entries, adding new, custom entries, selecting different kernels, or modifying initrd. GRUB also supports Logical Block Address mode. This means that if your computer has a fairly modern BIOS that can access more than 8GB (first 1024 cylinders) of hard disk space, GRUB will automatically be able to access all of it.
GRUB can be run from or be installed to any device (floppy disk, hard disk, CD-ROM, USB drive, network drive) and can load operating systems from just as many locations, including network drives. It can also decompress operating system images before booting them.
How does GRUB work?
When a computer boots, the BIOS transfers control to the first boot device, which can be a hard disk, a floppy disk, a CD-ROM, or any other BIOS-recognized device. We’ll concentrate on hard disks, for the sake of simplicity.
The first sector on a hard is called the Master Boot Record (MBR). This sector is only 512 bytes long and contains a small piece of code (446 bytes) called the primary boot loader and the partition table (64 bytes) describing the primary and extended partitions.
By default, MBR code looks for the partition marked as active and once such a partition is found, it loads its boot sector into memory and passes control to it.
GRUB replaces the default MBR with its own code.
GRUB works in stages.
Stage 1 is located in the MBR and mainly points to Stage 2, since the MBR is too small to contain all of the needed data.
Stage 2 points to its configuration file, which contains all of the complex user interface and options we are normally familiar with when talking about GRUB. Stage 2 can be located anywhere on the disk. If Stage 2 cannot find its configuration table, GRUB will cease the boot sequence and present the user with a command line for manual configuration.

Important daemons and start up services

A good source of information on daemons and services is the “Linux Devices, Daemons, Services” chapter of the CTDP (2000a) document.
•    amd – runs the automount daemon for remote filesystem mounting such as nfs
•    anacron – checks delayed `cron’ tasks (see below) at boot time and executes them. Useful if you have cron jobs scheduled but don’t run your machine all the time.
•    apmd – Advanced Power Management BIOS daemon. For use on machines, especially laptops, that support apm. Monitors battery status and can shut down the system if power is too low.
•    arpwatch – keeps watch for ethernet IP address pairings that are resolved using the ARP protocol.
•    atd – runs jobs queued by `at’
•    autofs – control the operation of automount daemons, used to mount and unmount devices on demand
•    bootparamd – allows computers to boot from a Linux machine using the BOOTP network protocol. A server process that provides information to diskless clients necessary for booting
•    crond – automatic task scheduler. Manages the execution of tasks that are executed at regular but infrequent intervals, such as rotating log files, cleaning up /tmp directories, etc.
•    cups – daemon for print services under the Common Unix Printer System, a replacement for lpd
•    dhcpd – implements the Dynamic Host Configuration Protocol (DHCP) and the Internet Bootstrap Protocol (BOOTP). Used to lease out IP addresses to remote machines.
•    drakfont – font server in Mandrake
•    fetchmail – daemon to fetch mail at regular intervals from mail servers
•    ftpd – ftp server daemon
•    gated – routing daemon that handles multiple routing protocols and replaces routed and egpup
•    gpm – useful mouse server for applications running on the Linux console.
•    httpd – the Apache webserver hypertext transfer protocol daemon
•    identd – The identd server provides a means to determine the identity of a user of a particular TCP connection. Given a TCP port number pair, it returns a character string which identifies the owner of that connection on the server’s system.
•    inetd – listens for service requests on network connections, particularly dial-in services. This daemon can automatically load and unload other daemons (ftpd, telnetd, etc.), thereby economizing on system resources. In the latest version of Red Hat (7.0 at the time of writing), it has been replaced by xinetd. A partial list of services controlled by inetd is listed below. Under many distributions, inetd will execute scripts in the file /etc/inetd.conf.
•    innd – Usenet news server daemon
•    ipchains – daemon for packet forwarding. Used for configuring a gateway/firewall.
•    isdn provides ISDN network interfacing services
•    isdn4linux – for users of ISDN cards
•    kerneld – automatically loads and unloads kernel modules
•    keytable – loads the appropriate keyboard map from /etc/sysconfig/ keyboard
•    kheader -
•    kudzu – detects and configures new or changed hardware during boot
•    linuxconf – “startup hook” needed for the linuxconf system configuration tool
•    lpd – line printer and print spooler daemon
•    mcserv – server program for the Midnight Commander networking file system. It provides access to the host file system to clients running the Midnight file system (currently, only the Midnight Commander file manager). If the program is run as root the program will try to get a reserved port otherwise it will use 9876 as the port. If the system has a portmapper running, then the port will be registered with the portmapper and thus clients will automatically connect to the right port. If the system does not have a portmapper, then a port should be manually specified with the -p option (see below).
•    mysql – database server daemon
•    named – provides DNS services
•    netfs – network filesystem mounter. Used for mounting nfs, smb and ncp shares on boot.
•    network -activates all network interfaces at boot time by calling scripts in /etc/sysconfig/network-scripts
•    nfsd – used for exporting nfs shares when requested by remote systems
•    nfslock – starts and stops nfs file locking service
•    numlock – locks numlock key at init runlevel change
•    pcmcia – generic services for pcmcia cards in laptops
•    portmap – needed for Remote Procedure Calls
•    postfix – mail transport agent which is a replacement for sendmail. Now the default on desktop installations of Mandrake.
•    postgresql – database server daemon
•    random – random number generating daemon, related to security and encryption
•    routed – manages routing tables
•    rstatd – kernel statistics server. Allows users on a network to get performance statistics for any connected machine.
•    rusersd – provides services that allow users to find one another over the network
•    rwalld – allows users to use rwall to write messages on remote terminals
•    rwhod – server which maintains the database used by the rwho(1) and ruptime(1) programs. Its operation is predicated on the ability to broadcast messages on a network.
•    sendmail – mail transfer agent. This is the agent that comes with Red Hat. Others, such as smtpd, are not included.
•    smb – needed for running SAMBA
•    snmpd – provides Simple Network Management Protocol support
•    sound – daemon for managing sound
•    squid – web page proxy server daemon
•    syslogd – manages system log files
•    smtpd – Simple Mail Transfer Protocol, designed for the exchange of electronic mail messages. Several daemons that support SMTP are available, including sendmail, smtpd, rsmtpd, qmail, zmail, etc.
•    tcpd – from the tcp_wrappers package. Intercepts requests normally handled by inetd and filters them through the files hosts.allow and hosts.deny files, which can restrict access to services based on type of service, origin of request, destination, etc. Requests are intercepted because calls to particular services are replaced with calls to tcpd in /etc/inetd.conf.
•    telnetd – telnet server daemon
•    usb – daemon for devices on Universal Serial Bus
•    xfs – X font server
•    xinetd – more modern replacement for inetd. It apparently allows for similar kinds of access filters to the ones used by tcpd in conjunction with inetd. xinetd replaces inetd as the default network services daemon in Red Hat 7.0.
•    xntpd – Network Time Protocol daemon. Provides a means to syncronize time over the network.
•    webmin – daemon for webmin web-based system administration program
•    ypbind – NIS binder. Needed if computer is part of Network Information Service domain.

NFS Config


NFS, the Network File System, is the most common method for providing file sharing
services on Linux and Unix networks. It is a distributed file system that enables
local access to remote disks and file systems.
Configuration and status files
*/etc/exports
*/var/lib/nfs/rmtab
*/var/lib/nfs/xtab
*/etc/hosts.allow
*/etc/hosts.deny
Daemons
*rpc.portmap
*rpc.mountd
*rpc.nfsd
*rpc.statd
*rpc.lockd
*rpc.rquotad
Scripts and commands
*/etc/rc.d/init.d/nfs
*nfstat
*showmount
*rpcinfo
*exportfs
Examle configuration of NFS:
edit the file /etc/exports as follows:
/home 192.168.0.*(rw,no_subtree_check)
/usr/local 192.168.0.*(ro)
In the above example /home and /usr/local are the shared paths for other linux/unix systems.
Now start the services
service portmap restart    and       service nfs restart
showmount -a     command will show you the mounted servers.
Now goto the client and give the path as follows to check the NFS server:
# mount -t nfs luther:/home /home
now the server is mounted on client and ready for sharing the files on /home.

Samba Server


Samba includes a utility called SWAT, the Samba Web Administration Tool. This tool makes setting up Samba very easy. The main Samba configuration file is /etc/smb.conf. SWAT enables you to use a Web browser as the interface to /etc/smb.conf and makes the necessary modifications to this file. While you are using SWAT to make the configuration changes, you will learn more about the smb.conf file. A sample smb.conf file was created during the installation that can be used for reference. You should rename this file because you will create a new smb.conf using SWAT and it will overwrite the original file.
The smb.conf file is divided into several sections. Shown next is the smb.conf file from one of the computers on my home network.
# Samba config file created using SWAT
# from localhost (127.0.0.1)
# Date: 2000/05/25 10:29:40
# Global parameters
[global]
workgroup = ONE
netbios name = TERRY
server string = Samba Server
security = SHARE
log file = /var/log/samba/log
max log size = 50
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
dns proxy = No
wins support = Yes
hosts allow = 192.168.1.
hosts deny = all
[homes]
comment = Home Directories
read only = No
[printers]
comment = All Printers
path = /var/spool/samba
guest ok = Yes
print ok = Yes
browseable = Yes
[sambashare]
path = /oldwin
valid users = naveen,ravi
read only = No
guest ok = no
browseable = yes
In the above file naveen and ravi are users  who can have access to /oldwin from the windows client. Start the services now to make file sharing on windows. sambashare is the share name.
service smb restart
You can test whether the smb process is running with the pgrep command:
# pgrep smb
Now create samba user and password for naveen and ravi.
# useradd naveen
#smbpasswd -a naveen
Now it will prompt for password,give the password
same for Ravi user too
Now give the following command to mount the samba server:
# smbmount ///share -u
Now at windows client side :
start – run- \\ipaddress\share name
Then you will get the remote desktop of the shared folders in linux.
This way samba can acess from windows.