Anda di halaman 1dari 34

Boot Process:

1. The system BIOS checks the system and launches the first stage boot loader on the MBR of the
primary hard disk.
2. The first stage boot loader loads itself into memory and launches the second stage boot loader from
the /boot/ partition.
3. The second stage boot loader loads the kernel into memory, which in turn loads any necessary
modules and mounts the root partition read-only.
4. The kernel transfers control of the boot process to the /sbin/init program.
5. The /sbin/init program loads all services and user-space tools, and mounts all partitions listed in
/etc/fstab.
6. The user is presented with a login screen for the freshly booted Linux system.

Config Files – Boot Process

/boot/grub/grub.conf and /etc/grub.conf This is the booting file of linux


#vim /boot/grub/grub.conf
boot=/dev/vda
default=0 = Which OS to be loaded at the time of booting
Tmeout=5
Splashimage appearance of grub menu
Hidden menu grub options are hidden

Run Levels

Vim /etc/inittab
0 - halt (Do NOT set initdefault to this)
1 - Single user mode
2 - Multiuser, without NFS (The same as 3, if you do not have networking)
3 - Full multiuser mode
4 - unused
5 - X11
6 - reboot (Do NOT set initdefault to this)Vim /etc/inittab (id:5:initdefault: :wq!)
id:5:initdefault:

For detecting new luns


echo "- - - " > /sys/class/fc_host/host0/issue_lip ====> For scanning the hba card and newly created zone
echo "1" > /sys/class/fc_host/host0/issue_lip
echo "- - -" > /sys/class/scsi_host/host0/scan ===> For detecting the nwlun
echo "- - -" >> /sys/class/scsi_host/host1/scan
rescan-scsi-bus.sh -l -w ===> For detecting new luns
fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' |wc –l ===> List the total disks
fdisk -l 2>/dev/null | egrep '^/dev/sd' |wc -l ==> List the total disks(using /dev/sd id)

echo 1 > /sys/block/sdo/device/delete ===> Remove LUN from system.


# grep sdo /proc/partitions ==> Then check whether it removed pointers to both sdo and sdo1

For detecting new hardware :


kudzu

Linux Disk Partioning

fdisk –l To display the disk configuration


fdisk /dev/vda To get in to the specified disk configuration
fdisk –Cu /dev/vda To get in with depressive mode
fdisk /dev/vda

P= print the partion table, n= To create new disk, d= delete a partition, m= print this menu, q= quit without saving,
t= change a partition system ID, w= write table to disk and exit

fdisk –cu /dev/vda n, select extended or Primary


Primary can be 3(3primary+1 externded)
Select ‘P’ for primary partition and ‘e’ for extended partition
First cylinder (enter or provide valid next cylinder number)
Last cylinder number (provide the size eg: +100G for 100gb partition)
w= To save changes and exit
trypartprobe or partx (without restart ,but it wont work in after rhel5)

[root@MDCLINUXVIRT ~]# fdisk /dev/sdb

Command (m for help): n


Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-13054, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-13054, default 13054): +6G

Command (m for help): p

Disk /dev/sdb: 107.3 GB, 107374182400 bytes


255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/sdb1 1 730 5863693+ 83 Linux
Command (m for help): n
Create sdb2 & sdb3 in same steps….
Command (m for help): p
Disk /dev/sdb: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/sdb1 1 730 5863693+ 83 Linux
/dev/sdb2 731 1704 7823655 83 Linux
/dev/sdb3 1705 2434 5863725 83 Linux

Command (m for help): n==========================================> Out of 4, 3 primary partition can


create. 4th one is using for extended. Then extended will split into logical partition.

Command action
e extended
p primary partition (1-4
e
Selected partition 4
First cylinder (2435-13054, default 2435):
Using default value 2435
Last cylinder or +size or +sizeM or +sizeK (2435-13054, default 13054):
Using default value 13054

Command (m for help): p

Disk /dev/sdb: 107.3 GB, 107374182400 bytes


255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/sdb1 1 730 5863693+ 83 Linux
/dev/sdb2 731 1704 7823655 83 Linux
/dev/sdb3 1705 2434 5863725 83 Linux
/dev/sdb4 2435 13054 85305150 5 Extended

Command (m for help): n


First cylinder (2435-13054, default 2435):
Using default value 2435
Last cylinder or +size or +sizeM or +sizeK (2435-13054, default 13054): 40 +40G

Command (m for help): p

Disk /dev/sdb: 107.3 GB, 107374182400 bytes


255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/sdb1 1 730 5863693+ 83 Linux
/dev/sdb2 731 1704 7823655 83 Linux
/dev/sdb3 1705 2434 5863725 83 Linux
/dev/sdb4 2435 13054 85305150 5 Extended
/dev/sdb5 2435 7298 39070048+ 83 Linux

Command (m for help): n


First cylinder (7299-13054, default 7299):
Using default value 7299
Last cylinder or +size or +sizeM or +sizeK (7299-13054, default 13054): +1G

Command (m for help): p

Disk /dev/sdb: 107.3 GB, 107374182400 bytes


255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System


/dev/sdb1 1 730 5863693+ 83 Linux
/dev/sdb2 731 1704 7823655 83 Linux
/dev/sdb3 1705 2434 5863725 83 Linux
/dev/sdb4 2435 13054 85305150 5 Extended
/dev/sdb5 2435 7298 39070048+ 83 Linux
/dev/sdb6 7299 7421 987966 83 Linux

Command (m for help): w


The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@MDCLINUXVIRT ~]# sync
[root@MDCLINUXVIRT ~]# partprobe
[root@MDCLINUXVIRT ~]# mkfs.ext3 /dev/sdb1
[root@MDCLINUXVIRT ~]#
[root@MDCLINUXVIRT ~]#mount /dev/sdb1 /mnt

/etc/fstab Entry==> Device to Mount : Mount Point : FS Type : Mount Option : FSCK Pass :
dev/vda3 /new ext4 defaults(r,rw) 0 0 (0=dump frequency ,0=fs check)
(0= Nobackup, 1=everyday backup, 2=Alternate day backup)
(0= Ignore, 1= All boot time, 2= Alternate booting)

How to create an encrypted partition


Create a normal partition for encrypted partition
cryptsetupluksFormat /dev/vda5 To make this FS for encrypted
CryptsetupluksOpen /dev/vda5 ipsr To generate encrypted (note: ipsr= it is an simple name for identification )
Mkfs –t ext4 /dev/mapper/ipsr
Mkdir /secret
Mount /dev/mapper/ipsr /secret
Df –h, ls /secret
CryptsetupluksCloseipsrTo remove/close from encryption
Update in /etc/fstab To make permanent .
Vim /etc/crypttab Update here also to make permanent
Ipsr /dev/vda5
So each and every time when the server gets reboot ,it will ask for the password to proceed with mounting of the
particular FS.

Setting password in crypttab file for automatic mounting when the server reboot.
Vim /etc/crypttab
Ipsr /dev/vda5 /root/mypassword
:wq!
Echo redhat> /root/mypassword It will set the password as ‘redhat’ by creating a file /root/mypassword for
encrypted FS
Chown root /root/mypassword, chmod 600 /root/mypassword, ls –l /root/mypassword
CryptsetupluksAddKey /dev/vda5 /root/mypasswordTo add the password key for encryption
E2label /dev/mapper/ipsr new To label
Vim /etc/fstab
LABEL=new :wq!

blockdev -getra /dev/sdb  For increasing the HDD performance

Breaking Root Password:

After rebooting, select any key to go to menu type e Select second line, starting with kernel and type e and go
to end of last line and type S press enter and will be in kernel prompt, ie 2 nd line  type b

It will come in single user mode

passwd root  change root passwd

LVM (Logical Volume Manage)

*LVM wont support /boot*


Create a partition in normal way
(m for help) : ‘t’ To change the partition type
‘5’ select the partition number
Code: ‘8e’ , : p to print the partition table, :’w’ To save and exit

Single LUN LVM Creation:

pvcreate /dev/mapper/mpathac
pvcreate /dev/sdb

vgcreate data_vg /dev/mapper/mpathac


vgcreate data_vg /dev/sdb5create a new vg with default PE
Vgcreate –s 8M newvg /dev/sdb5  To create VG with mentioning 8mb Physical Extend(PE)
Vgchange –s 4M newvg To change PE size
lvcreate –L 100G –n data_lv data_vg  To create 100GB LV
lvcreate –l 10 –n newlv newvg It will take the size as (10*8M of PE)
lvcreate -l 100%FREE -n data_lv data_vg By taking the full size of vg

mkfs.ext3 /dev/mapper/vg_data_3-lv_data_3
mount /dev/mapper/vg_data_3-lv_data_3 /data3

PV (Physical Volume)

pvcreate /dev/sdb
pvs
pvdisplay
pvscan scans for disks for non-LVM and LVM disks
pvs -a -o +devices  Listing detailed information of pvs.
pvremove /dev/sde
pvmove /dev/sde<faulty disk> /dev/sdf <new disk> Moving the data from faulty disk to new disk

VG (Volume Group)

vgcreate data_vg /dev/sdb


vgs
vgdispaly
vgscan
vgextend data_vg /dev/sdc
vgreduce data_vg /dev/sdc
vgreduce –removemissing –force vg_data

vgs –a –o +devices  Listing detailed information of vgs

vgs flags:
#PV - number of physical devices
#LV - number of configured volumes        

vgs attributes are:


1. permissions (r)|(w)
2. resi(z)eable
3. e(x)ported
4. (p)artial
5. allocation policy - (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited
6. (c)luster

## Backup to default location (/etc/lvm/backup)


vgcfgbackup VolData00

# Backup to specific location


vgcfgbackup -f /var/backup/VolData00_bkup VolData00
# Backup to specific location all volume groups (notice the %s)
vgcfgbackup -f /var/backup/vg_backups_%s
vgcfgrestore -f /var/backup/VolData00_bkup VolData00

Common Attributes that you may want to use:


-l list backups of file
-f backup file
-M metadataype 1 or 2

Exporting and Importing VG:

vgexport VolData00

vgimport VolData00

Reducing the vg... When the physical disk removing

umout /fs
pvremove pv_name
vgreduce --removemissing vg_name

LVM (Logical Volume Manager)

lvs
lvdisplay
lvdisplay –maps  Display Mirror Volumes

lvcreate –L 100G –n lv_name vg_name


lvcreate –l 10 –n newlv newvg It will take the size as (10*8M of PE)
lvcreate -l 100%FREE -n data_lv data_vg  By taking the full size of vg

lvchange -a n /dev/vg0/lv0  Disabling the LVM partition from usage.


lvchange -a y /dev/vg0/lv0  Enabling the LVM partition from usage.

lvrename /dev/VolData00/vol_old /dev/VolData00/vol_new

lvs –a –o +devices Detailed information of lvs

lvs attributes are:


1. volume type: (m)irrored, (M)irrored without initail sync, (o)rigin, (p)vmove, (s)napshot, invalid (S)napshot,
(v)irtual, mirror (i)mage
                      mirror (I)mage out-of-sync, under (c)onversion
2. permissions: (w)rite, (r)ead-only
3. allocation policy - (c)ontiguous, c(l)ing, (n)ormal, (a)nywhere, (i)nherited
4. fixed (m)inor
5. state: (a)ctive, (s)uspended, (I)nvalid snapshot, invalid (S)uspended snapshot, mapped (d)evice present with-out
tables, mapped device present with (i)nactive table
6. device (o)pen (mounted in other words)
LVM Extension

pvcreate /dev/hde1
vgextend data_vg /dev/hde1
lvextend -L +100G /dev/data_vg-pgsql_vol
resize2fs /dev/data_vg-pgsql_vol
LVM Reducing
Reducing the mount point /apps from 100G to 50G

umount /apps
e2fsck -f /dev/vg_app/lv_app
resize2fs /dev/vg_app/lv_app 110G
lvreduce–L 110G /dev/vg_app/lv_app
mount /dev/vg_app/lv_app /apps/

LVM Removing (mountpoint /data3)


umount /data3
lvremove /dev/mapper/vg_data3-lv_data3
vgremove vg_data3
pvremove /dev/mapper/mpathaa

Adding the new disk to vg vg_app

pvcreate /dev/vdd
vgextend vg_app /dev/vdd

Faulty Disk Replacement Procedure in LVM

pvcreate /dev/sdf  Creating the pv of new disk


vgextend vg_app /dev/sdf
pvmove /dev/sde<faulty disk> /dev/sdf <new disk> Moving the data from faulty disk to new disk
pvremove /dev/sde
vgreduce –removemissing vg_app

dmsetup info  It’s a low level logical volume management. For getting details of the all LVM fs on the
server.
[root@IETEST ~]# dmsetup info
Name: VolGroup00-data_lv
State: ACTIVE

dmsetup suspend VolGroup00-data_lv


dmsetup resume VolGroup00-data_lv
How to create LV snapshot

Lvcreate –s -L 20M –n snap /dev/newvg/newlv To take snapshot


Ls /dev/newvg To check the snapshot
(* delete file to check, unmount Fs umount /data)
Lvchange –an /dev/newvg/newlv To deactivate lv
Lvchange –ay /dev/newvg/newlv To activate lv
Lvconvert –merge /dev/newvg /snap
Mount –a

## a striped volume called lvol1 (note the captial i for the stripe size), can use -l (extents) instead of -L
lvcreate -i 3 -L 24M -n lvol1 vg01
## Mirrored volume
lvcreate -L 10M -m1 -n data01 vg01
-------------------------------------------------------------------------------------------------------------------------------------
## Mirrored volume without a mirror log file
lvcreate -L 10M -m1 --mirrorlog core -n data01 vg01
Common Attributes that you may want to use:
-L size of the volume [kKmMgGtT]
-l number of extents
-C contiguous [y|n]
-i stripes
-I stripe size
-m mirrors
--mirrorlog
-n volume name
##adding a mirror to a non-mirrored volume
lvconvert -m1 --mirrorlog core /dev/VolData00/vol01 /dev/sdb2
##removing a mirror from a mirrored volume
lvconvert -m0 /dev/VolData00/vol01 /dev/sdb2
##Mirror a volume that has stripes
lvconvert --stripes 3 -m1 --mirrorlog core /dev/VolData00/data01 /dev/sdd1 /dev/sde1 /devsdf1
##snapshot
lvcreate --size 100M --snapshot -name snap /dev/vg01/data01

To List the HBA Card Details

systool -c fc_host -v ==> To Check FC info, WWN

systool -c fc_transport -v ==> To Check FC info, WWN

systool -c fc_remote_ports –v

systool -c fc_vports –v

Listing the HBA card wwwn No:


bash-4.1# cd /sys/class/fc_host/host1
bash-4.1# cat node_name
0x20000000c9fc8af5

To check the LUN id of the disk

multipath -ll
/dev/disk/by-id

Multipathing - RHEL6

# mpathconf --enable --with_multipathd y


#multipath -ll

Steps for Configuring Mulitpath

Package Required: device-mapper-multipath

Config File:
/etc/multipath.conf
OR
/usr/share/doc/device-mapper-multipath-0.4.9/multipath.conf

If you do not need to edit the /etc/multipath.conf file, you can set up DM-Multipath for a basic failover
configuration by running the following command. This command enables the multipath configuration file
and starts the multipathd daemon.

# mpathconf --enable --with_multipathd y

If you need to edit the /etc/multipath.conf file before starting the multipathd daemon. use the


following procedure to set up DM-Multipath for a basic failover configuration.

# mpathconf –enable

Edit the /etc/multipath.conf file if necessary. The default settings for DM-Multipath are compiled in to
the system and do not need to be explicitly set in the /etc/multipath.conf file.
The default value of path_grouping_policy is set to failover, so in this example you do not need to edit
the /etc/multipath.conf file. For information on changing the values in the configuration file to
something other than the defaults

Save the configuration file and exit the editor, if necessary.


Execute the following command:
# service multipathd start
If you find that you need to edit the multipath configuration file after you have started the multipath
daemon, you must execute the below  command for the changes to take effect.

#service multipathd reload

Black Listing Device by WWID

#vi /etc/multipath.conf

blacklist {
wwid SIBM-ESXSST336732LC____F3ET0EP0Q000072428BX1
}

# service multipathd reload

Run the following command to remove the multipath device:


#multipath -f SIBM-ESXSST336732LC____F3ET0EP0Q000072428BX1

In the o/p of #mulitpath -ll, above mentioned device will not list.

Setting Up Multipathing in the initramfs File System

You can set up multipathing in the initramfs file system. After configuring multipath, you can rebuild
the initramfs file system with the multipath configuration files by executing the dracut command

# dracut --force --add multipath --include /etc/multipath /etc/multipath

If you run multipath from the initramfs file system and you make any changes to the multipath
configuration files, you must rebuild the initramfs file system for the changes to take effect.

Rebuilding Initial Ramdisk Image (initramfs)

Rebuilding the initrd (RHEL 3, 4, 5)

It is recommended you make a backup copy of the initrd in case the new version has an unexpected
problem:
$ cp /boot/initrd-$(uname -r).img /boot/initrd-$(uname -r).img.$(date +%m-%d-%H%M%S).bak
Here: $ cp /boot/initrd-2.6.32-220.el6.i686kdump.img $ cp /boot/initrd-2.6.32-
220.el6.i686kdump.img.25102014.bak

Now build the initrd:


$ mkinitrd -f -v /boot/initrd-$(uname -r).img $(uname -r)
The -v verbose flag causes mkinitrd to display the names of all the modules it is including in the initial
ramdisk.
The -f option will force an overwrite of any existing initial ramdisk image at the path you have specified
If you are in a kernel version different to the initrd you are building (including if you are in Rescue Mode)
you must specify the full kernel version, without architecture:
$ mkinitrd -f -v /boot/initrd-2.6.18-348.2.1.el5.img 2.6.18-348.2.1.el5

Rebuilding the initramfs (RHEL 6, 7)

It is recommended you make a backup copy of the initrd in case the new version has an unexpected
problem:
$ cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.$(date +%m-%d-%H%M%S).bak
Here: $ cp /boot/initramfs-2.6.32-220.el6.i686.img /boot/initramfs-2.6.32-220.el6.i686.img.10-25-
125700.bak

Now rebuild the initramfs for the current kernel version:


$ dracut -f -v

If you are in a kernel version different to the initrd you are building (including if you are in Rescue Mode)
you must specify the full kernel version, including architecture:
$ dracut -f /boot/initramfs-2.6.32-220.7.1.el6.x86_64.img 2.6.32-220.7.1.el6.x86_64

Taking OS Backup (Native Tool)


dump -0u -f /backup/varbkp /var
restore –i –f /backup/varbkp

rsync -aAXv /* /backup/ --exclude={/dev/*,/proc/*,/sys/*,/run/*,/media/*,/lost+found} Backup


rsync -aAXv /backup/* / --exclude=boot = Restore

Manage system software

RPM- Redhat Package Management


rpm –qa To check the rpm
rpm –e <pkgname> To uninstall rpm
rpm –ivh <pkgname> To install rpm
rpm –qf /usr/sbin/vsfpd To know the rpm integrated with this package
rpm –qpl <pkgname> It will display all the integrated location for that package or service
rpm-Uvh vsftpd To update the package
rpm –ivh –nodeps –force To install forcefully without dependency
rpm –qi vsftpd To check more about the package

sysstat-9.0.4-20.el6.x86_64 = RPM using for system performance monitoring commands. mpstat,sar…


etc
YUM

yum repolist
yum clean all To clean yum
yum install samba To install package
yum update It will update all available rpm
yum list update It will list all new updated packages
yum update <pkg> It will update only mentioned package
yum list all It will list all files in repo
yum remove samba To uninstall a package
yum info <pkgname> To know about a package
yum grouplistall
yum groupinstall “Directory Client”
yum groupremove
yum search <pkgname>
createrepo /var/ftp/pub/rhel/dvd To generate/create repo

yum whatprovides */libldap-2.3.so.0 ==> To find the package related to file libldap-2.3.so.0
Here Its package is: compat-openldap-2.3.43-2.el6.i686

Yum Group Repo Creation:

#rpm –qa |grep –I yum-utlis

Go to the repodata dir of CD/ISO image(/media/Packages/repodata), and copy to the local repo path
(/backup/packages)
#cp *-comps-rhel6-Server.xml /backup/packages/comps.xml

Then, create repo group.


#cd /backup/packages
#createrepo -g comps.xml /backup/packages

#yum clean all


#yum grouplist

Yum Repo Creation Procedure Locally in RHEL

Server Side:

#copy all rpms in /var/ftp/pub/cdrom

Install the rpm createrepo-0.9.8-4.el6.noarch.rpmfor executing createrepo command also install its
dependency packagesdeltarpm and python-deltarpm

#createrepo /var/ftp/pub/cdrom/
#cd /etc/yum.repos.d==>vi example.repo
[unixreposerver]
name=linux repo
baseurl=file:///var/ftp/pub/cdrom
enabled=1
gpgcheck=0

If we are getting “public key for package xxxx is not installed” error, change the gpcheck value and give
the key.

gpcheck=1
gpkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

Also execute the command #rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

OR

#copy all rpms in /var/www/html/pub/cdrom


#createrepo /var/www/html/pub/cdrom
#cd /etc/yum.repos.d==>vi example.repo
[unixreposerver]
name=linux repo
baseurl=http://10.0.7.50/pub/cdrom
enabled=1
gpgcheck=0

Creating Repo Server - By keeping Repodata in Different Path

#Here copying all packages in /yum-repo

createrepo /yum-repo

# vi /etc/httpd/conf.d/repo.conf
Alias /repo/ "/yum-repo/"

#service httpd start

#vi /etc/yum.repos.d/local.repo
[Localrepo]
name=RHEL6.2 Repo
baseurl=http://10.1.46.81/repo/
enabled=1
gpgcheck=1
######################################################################
For importing gpgcheck key from iso mount point /mnt. It is required if gpgcheck=1
rpm --import /mnt/RPM-GPG-KEY-redhat-release
rpm --import /mnt/RPM-GPG-KEY-redhat-beta
######################################################################
elinks http://10.1.46.81/repo/repodata/repomd.xml ==> For cheking through browser

Client Side:

#yum clean all ==> Clean all repos


#yum repolist ==> refreshing teh repolist by reading /etc/yum.repos.d/linuxhttp.repo file

[root@PKICK01 yum.repos.d]# pwd


/etc/yum.repos.d
[root@PKICK01 yum.repos.d]# cat linuxhttp.repo
[unixreposerver]
name=linux repo
baseurl=http://10.0.7.50/pub/cdrom
enabled=1
gpgcheck=0

Yum Repo Creation Procedure RHEL Network

https://access.redhat.com/home
Login: futuregroup_redhat
Pswd: Redhat123

Go to Subscriptions and remove the existing client

Update the below entry in /etc/sysconfig/rhn/up2date file of server


1. proxyPassword=temproot
2. proxyUser=unix-patch
3. httpProxy=10.0.4.11:3128
4. enableProxyAuth=1
5. enableProxy=1
# rhnreg_ks --username=futuregroup_redhat --password=Redhat123 Command for
registering

Downloading rpm from YUM Repo

Downloadonly plugin for yum


Install the package including "downloadonly" plugin:

(RHEL5)
# yum install yum-downloadonly

(RHEL6)
# yum install yum-plugin-downloadonly

Run yum command with "--downloadonly" option as follows:


# yum install --downloadonly --downloaddir=<directory><package>

Confirm the RPM files are available in the specified download directory.

Yumdownloader
If downloading a installed package, "yumdownloader" is useful.

Install the yum-utils package:

# yum install yum-utils


Run the command followed by the desired package:

# yumdownloader<package>

Redhat Package Rollback (Yum & RPM)

RHEL5 /CentOS
We can setup a RPM rollback using two simple steps on Centos 5 or RHEL5,
Step 1)Create a file called macros
[root@kernelmount ~]# cat  /etc/rpm/macros
%_repackage_all_erasures 1

Step 2)Add tsflags=repackage   line at end of yum configuration file,


[root@kernelmount ~]# tail -1 /etc/yum.conf
tsflags=repackage

Install the package / yum update

Check the rpm backup for reinstalling old packages


#ls -l /var/spool/repackage

ROLL back RPM:


If OS updated with in one hour period
#rpm -Uvh --rollback '1 hour ago'

if yesterday
#rpm -Uvh --rollback '1 day ago'
if OS updated on a week ago,
#rpm -Uvh --rollback '1 week ago'

if OS update on Mar 20th,


#rpm -Uvh --rollback 'March 20'

---------------------------------------------------------------------------------------------------------------------------------------
RHEL6 :

To check all the previous history of RPM installation/update:


# yum history output will be below
ID     | Login user             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
47 | root <root>            | 2012-05-27 09:03 | Install        |    4   

To list/info/summary of 47th transactions


#yum history list 47 / # yum history info 47 / # yum history summary 47

To ROLLBACK All RPM'S in the particular transaction: ( To erase installed packages and To Install uninstalled
packages)
# yum history undo 47

To reinstall the rpm's which are erased via undo option:


# yum history redo 46

Yum database location:


# ls -ltr /var/lib/yum/yumdb/

Exporting Proxy:

export http_proxy=unix-patch:temproot@10.0.4.11:3128

Service Administration

service network status


service iptables restart/stop/start

/etc/init.d/network status
/etc/init.d/iptables restart/stop/start

chkconfig --list | grep -i iptables Listing permanent service status, after rboot also.
chkconfig network on  To on network service permanently
chkconfig network off  To off network service permanently
chkconfig network --level 1 off For making network service off on run level1
Selinux is an kernel level security, it is developed by NSA

getenforceTo check selinux mode


sestatus To check selinux status

Enforce=1=enable
Permissive=0=Disable

setenforce 0 disabling selinux

#vi /etc/sysconfig/selinux
SELINUX=disabled

Network Administration

system-config-network To enter to the network setup GUI


setup To enter to the network setup GUI

nmap localhost
nmap 10.0.7.50 To check the opened port in the server
ip route It will show the ip tables in linux
dig –t 10.0.7.50 It will show details with DNS servers
/etc/resolv/conf DNS servers details need to be updated here
netstat -tunlp |grep -i 21 To chek wheather the mentioned port is opened
netstat –tunlp To see all the opened ports in the server

Hostname Change:
# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=PAVXDX513

# cat /etc/hosts
10.0.26.31 PAVXDX513

OR
sysctl kernel.hostname=NEW-HOSTNAME

IP Configuration

Normal Configuration

# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:CF:F3:CB
IPADDR=10.15.1.3
NETMASK=255.255.255.0
GATEWAY=10.15.1.1
ONBOOT=yes

ip link  To list the NIC


ethtool eth0  To list the properties of the NIC eth0
mii-tool eth0  To list the properties

mii-tool -F 100baseTx-HD Setting parameter by using mii-tool

ethtool -s eth0 speed 100 duplex full Setting the speed =100 and duplex=full for the interface eth0

For making these settings permanently. Append the below line in ifcfg-eth0 file
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
ETHTOOL_OPTS="speed 100 duplex full autoneg off"

Bonding Without VLAN:


1 .Create a Bond0 Configuration File:
#cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.1.20
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

2: Modify the existing eth0 and eth1 config


#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

#cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
3: Load bond driver/modul
# vi /etc/modprobe.d/bonding.conf Append following two lines:
alias bond0 bonding
options bond0 mode=balance-alb miimon=100 or options bond0 mode=1 miimon=100
4: Test configuration
modprobe bonding

Restart the networking service in order to bring up bond0 interface, enter:


service network restart

5.Type the following command to query the current status of Linux kernel bonding driver, enter:

#cat /proc/net/bonding/bond0
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 200
Down Delay (ms): 200
Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:59
Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:c6:be:63
Bonding With VLAN
-bash-4.1# ifconfig -a
bond0 Link encap:Ethernet HWaddr 34:40:B5:BE:E4:28
inet6 addr: fe80::3640:b5ff:febe:e428/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:40731847707 errors:280 dropped:926099 overruns:1300 frame:280
TX packets:49259824458 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:37135621905390 (33.7 TiB) TX bytes:54652939045444 (49.7 TiB)

bond0.8 Link encap:Ethernet HWaddr 34:40:B5:BE:E4:28


inet addr:10.0.8.127 Bcast:10.0.8.255 Mask:255.255.255.0
inet6 addr: fe80::3640:b5ff:febe:e428/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:11315035341 errors:0 dropped:0 overruns:0 frame:0
TX packets:2667122919 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:525210854463 (489.1 GiB) TX bytes:33132625305174 (30.1 TiB)

bond0.26 Link encap:Ethernet HWaddr 34:40:B5:BE:E4:28


inet addr:10.0.26.31 Bcast:10.0.26.255 Mask:255.255.255.0
inet6 addr: fe80::3640:b5ff:febe:e428/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:29416812366 errors:0 dropped:0 overruns:0 frame:0
TX packets:18088898934 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:36040165183029 (32.7 TiB) TX bytes:21474031324178 (19.5 TiB)

eth0 Link encap:Ethernet HWaddr 34:40:B5:BE:E4:28


UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:40678183871 errors:140 dropped:926099 overruns:1300 frame:140
TX packets:49259824459 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:37131672317972 (33.7 TiB) TX bytes:54652939046542 (49.7 TiB)

eth1 Link encap:Ethernet HWaddr 34:40:B5:BE:E4:28


UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:53663836 errors:140 dropped:0 overruns:0 frame:140
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3949587418 (3.6 GiB) TX bytes:0 (0.0 b)
-bash-4.1# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
USERCTL=no
ONBOOT=yes

-bash-4.1# cat /etc/sysconfig/network-scripts/ifcfg-bond0.8


DEVICE=bond0.8
VLAN=yes
ONBOOT=yes
IPADDR=10.0.8.127
NETMASK=255.255.255.0
USERCTL=no
TYPE=ETHERNET

-bash-4.1# cat /etc/sysconfig/network-scripts/ifcfg-bond0.26


DEVICE=bond0.26
VLAN=yes
ONBOOT=yes
IPADDR=10.0.26.31
NETMASK=255.255.255.0
USERCTL=no
GATEWAY=10.0.26.1
TYPE=ETHERNET

-bash-4.1# cat /etc/sysconfig/network-scripts/ifcfg-eth0


DEVICE=eth0
NM_CONTROLLED=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
TYPE=Ethernet
BOOTPROTO=none
USERCTL=no
HWADDR=34:40:b5:be:e4:28
IPV6INIT=no
-
-bash-4.1# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
USERCTL=no
HWADDR=34:40:b5:be:e4:2c
IPV6INIT=no

-bash-4.1# cat /etc/modprobe.d/bonding.conf


alias bond0 bonding
options bond0 mode=1 miimon=100

-bash-4.1# cat /proc/net/bonding/bond0


Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: fault-tolerance (active-backup)


Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0


MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 34:40:b5:be:e4:28
Slave queue ID: 0

Slave Interface: eth1


MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 34:40:b5:be:e4:2c
Slave queue ID: 0
Modes of Bonding:

Mode 0 (balance –rr) :Sets a round-robin policy for fault tolerance and load balancing.

Mode 1 (active–backup) : Sets an active-backup policy for fault tolerance. Another bonded slave
interface is only used if the active bonded slave interface fails.

Mode 2 (balance–xor) :Sets an XOR (exclusive-or) policy for fault tolerance and load balancing.

Mode 3 (broadcast) : Sets a broadcast policy for fault tolerance. All transmissions are sent on all slave
interfaces.

Mode 4 (802.3ad) :Sets an IEEE 802.3ad dynamic link aggregation policy.

Mode 5 (balance-tlb) : Sets a Transmit Load Balancing (TLB) policy for fault tolerance and load balancing.

Mode 6 (balance-alb) : Sets an Active Load Balancing (ALB) policy for fault tolerance and load balancing.

Parameters (etc)

Security Logs:

cat /etc/syslog.conf
cat /etc/logrotate.conf
cat /etc/audit/auditd.conf

Memory Parametes:

cat /etc/sysctl.conf – Parameters setting globally (/etc/system)

sysctl –p  setting the parameters permanently by reading the kernel.

sysctl –a  Listing the parameters

cat /etc/security/limits.conf – Parametrs setting userwise (/etc/projects)

Tuning and maintaining the kernel


Uname –a, uname –m
How to upgrade
Create a local repo and start
yum install kernel
vi /etc/grub.conf
modeprobe –I fuse
modeinfo fuse

How To set parameter


vi /etc/grub.conf
root rd_NO_LUKS
sysvctl=1………rhgh quiet
After setting the parameter ,reboot the server .
Cat /proc/cmdline It will list the parameter

IP Forwarding
Vim /etc/sysctl.conf
net.Ip4.IP_forward=0 change it to 1 :wq!
sysctl –p To load

Loop mounting
# mount -o loop disk1.iso /mnt

#mount /dev/cdrom /media Mounting CDROM or isoimages connected in vmware

Changing NIC interface from OS Level on basis of MAC ID Level

[root@PMSTRA551 /]#cat /etc/udev/rules.d/70-persistent-net.rules

# PCI device 0x8086:0x100e (e1000)


#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="06:c7:ed:00:00:09", ATTR{type}=="1",
KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100e (e1000)


#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="06:64:cb:00:00:18", ATTR{type}=="1",
KERNEL=="eth*", NAME="eth1"

#PCI device 0x1af4:0x1000 (virtio-pci)


SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="06:f1:8e:00:00:11", ATTR{type}=="1",
KERNEL=="eth*", NAME="eth0"

Remove the # from required lines.

User Administration

useradd –s /sbin/nologin tom To create a user with nologin


useradd –d /mnt/joy To create a user with home directory mentioned
usermod –l nun oun To change the user name
usermod -u 700 un To modify the User ID
usermod –L username To lock the user
usermod –U username To unlock the user
groupadd<GN> To create new group
groupdel<GN> To modify the group
groups tom To show the groups for the user
groupmod –n <Newgroup><oldgroup> To rename the group name
usermod –G sales sam To modify user groups
usermod –G sales,mkt sam To add multiple groups
usermod –G sales sam To append the groups without changing existings
gpasswd –d sam sales To delete a user from a group
gpasswd –a sam sales To append a user to the group

Xstart Configutration:

yum install xterm*


yum install xorg-x11

Then try xclock command.

Xmanager Setting in Linux

[root@PTREXA751 gdm]# cat /etc/gdm/custom.conf


# GDM configuration storage

[daemon]
RemoteGreeter=/usr/libexec/gdmgreeter
[security]
AllowRemoteRoot=true

[xdmcp]
Enable=true
[greeter]

[chooser]

[debug]

Execution Command in xstart window:


/usr/X11R6/bin/xterm -ls -display $DISPLAY
or
/usr/bin/xterm -ls -display $DSIPLAY

Performance Monitoring
echo 1 > /proc/sys/vm/drop_caches It will clear the cache memory and give us the space as free

ps -auxf | sort -nr -k 3 | head -10 ==> Top 10 users consuming cpu
ps -aux | sort -nr -k 4 | head -10 ==> Top 10 users consuming memory
free –m
top

cat /proc/cpuinfo | grep “physical id” | sort | uniq | wc –l  To list the number of processors

cat /proc/cpuinfo | grep “cpu cores” | uniq To list no: of cores

#iostat -x 2  disk utilization details.


O/P:
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util

The high disk utilization is typically observed when %util field in the iostat output reaches up to 90-100%

STDIN STDOUT SDTERR Standard IOs


Date > date.txt To redirect the output to defferent
Cal >> date.txt To append the list
Tr ‘a-z’ ‘A-Z’ </test/f1 To change the case
grep -n root /etc/passwd To grep for the word
grep –color root /etc/passwd To show the color files

Deploy File sharing services


FTP HTTP(apache/webserver)
FTP – Anonymous ftp=/var/ftp , Local ftp=/home/tom Package= vsftpd
Vi /etc/vsftpd/vsftpd.conf (anonymous_enable=YES :q!) To enable anonymous access
Service vsftpd status , stop and restart
Chkconfig –list vsftpd
Chkconfig vsftpd on
ftp 192.168.0.250 To connect
ftp ftp is the user name and passwd for anonymous login
mget<fn> To download a file
cat /var/log/xferlog To check the var messages
nmap<ip> To check the port
Web server :- Appache(http=80) Tomcat Package= httpd
/var/www/html Here we have to create ‘index.html’
Cat >index.html (WELCOME TO MY PAGE) this name should be same
Service httpd status, restart
Chkconfig httpd on
Links 192.168.0.250 To connect from client
Elinks 192.168.0.250 From command prompt
Cat /var/log/httpd/access-log To check http logs
Cat /var/log/httpd/error-log To check error logs

Automated installation/Kickstart
Automated installation/Kickstart

(in server the services DHCP,tftp it has to be enabled)

*pxe should be enabled in the client machine for network boot==> enable from bio prompt
---------------------------------------------------------------------------------------------------------------------------
Kickstart server configuration
Yum install system-config-kickstart

Desktops-desktop-xwindows system this package need to be enable to configure kickstart in server as graphic

#system-config-kickstart To configure the kickstart server==> do it from graphics

Basic configuration-Language, root passwd, Timezone etc.


Installation methord- FTP, HTTP, Harddrive FTP server=192.168.0.254, FTP Directory= pub/rhel6/dvd
Boot loader, partition information ,
Network configuration-Add networkdevice Network device=eth0, IP=DHCP
Authentication, Firewall configuration, Display,
Package selection- Desktops-Desktop-windows desktop
Preinstallation script, post installation script
*update above details and File-save .
*by default ks.cfg file will be created , copy the file to our location eg: /var/ftp/pub or
/var/www/html/pub/kickstart

OR

Create ks.cfg file be mentioning below details.


copy the iso image in /var/www/html/pub directory or ftp dir
# cd /var/www/html/pub
# ls -ltr
drwxr-xr-x. 12 root root 4096 Jul 3 2013 RHEL6.3
drwxr-xr-x. 7 root root 4096 Sep 20 2013 CENT5.4
drwxr-xr-x. 7 root root 4096 Sep 26 2013 CENT5-4
drwxr-xr-x. 2 root root 4096 Sep 26 2013 cent5
drwxr-xr-x 2 root root 4096 Nov 1 2013 cent5-5
drwxr-xr-x 2 root root 4096 Jan 8 13:05 rhel
drwxr-xr-x. 2 root root 4096 Jan 15 12:40 kickstart

#cd kickstart

*create the ks.cfg file on the location /var/ftp/pub or


/var/www/html/pub/kickstart-----------------------------------------------------------------------------------------------------------------
-------------

From Client Side


Boot from cd and select boot and type
linux ks=http://10.0.7.163:/pub/kickstart/ks.cfg append ip=10.0.8.92 netmask=255.255.255.0 gateway=10.0.8.1

Ks=ftp://192.168.0.106/pub/ks.cfg To start the installation from the client machine (select standard …. Then
space and “ks=ftp…)
Ks=http://server/ dir/file
Ks=ftp://server/dir/file
Ks=nfs:server:/dir/file
Ks=hd:device:/dir/file
Ks=cdrom:/dir/file

Hardlink and sympolic link


Ls –i a.txt To check the inode number
Ln /root/a.txt /a.txt To hard link a file
Ln –s file1 file2 To soft link a file from file1 to file2

KDUMP Configuration

Packages
system-config-kdump-1.0.14-4.el5 / kdump-1.0.14-4.el5
kexec-tools-1.102pre-77.el5

cat /etc/grub.conf
kernel /vmlinuz-2.6.18-164.el5 ******* crashkernel=128M@16M

vi /etc/kdump.conf
path /var/crash
core_collector makedumpfile -c --message-level 1

cat /etc/sysctl.conf
# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 1

Restart the Service


/etc/init.d/kdump restart

for panicking the OS


Alt+SysRq+C

User Quota

repquota -a ==> Listing the quota details


/etc/fsttab ==> after default,usrquota,gpquota on required mountpoint
remount the mounpoit
quotacheck -cug /mounpoint ==> creating quotadb
quotacheck -avug /mountpoint ==> enabling

Creating quota for user


edquota -u username

SSH Trust Relation:

Creating trust relationship b/w 26.38 to 30.100. ie taking ssh from 26.38 to 30.100 without asking
passwd.
For particular user, eg:billrp (billrp users should be there in both servers)
--------------------------------------------------------
From 26.38:
#su - billrp
Check the home directory of billrp. If id_rsa.pub is in the /homedirectory/.ssh. Go to
homedirectory/.ssh/. Exectute below command directly.

#ssh-copy-id -i id_rsa.pub billrp@10.0.30.100


---------------
If id_rsa.pub is not there, follow below step

#ssh-keygen

Go to /homedirectory/.ssh

#ssh-copy-id -i id_rsa.pub billrp@10.0.30.100

Swap Administration

Creating Swap Space


fdisk –cu /dev/vda create a normal partition and change the partition ID to 82 W to save , partprobe, reboot
mkswap /dev/vda5 To format as swap
swapon /dev/vda5 To activate swap space
swapon –s It will display the swap
swapon –a

swapoff /dev/sdc1  Remove the swap space

Creating swap file


dd if=/dev/zero of=/swapfile bs=1M count=128 To create a swap using file
cat swapfile
mkswap /swapfile
swapon swapfile
swapon –s
update in /etc/fstab to make permanent .
swapon –a

swapoff /swapfile  To remove the swap file

Creating SWAP by using 4gb slice.

#fdisk /dev/sdc
Command (m for help): p
Command (m for help): n
p
Partition number (1-4): 1
Last cylinder, +cylinders or +size{K,M,G} (1-10240, default 10240): 4096
Command (m for help): p
Command (m for help): t
Hex code (type L to list codes): 82
Command (m for help): p
Command (m for help): w
The partition table has been altered!
#partprobe
#mkswap /dev/sdi1
#swapon /dev/sdi1
#swapon -s
#free -g
#vi /etc/fstab

NFS
Server Side:
Create a directory and touch files eg: /new
vi /etc/exports
/new 192.168.0.0/255.255.255.0(ro,sycn,no_root_squash)
exportfs –a To export all

Share Options:
root_squash : nfs client root user can’t modify files from client side. By default options is root_squash
no_root_squash : nfs client root user can modify files from client side

Client Side:
showmount –e
mount –t nfs 192.168.0.0:/new /test

Autofs:
#vi auto.master
/demo /etc/auto.demo create this line below the /misc line.

#cp -pr auto.misc auto.demo


#vi auto.demo
public<tab> –rw,intr,soft <tab> 10.15.1.5:/wipro  make this entry in last line

service autofs restart  To restart the service


or
service autofs stop
service autofs start

cd /demo ls . No public will show but cd public it will work .

CIFS - Samba
Sambaclient is the package name
Smbclient –L 192.168.0.254 To list the shared from the server
Samba Server
Samba provides 4 main service
1 authentication and authorization of users
2 file and printer sharing
3 name resolution
4 Browsing
*CIFS is the filesystem is used by samba
CIFS Common Internet Filesystem
Three packages required for samba-(samba, samba-client,samba-common-samba) port-445
/etc/samba/smb.conf This is the configuration file
2 types of samba configuration public users and private users
*samba_share_t This is the selinux contest
How to configure as public
*Install 3 packages then edit the file
Vi /etc/samba/smb.conf
….WORKGROUP=fg.net
Then go to last line
[winshare]
Path =/linux
Public =yes
hosts allow =192.168.0. 127
Browsable =yes :wq!

Service smb restart


Service chkconfig on
Client Side
Smbclient //192.168.0.250/winshare –N
Incase if it is not accessible, then check the selinux contest eg: ls –lZd linux .change from “default_t:s0 to samba-
share_t
Chcon –t samba_share_t /linux
Ls –lZd /linux
Smbclient //192.168.0.250/winshare –N
To access from Browser
Smb://192.168.0.250/winshare
How to configure as private/valid
Vi /etc/samba/smb.conf
[winshare]
Path /linux
Valid users =tom
Hosts allow =192.168.0. 127.0
Browseable =yes :wq!
Smbpasswd –a tom To add user to the samba
And set the password eg: 123
Smbpasswd –e tom To enable
Service smb restart
10
Chkconfig smb on

Client Side
Smbclient //192.168.0.250/winshare –U tom

Mount –o username=guest200 //192.168.0.254/ftp /remote/ To mount (provide the blank password)


Cd /net This is the location all the NFS shares will be available .(cd 192.168.0.254)

Chage
chage –m 0 –M 90 –W 7 –I 14 student To change the user password settings
chage –l student To list the user information
chage –E 0 student To expire the user now
chage –E never student To remove expiry
chage –d 0 student To change the password at next logon

Network user account with LDAP (port/Code=389) LDAP is fast and secured

Cat /etc/services here it will display all the port numbers


Dc=example,dc=com
Yum groupinstall Directory-Client This package is required for LDAP client configuration
system-config-authentication editing for LDAP client
User Account Database – LDAP
LDAP search base- dc=example,dc=com
7.
LDAP server- instructor.example.com
Authentication methord – LDAP password
*Select use TLS to encrypt
Download certificate
Certificate URL: http://instructor.example.com/pub/EXAMPLE-CA-CERT
Ok and Apply
*SSD is the daemon for LDAP client
Getent passwd ldapuser10 This the command to access the ldap user from the client
Showmount –e 192.168.0.254 To see the remote NFS shared .
How to set Home directory for ldapusers
*/home/guests*is the home directory for ldap users (in the server)
Vi /etc/auto.master
(under misc) /home/guests /etc/auto.misc :wq!
Vi /etc/auto.misc go to the last line, ldapuser11 <tab> -rw,soft,intr<tab>
instructor.example.com:/home/guests/ldapuser11 :wq! (or Ip also can use)
Service autofs reload To reload the autofs service
Su – ldapuser11 To switch to ldap user
Vi /etc/auto.misc (* <tab> -rw/soft,intr <tab> instructor.example.com:/home/guests/&) :wq! To set
access for all users

Mail Server
MTA Mail Transport Agent - MDA Mail Delivery Agent - MRA Mail Receiving Agent - MX Mail exchange Record

*’postfix’ is the package required for mail server


vi /etc/postfix/main.cf
inet_interface=localhost change it to all
service postfix restart& chkconfig postfix on

#mail root@demo.example.com mail fg-unix-team@futuregroup.in


Redirection of mails
Vim /etc/alias
Go to the last line and add
root: jack :wq!
Newaliases To refresh or add new aliases
mailroot@demo.example.com
mail –u jack

Web Server
Appache webserver
http hyper text terminal Protocol
httpd is the package
/etc/httpd/conf/httpd.conf
Httpd_sys_content_t Selinux context
http- 80
https -443
IP based webhosting and Domain based web hosting
Yum install httpd
Vi /etc/httpd/conf/httpd.conf
Copy the last 7 lines and pastto the end
Edit only 1, 3 4 7 lines edit and save
1-Virtua host 192.168.0.250:80>
Document Root /var/www/html
Server Name demo.example.com
#<Virtual Host> remove this # :wq!
Httpd –t To check the updated file has any mistakes
Create a file under /var/www/html
Cat >index.html
Service httpd status
Service httpd restart
Chkconfig httpd on
To restrict the IP based hosting from others to access
Edit the same file
Vi /etc/httpd/conf/httpd.conf
:582 go to 582 line and copy 6 lines and past to the end and edit those lines
<directory “/var/www/html”>
Allow from 192.168.0.250 :wq!

How to break the root password


*Reboot the system, while rebooting press ‘e’ when shows ‘Redhat…..
*select kernel…….. ‘e’
*Type ‘1’ to boot as single user mode
*’b’ to boot the server
*Then it will go to the single user mode .#passwd root To change the root password

Booting to Rescue Mode

Boot from CD
Type boot: ‘’linux rescue’’

chroot /mnt/sysimage

grub-install /dev/sda  Installing corrupted grub from rescue mode on the /boot device /dev/sda

sudo iptables -t nat -A PREROUTING -p tcp -m tcp --dport 21 -j REDIRECT --to-ports 60021 Re-directing the port
21 to different port 60021
VNC

Vnc packages : xterm, xorg

Steps for starting vnc, execute the cmd


: #vncserver

Date and Time Changing

date +%Y%m%d -s "20140812"

date +%T -s "12:06:13"

 #uname –m = To check the architecture of os


x86_64 ==> 64-bit kernel
i686 ==> 32-bit kernel

URL For downlaoding Wine Package

https://access.redhat.com/solutions/41579
https://access.redhat.com/solutions/3358
http://dl.fedoraproject.org/pub/epel/6/x86_64/repoview/wine.html

Anda mungkin juga menyukai