0% found this document useful (0 votes)
845 views275 pages

Linux L2 PDF

This document contains notes for a Linux Level 2 training course. It covers topics such as managing partitions and file systems, logical volume management and RAID, user administration and permissions, networking, SELinux, booting procedures, job automation, remote administration with SSH, memory management, software management, backups, services, processes, FTP, NFS, Samba, time synchronization, DNS, DHCP, web servers, mail servers, iSCSI, databases, logging, firewalls, virtualization, installation methods, storage management, clustering, and monitoring with top. The key files related to mounting in Linux are /etc/fstab, which stores permanent mount points, and /etc/mtab, which stores currently mounted file systems

Uploaded by

amudhanaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
845 views275 pages

Linux L2 PDF

This document contains notes for a Linux Level 2 training course. It covers topics such as managing partitions and file systems, logical volume management and RAID, user administration and permissions, networking, SELinux, booting procedures, job automation, remote administration with SSH, memory management, software management, backups, services, processes, FTP, NFS, Samba, time synchronization, DNS, DHCP, web servers, mail servers, iSCSI, databases, logging, firewalls, virtualization, installation methods, storage management, clustering, and monitoring with top. The key files related to mounting in Linux are /etc/fstab, which stores permanent mount points, and /etc/mtab, which stores currently mounted file systems

Uploaded by

amudhanaya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 275

[Pick the date] [LINUX NOTES FOR LEVEL 2]

1. Managing Partitions and File Systems 2-8


2. Logical Volume Management and RAID Levels 9- 20
3. User and Group Administration, SUDO and Permissions 21 - 35
4. Network Configuration and Troubleshooting 36 - 47
5. Managing SELinux 48 - 49
6. Booting Procedure and Kernel parameters 50 - 55
7. Job Automation 56 - 60
8. Administrating Remote Systems (SSH) 61 -66
9. Memory Management (Swap) 67 - 69
10. Software Management 70 - 75
11. Backup and Restore 76 - 80
12. Managing Installed Services 81 - 83
13. Managing Process 84 – 93
14. FTP (File Transfer Protocol) Server 94 – 97
15. NFS (Network File System) Server, Autofs and LDAP Client 98 – 109
16. Samba Server 110 – 113
17. NTP (Network Time Protocol) or Chrony 114 – 114
18. DNS (Domain Naming System) 115 – 124
19. DHCP (Dynamic Host Configuration Protocol) 125 – 127
20. Web Server (Apache) 128 – 141
21. Mail Server 142 – 145
22. iSCSI (Remote Storage) 146 – 148
23. MySQL Server and MariaDB 149 – 151
24. Log Server and Log Files 152 – 154
25. Configuring IPtables and Firewall 155 – 159
26. Virtualization 160 – 161
27. General Questions 162 – 174
28. Kickstart Installation and PXE (Network) Installation 175 – 181
29. Veritas Volume Manager and Veritas Cluster 182 – 195
30. RedHat Cluster 196 – 201

Ratnakar Page 1
[Pick the date] [LINUX NOTES FOR LEVEL 2]

31. Examples of top command 202 - 209


1. Managing Partitions and File Systems

1. What is partition?
A partttio is a ctiotigutgus set tf bltcks tio a dri e that are treated as iiodepeiodeiot disk.
2. What is partitioning?
Partttioiioi meaios tt di ide a siioile hard dri e iiott maioy ltiical dri es.
3. Why we have multiple partitions?
 Eiocapsgulate tgur data. Siioce fle system ctrrgupttio is limited tt that partttio tioly. St we caio
sa e tgur data frtm accideiots.
 We caio iiocrease the disk space efcieiocy. Depeiodiioi tio tgur gusaie we caio ftrmat the
partttio with difeereiot bltck sises. St we caio redguce the wastaie tf the disk.
 We caio limit the data irtwth by assiiioiioi the disk qguttas.
4. What is the structure of the disk partition?
 The frst secttr tf the O/SS disk ctiotaiios the MB R (MBaster ttt Rectrd).. The MB R is di ided
iiott 3 parts aiod it's sise is 512 bytes.
 The frst part is IPL (Iioital Prtiram Ltader). aiod it ctiotaiios the Sectiodary ttt Ltader. St
IPL is resptiosible ftr btttioi the O/SS aiod it's sise is 446 bytes.
 The sectiod part is PTI (Partttio Table Iioftrmattio).. It ctiotaiios the iogumber tf partttios tio
the disk sises tf the partttios aiod type tf the partttios.
5. Explain the disk partition criteria?
 E ery disk caio ha e max. 4 partttios. The 4 partttios are 3 Primary partttios aiod 1
Exteioded partttio.
 The MB R aiod O/SS will iiostall iio Primary partttio tioly.
 The Exteioded partttio is a special partttio aiod caio be fgurther di ided iiott mgultple ltiical
partttios.
6. How to identify the disks?
Iio Liiogux difeereiot types tf disks will be ideiotfed by difeereiot ioamiioi ctio eiottios.
 IDE). dri es will be shtwio as /Sde /Shda /Sde /Shdb /Sde /Shdc ...etc. aiod the partttios are
/Sde /Shda1 /Sde /Shda2 /Sde /Shda3 ...etc.
 iSCSI/SSCSI aiod SATA dri es will be shtwio as /Sde /Ssda /Sde /Ssdb /Sde /Ssdc ...etc. aiod the
partttios are /Sde /Ssda1 /Sde /Ssda2 /Sde /Ssda3 ...etc.
 Virtgual dri es will be shtwio as /Sde /S da /Sde /S db /Sde /S dc ...etc. aiod the partttios
are /Sde /S da1 /Sde /S da2 /Sde /S da3 ...etc.
IDE -----> Iioteirated Dri e Electrtioics.iSCSI -----> Iioterioet Small Scale System Iioterface.
SCSI -----> Small Scale System Iioterface.
7. What is file system?
It is a methtd tf sttriioi the data iio aio triaioised fashitio tio the disk. E ery partttio tio the disk
except MB R aiod

Ratnakar Page 2
[Pick the date] [LINUX NOTES FOR LEVEL 2]

Exteioded partttio shtguld be assiiioed with stme fle system iio trder tt make them tt sttre the
data. File system is applied tio the partttio by ftrmatioi it with a partcgular type tf fle
system.
8. What are the diferent types of file systems supported in Linux?
The Liiogux sgupptrted fle systems are ext2 ext3 ext4 xfs fat cdfs hdfs ist9660 ...etc.
The ext2 ext3 ext4 fle systems are widely gused iio RHEL-6 aiod xfs fle system is iiotrtdguced tio
RHEL-7. The fat fle system is gused tt maiiotaiio a ctmmtio sttraie betweeio Liiogux
aiod Wiiodtws O/SS.
The cdfs fle system is gused tt mtguiot the CD-ROMBs aiod the hdfs fle system is gused tt mtguiot
DVDs.
The ist9660 fle system is gused tt read CD/SDVD.ist imaie ftrmat fles iio Liiogux O/SS.
9. What is mounting and in how many types can we mount the partitions?
Attachiioi a directtry tt the fle system iio trder tt access the partttio aiod it's fle system is
kiotwio as mtguiotioi.
Iio ieioeral the sgub directtries guioder /Smiot directtry are the mtguiot ptiiots tt mtguiot the fle
systems.
There twt types tf mtguiotiois iio Liiogux/SUioix.
 Temptrary MBtguiotioi :
Iio a temptrary mtguiotioi frst we create a directtry aiod mtguiot the partttio tio that
directtry. gut this type mtguiotioi will last tioly tll the system is gup aiod tioce it is rebttted
the mtguiotioi will be ltst.
Example:# mtguiot <tpttios><de ice ioame><directtry ioame (mtguiot ptiiot).>
 Permaioeiot MBtguiotioi :
Iio this alst frst we create the directtry aiod tpeio the /Setc/Sfstab fle aiod make aio eiotry as
beltw
<de ice ioame><mtguiot ptiiot><fle system type><mtguiot tpttios><take a backgup tr
iott><fsck algue>
Wheioe er the system rebttts mtguiot the partttios acctrdiioi tt eiotries iio /Setc/Sfstab fle.
St these type tf mtguiotiois are permaioeiotly e eio afer the system is rebttted.
# mtguiot -a tt mtguiot the partttios withtgut rebttt).
10. What are diferences between the ext2, ext3, ext4 and xfs file systems?

S.No. Ext2 Ext3 Ext4 Xfs


1. Staiods ftr Sectiod Staiods ftr Third Staiods ftr Ftgurth Staiods ftr Exteioded fle
Exteioded fle system. Exteioded fle system. Exteioded fle system. system.
2. Dtes iott ha iioi Sgupptrts Jtgurioaliioi Sgupptrts Jtgurioaliioi Sgupptrts Jtgurioaliioi
Jtgurioaliioi featgure. featgure. featgure. featgure.
3. MBax. fle sise caio be MBax. fle sise caio be MBax. fle sise caio be MBax. fle sise caio be
frtm 16 G tt 2 T . frtm 16 G tt 2 T . frtm 16 G tt 16 T . frtm 16 G tt 8E .
4. MBax. fle system sise MBax. fle system sise MBax. fle system sise MBax. fle system sise
caio be frtm 2 T tt 32 caio be frtm 2 T tt 32 caio be frtm 2 T tt 1 caio be frtm 2 T tt

Ratnakar Page 3
[Pick the date] [LINUX NOTES FOR LEVEL 2]

T T E 16E .
*1E = 1024 Peta bytes.
5. Caioiott ctio ert ext fle We caio directly ctio ert We caio ctio ert all fle Uiomtguiot aiod mtguiot
system tt ext2. ext2 tt ext3 fle systems tt ext4 fle the fle system is
system. system. reqguired.

11. Which files are related to mounting in Linux?


/Setc/Smtab ----> is a fle which sttres the iioftrmattio tf all the cgurreiotly mtguioted fle systems
aiod this fle is dyioamic aiod keep tio chaioiiioi.
/Setc/Sfstab ----> is keepiioi iioftrmattio abtgut the permaioeiot mtguiot ptiiots. If we waiot tt make
tgur mtguiot ptiiot permaioeiot theio make aio eiotry abtgut the mtguiot
ptiiot iio this fle.
/Setc/Sfstab eiotries are:
1 2 3 4 5 6
de ice ioame mtguiot ptiiot fle system type mtguiot tpttios take a backgup shtguld
rguio
tr iott fsck tr iott
12. How to create diferent types of partitions?
# fdisk -l
# fdisk /Sde /Ssdc
Ctmmaiod (m ftr help). : io (type io ftr ioew partttio).
(p - primary). tr e - exteioded). : p (type p ftr primary partttio tr type e ftr exteioded
partttio).
First cyliioder : (press Eioter ftr defagult frst cyliioder).
Last cyliioder : + <sise iio K /SMB /SG /ST >
Ctmmaiod (m ftr help). : t (type t tt chaioie the partttio id).
(ftr example: 8e ftr Liiogux LVMB 82 ftr Liiogux Swap aiod 83 ftr Liiogux iotrmal partttio).
Ctmmaiod (m ftr help). : w (type w ttsa e the chaioies iiott the disk).
# partprtbe /Spartx -a/Skpartx /Sde /Ssdc1 (tt gupdate the partttioiioi iioftrmattio iio partttio
table).
13. How to make a file system in Linux?
# mkfs.ext2/Sext3/Sext4/Sxfs/S fat <de ice ioame> ( ftr example/Sde /Ssdc1).
14. How to mount the file systems temporarily or permanently?
# mkdir /Smiot/Stracle
# mtguiot /Sde /Ssdc1 /Smiot/Stracle (temptrary mtguiot).
# im /Setc/Sfstab
/Sde /Ssdc1 /Smiot/Stracle xfs defagults 0 0
Esc+:+wq!
# mtguiot -a (permaioeiot mtguiot).
15. How to delete the partition?
# fdisk /Sde /Ssdc
Ctmmaiod (m ftr help). :d (type d ftr delete the partttio).

Ratnakar Page 4
[Pick the date] [LINUX NOTES FOR LEVEL 2]

Partttio iogumber : (specify the partttio iogumber).


Ctmmaiod (m ftr help). : w (type w tt write the chaioies iiott disk).
# partprtbe/Spartx -a/Skpartx /Sde /Ssdc1(tt gupdate the partttio table withtgut restartioi the
system).
16. The partitions are not mounting even though there are entries in /etc/fstab. How to solve this
problem?
First check aioy wrtioi eiotries are there iio /Setc/Sfstab fle. If all are tk theio guiomtguiot all the
partttios by
execgutioi the beltw ctmmaiod
# gumtguiot -a
Theio mtguiot aiaiio mtguiot all the partttios by execgutioi the beltw ctmmaiod
# mtguiot -a
17. When trying to unmounting it is not unmounting, how to troubleshoot this one?
Stme tmes directtry refects errtr while guiomtguiotioi becaguse
(i). ytgu are iio the same directtry aiod tryiioi tt guiomtguiot it check with # pwdctmmaiod.
(ii). stme gusers are preseiot tr accessiioi the same directtry aiod gusiioi the ctioteiots iio it check
this with
# fguser -cgu <de ice ioame> (tt check the gusers wht are accessiioi that partttio).
# lstf <de ice ioame> (tt check the fles which are tpeio iio that mtguiot ptiiot).
# fguser -ck <tpeioed fle ioame with path> (tt kill that tpeioed fles).
Ntw we caio guiomtguiot that partttio gusiioi # gumtguiot <mtguiot ptiiot>
18. How to see the usage information of mounted partitions?
# df -hT (tt see de ice ioame fle system type sise gused a ailable sise guse% aiod mtguiot
ptiiot).
19. How to see the size of the file or directory?
# dgu -h <fleioame tr directtry ioame> (tt see the sise tf the fle tr all the fle sises iio that
directtry).
# dgu -h (tt see all the fle sises which are ltcated iio the preseiot wtrkiioi directtry).
# dgu .| strt -ior | head -io10 (tt see the biiiest fles frtm cgurreiot ltcattio).
# dgu -s * | strt -ior | head -io10 (tt see the biiiest directtries frtm that partttio).
# iocdgu (tt list biiiest fles aiod directtries we ha e tt iiostall the ncdu packaie beftre
execgutioi this).
20. How to assign a label to the partition?
# e2label <de ice ioame tr partttio ioame><label ioame> (tt assiiio the label tt that
partttio).
Example : # e2label /Sde /Ssdb1 tradisk (tt assiiio tradisk label tt /Sde /Ssdb1 partttio).
# mtguiot -l (tt list all the mtguioted partttios altioi with their labels).

21. How to mount a partition temporarily or permanently using label?


# mtguiot LA EL=<label ioame><mtguiot ptiiot>

Ratnakar Page 5
[Pick the date] [LINUX NOTES FOR LEVEL 2]

Example : # mtguiot LA EL=tradisk /Smiot/Stracle (tt mtguiot the tradisk label tio /Smiot/Stracle
directtry).
# im /Setc/Sfstab
LA EL=tradisk /Smiot/Stracle ext4 defagults 0 0
Esc+:+wq! (tt sa e aiod exit the fle).
# mtguiot -a (tt mtguiot the partttios).
# mtguiot (tt erify whether it is mtguioted tr iott).
22. How mount the partition permanently using block id (UUID)?
# blkid <partttio ioame tr disk ioame> (tt see the UUID tr bltck id tf that partttio).
Example : #blkid /Sde /Ssdb2 (tt see the UUID tr bltck id tf the /Sde /Ssdb2 partttio).
Ctpy that UUID with mtguse aiod paste it iio /Setc/Sfstab fle aiod make aio eiotry abtgut that.
Example: # im /Setc/Sfstab
UUID="{.......................}" /Smiot/Stracle ext4 defagults 0 0
Esc+:+wq! (tt sa e aiod exit).
23. What is the basic rule for swap size?
(i). If the sise tf the RAMB is less thaio tr eqgual tt 2G theio the sise tf the swap = 2 X RAMB sise.
(ii). If the sise tf the RAMB is mtre thaio 2G theio the sise tf the swap = 2G + RAMB sise.
24. How to create a swap partition and mount it permanently?
# free -m (tt see the preseiot swap sise).
# swaptio -s (tt see the swap gusaie).
# fdisk <disk ioame> (tt make a partttio).
Example: # fdisk /Sde /Ssdb
Ctmmaiod (m ftr help). : io (tt create a ioew partttio).
First cyliioder : (press Eioter tt take as defagult algue).
Last cyliioder : +2048MB (tt create 2G partttio).
Ctmmaiod (m ftr help). : t (tt chaioie the partttio id).
Eioter the partttio Nt.: 2 (tt chaioie the /Sde /Ssdb2 partttio id).
Eioter the id : 82 (tt chaioie the partttio id Liiogux tt Liiogux Swap).
Ctmmaiod (m ftr help). : w (tt sa e the chaioies iiott the disk).
# partprtbe /Sde /Ssdb (tt gupdate the partttio table iioftrmattio).
# mkswap <de ice tr partttio ioame> (tt ftrmat the partttio with swap fle system).
Example : # mkswap /Sde /Ssdb2 (tt ftrmat the /Sde /Ssdb2 partttio with swap fle system).
# swaptio <de ice tr partttio ioame> (tt act ate the swap space).
Example : # swaptio /Sde /Ssdb2 (tt act ate /Sde /Ssdb2 swap space).
# free -m (tt see the swap sise).
# im /Setc/Sfstab (tt make aio eiotry tt permaioeiot mtguiot the swap partttio).
/Sde /Ssdb2 swap swap defagults 0 0
Esc+:+wq! (tt sa e aiod exit).
25. What are the atributes of the file system?
(i). Iiotde iogumber

Ratnakar Page 6
[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). File ioame


(iii).data bltck

26. What is inode number and what is the use of it?


Iiotde iogumbers are the tbjects the Liiogux O/SS guses tt rectrd the iioftrmattio abtgut the fle.
Geioerally iiotde iogumber ctiotaiios twt parts.
(a). Iiotde frst part ctiotaiios iioftrmattio abtgut the fle twioer its sise aiod its permissitios.
(b). Iiotde sectiod part ctiotaiios ptiioter tt data bltcks asstciated with the fle ctioteiot.
That's why gusiioi the iiotde iogumber we caio iet the fle iioftrmattio qguickly.
27. How to check the integrity of a file system or consistency of the file system?
y rguioioiioi the # fsck <device or partition name>ctmmaiod we caio check the iioteirity tf the
fle system.
gut beftre rguioioiioi the fsck ctmmaiod frst guiomtguiot that partttio aiod theio rguio fsck ctmmaiod.
28. What is fsck check or what are the phases of the fsck?
(a). First it checks bltcks aiod sises tf the fle system
(b). Sectiod it checks fle system path ioames
(c). Third it checks fle system ctioioect ity
(d). Ftgurth it checks fle system refereioce ctguiots (iotthiioi bgut iiotde iogumbers).
(e). Fiioally it checks fle system tccgupied cyliiodrical irtgups
29. Why the file system should be unmount before running the fsck command?
If we rguio fsck tio mtguioted fle systems it lea es the fle systems iio guiogusable state aiod alst
deletes the data.
St beftre rguioioiioi the fsck ctmmaiod the fle system shtguld be guiomtguioted.
30. Which type of file system problems you face?
(i). File system fgull
(ii). File system ctrrgupted
31. How to extend the root file system which is not on LVM?
y gusiioi # gparted ctmmaiod we caio exteiod the rttt partttio ttherwise we caioiott exteiod the
fle systems which is iott tio LVMB.
32. How to unmount a file system forcefully?
# gumtguiot -f <mtguiot ptiiot>
# fguser -ck <mtguiot ptiiot>
33. How to know the file system type?
# df -hT (ctmmaiod ii es the fle system type iioftrmattio).
34. How to know which file system occupy more space and top 10 file systems?
# df -h <de ice tr partttio ioame> | strt -r | head -10
35. What is the command to know the mounted file systems?
# mtguiot tr # cat /Setc/Smtab
36. How to know whether the file system is corrupted or not?
First guiomtguiot the fle systems aiod theio rguio fsck ctmmaiod tio that fle system.

Ratnakar Page 7
[Pick the date] [LINUX NOTES FOR LEVEL 2]

37. How to recover if a file system is corrupted or crashed?


If the iotrmal tr iott related tt O/SS fle system is ctrrgupted frst guiomtguiot that fle system aiod
rguio fsck ctmmaiod tio that fle system aiod if the O/SS related fle system is ctrrgupted theio bttt
the system with CDROMB iio siioile guser mtde aiod rguio the fsck ctmmaiod.
If the iotrmal tr iott related tt O/SS fle system is crashed theio resttre it frtm the receiot backgup
aiod if the O/SS related fle system is crashed theio bttt the system with CDROMB iio siioile guser mtde
aiod resttre it frtm the receiot backgup.
38. How to create a file with particular size?
# dd if=/Sde /Ssert tf=/Strafle bs=1MB ctguiot=500 (tt create 500MB sise /Strafle with 4K
bltcksise).
39. How to find how many disk are atached to the system?
# fdisk -l (tt see htw maioy disk are attached tt the system).
40. What is journaling?
It is a dedicated area iio the fle system where all the chaioies are tracked wheio the system
crashed. St the ptssibility tf the fle system ctrrgupttio tr crashes is less becaguse tf this jtgurioaliioi
featgure.
41. How to repair the Superblock of the file system?
Wheioe er we waiot tt sttre the data iiott the hard disk if the iiopgut/Stgutpgut errtr tccgurs theio
the Sguperbltck tf the fle system may be erased tr ctrrgupted. St we ha e tt resttre tr repair
that Sguperbltck.
# gumtguiot <fle system mtguiot ptiiot> (tt guiomtguiot the fle system).
# dgumpe2fs </Sde /S iioame/Sl ioame> | irep sguperbltck (tt list the sguperbltcks frst primary
sguperbltck aiod theio
sectiodary sguperbltck aiod st tio).
# e2fsck -b <ctpy aiod paste the sectiodary sguper bltck frtm the abt e
list></Sde /S iioame/Sl ioame>
(tt resttre the damaied
sguperbltck).

# mtguiot -a (tt mtguiot the fle system).


42. How to create the file systems with the user specified superblock reserve space?
# mkfs.ext4 -m <iot.><partttio ioame> (tt ftrmat the partttio with <iot.>% tf reser e
space tt sguperbltck).
Wheioe er we ftrmat the fle system by defagult it reser e the 5% partttio space ftr
Sguperbltck.

43. How to modify the superblock reserve space?


# tguioe2fs -m <iot.><partttio ioame> (tt mtdify the sguperbltck reser e space tt <iot.>%).
Important Commands :
# fsck <partttio ioame> (tt check the ctiosisteiocy tf the fle system).

Ratnakar Page 8
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# e2fsck <partttio ioame> (tt check the ctiosisteiocy tf the fle system iio iioteract e
mtde).
# e2fsck -p <partttio ioame> (tt check the ctiosisteiocy tf the fle system withtgut
iioteract e mtde).
# mke2fs -io <partttio ioame> (tt see the sguperbltck iioftrmattio).
# mke2fs -t <fle system type><partttio ioame> (tt ftrmat the partttio iio the specifed fle
system type).
# mke2fs <partttio ioame> (tt ftrmat the partttio iio defagult ext2 fle system type).
# bltckde --ietbs /Sde /Ssdb1 (tt check the bltck sise tf the /Sde /Ssdb1 fle system).
# fsck <de ice tr partttio ioame> (tt check aiod repair the fle system).
Ntte: eftre rguioioiioi this ctmmaiod frst guiomtguiot that partttio theio rguio
fsck ctmmaiod.

# gumtguiot -a (tt guiomtguiot all the fle systems except ( /S ). rttt fle system).
# mtguiot -a (tt mtguiot all the fle systems which are ha iioi eiotries iio
/Setc/Sfstab fle).
# fsck -A (tt rguio fsck tio all fle systems).
# fsck -AR -y (tt rguio fsck withtgut askiioi aioy qguesttios).
# fsck -AR -t ext3 -y (tt rguio fsck tio all ext3 fle systems).
# fsck -AR -t iot ext3 -y (tt rguio fsck tio all fle systems except ext3 fle systems).
# fsck -io /Sde /Ssdb1 (tt see the /Sde /Ssdb1 fle system reptrt withtgut rguioioiioi
fsck).
# tguioe2fs -l /Sde /Ssdb1 (tt check whether the jtgurioaliioi is there tr iott).
# tguioe2fs -j /Sde /Ssdb1 (tt ctio ert ext2 fle system tt ext3 fle system).
# tguioe2fs -l /Sde /Ssdb1 (tt check whether the jtgurioaliioi is added tr iott).
# tguioe2fs -O ^has_jtgurioal /Sde /Ssdb1 (tt ctio ert ext3 fle system tt ext2 fle system).
# tguioe2fs -O dir_iiodex has_jtgurioal guioit_bi /Sde /Ssdb1 (tt ctio ert ext2 fle system tt ext4
fle system).
# tguioe2fs -O exteiots dir_iiodex guioit_bi /Sde /Ssdb1 (tt ctio ert ext3 fle system tt ext4 fle
system).
# mtguiot -t remtguiot rw /Sde /Ssdb1 (tt mtguiot the partttio with read aiod write permissitios).
# mtguiot -t remtguiot rt /Sde /Ssdb1 (tt mtguiot the partttio with read tioly permissitios).
# mtguiot <mtguiot ptiiot tr directtry ioame> (tt check whether this directtry is mtguiot ptiiot tr
iotrmal directtry).
# dgump2fs <de ice tr partttio ioame> (tt check the metadata tf the partttio aiod repair the
metadata).
# fdisk -l (tt list tttal hard disks attached tt system aiod their
partttios).
# fguser -cgu <de ice tr partttio ioame> (tt see the gusers wht are accessiioi that fle system).
# fguser -cK <de ice tr partttio ioame> (tt kill the gusers prtcesses wht accessiioi the fle systems).

Ratnakar Page 9
[Pick the date] [LINUX NOTES FOR LEVEL 2]

Note: E eio thtguih we kill thtse gusers prtcesses stmetmes we caioiott guiomtguiot thtse
partttios st if this
sitguattio arises theio frst see the prtcess id's tf the guser tpeioed fles by # lsof <mount
point>aiod
killthtse prtcessesftrcefgully by # kill -9 <process id>

# jtgurioalctl (It tracks all the lti fles betweeio twt difeereiot tmiiois aiod by defagult sa ed iio
/run/log ltcattio).
* /run/log is mtguioted tio tmpfs fle system. ie. if system is rebttted the whtle iioftrmattio iio
that ltcattio will
be deleted tr erased.
* We caio chaioie the ltcattio tf the /run/log tt aiotther like /var/log/journal by
# mkdir -p /S ar/Slti/Sjtgurioal (tt make a directtry iio /S ar/Slti ltcattio).
# chtwio rttt : systemd-jtgurioal /S ar/Slti/Sjtgurioal (tt chaioie the irtgup twioership tf
/S ar/Slti/Sjtgurioal).
# chmtd i+s /S ar/Slti/Sjtgurioal (tt set the siid tio /S ar/Slti/Sjtgurioal).
# killall -URS1 systemd-jtgurioald (It is ioecessary tt kill tld /Srguio/Slti prtcess aiod the
ltcattio tf jtgurioal
messaies is chaioied tt /S ar/Slti/Sjtgurioal).
# jtgurioalctl -io 5 (tt display last f e liioes tf all the lti fles).
# jtgurioalctl -p err (tt display all the errtr messaies).
# jtgurioalctl -f (tt watch jtgurioalctl messaies ctiotiogutgusly).
# jtgurioalctl --siioce<ttday> tr <yesterday> (tt see all the jtgurioalctl messaies siioce ttday tr
yesterday).
# jtgurioalctl --siioce "date" --guiotl "date" (tt see the jtgurioal messaies betweeio the specifed
twt dates).
# jtgurioalctl -pid=1 (tt see the pid=1 prtcess ioame).
# aguditctl (tt see the agudit reptrt).
# sar (sar gutlity is tt watch the system act ity reptrt like CPU
memtry ...etc. ).
# smartctl -H <hard disk ioame> (tt check the health tf the specifed hard disk).
# smartctl -i <hard disk ioame> (tt see the iioftrmattio tf the specifed hard disk).
# smartctl -a <hard disk ioame> (it ii es mtre iioftrmattio tf the specifed hard disk).
Note: Iio the abt e ctmmaiod resgults it tt Valueaiod Tresh felds. If Tresh is mtre thaio the
Value theio
immediately hard disk chaioie is reqguired. If Tresh is ltwer thaio the Value theio hard disk is
tk. St the Tresh is always ltwer thaio the Value ttherwise hard disk chaioie is
reqguired immediately aiod
reptrt this maioaier.

Ratnakar Page 10
[Pick the date] [LINUX NOTES FOR LEVEL 2]

2. Logical Volume Management and RAID Levels

1. What is LVM and why we go for LVM?


Lvm meaios Ltiical Vtlgume MBaioaiemeiot. The ctmbiioattio tf 2 tr mtre physical disk iio trder
tt make a bii ltiical disk is called Ltiical Vtlgume.
If iotrmal Liiogux partttio is fgull aiod aio applicattio reqguires stme mtre disk space theio iotrmal
partttio caioiott be exteioded ftr that applicattio reqguiremeiot. Ftr this frst we ha e tt take
a backgup tf that iotrmal partttio delete that partttio aiod aiaiio create that partttio with
mtre disk space ftrmat aiod mtguiot that partttio aiod fioally resttre the applicattio frtm the
backgup. This prtcess reqguires dtwio tme.
St tt t erctme this prtblem LVMB ctiocept is ctmiioi iiott the pictgure. Usiioi this LVMB we caio
exteiod tr redguce the fle systems as per reqguiremeiot withtgut ltss tf aioy data.
2. What are the components of the LVM?
 Physical Vtlgume (PV).
 Physical Exteiot (PE).
 Vtlgume Grtgup (VG).
 Ltiical Vtlgume (LV).
 Ltiical Exteiot (LE).
Physical Volume (PV) :
It is the staiodard partttio that we add tt the LVMB. Ntrmally a physical tlgume is a staiodard
primary tr ltiical partttio with the partttio ctde as 8e.
Physical Extent (PE) :
It is chguiok tf disk space. E ery physical tlgume is di ided iiott a iogumber tf eqgual sised PEs.
Volume Group (VG) :
It is ctmptsed tf a irtgup tf physical tlgumes aiod ltiical tlgumes. It is the triaioisattioal irtgup
tf LVMB.
Logical Volume (LV) :
It is ctmptsed tf a irtgup tf LEs. We caio ftrmat (make a fle system). aiod mtguiot aioy fle system
tio the ltiical tlgume. The sise tf these ltiical tlgumes caio easily be iiocreased tr decreased as
per the reqguiremeiot.
Logical Extent (LE) :
It is alst a chguiok tf disk space. E ery ltiical exteiot is mapped tt a specifc physical exteiot.

Ratnakar Page 11
[Pick the date] [LINUX NOTES FOR LEVEL 2]

3. How to create the LVM, make a file system and mount that permanently?
(i). Take twt physical disks ftr example /dev/sdb aiod /dev/sdc. if there is iot sectiod disk
theio make the reqguired partttios gusiioi # fdisk ctmmaiod aiod chaioie the partttio
ctde as 8e.
(ii). Ctio ert the Physical disk iiott physical tlgumes by
# pvcreate /dev/sdb /dev/sdc
(iii). Theio create the tlgume irtgup by ctmbiioiioi physical tlgumes by
# vgcreate <volume group name><physical volume names> tr
W
# vgcreate -s <PE size in MBs><volume group name><physical volume names>
(i ). Theio create the ltiical tlgume tio the abt e created tlgume irtgup by
# lvcreate -L +<size in MBs> -n <logical volume name><Volume group name> tr
# lvcreate -l <no. of PEs> -n <logical volume name><volume group name>
( ). MBake a fle system tio the abt e created ltiical tlgume by
# mkfs.ext2/ext3/ext4/xfs /dev/<volume group name>/<logical volume name>

( i). Create a mtguiot ptiiot tt mtguiot the abt e created LVMB fle system by
# mkdir /mnt/<directory name>
( ii). MBtguiot the LVMB tio the abt e created mtguiot ptiiot temptrarily by
# mount /dev/<volume group name>/<logical volume name><mount point>tr
MBtguiot the LVMB tio mtguiot ptiiot permaioeiotly by
# vim /etc/fstab
/dev/<VG name>/<LV name> /mnt/<directory> <file system type> defaults
0 0
Esc+:+wq!
# mount -a
# df -hT (tt see the mtguioted partttios with fle system types).
4. How to see the details of the Physical Volumes?
#p s (displays all physical tlgumes with less details).
# p display (displays all physical tlgumes with mtre details).
# p display <physical tlgume ioame> (displays the details tf the specifed physical
tlgume).
# p scaio (tt scaio all the physical tlgumes).
#p scaio <PV ioame> (tt scaio the specifed physical tlgume).

5. How to see the details of the Volume Groups?


# is (displays all tlgume irtgups with less details).
# idisplay (displays all tlgume irtgups with mtre details).
# idisplay <VG ioame> (displays the specifed tlgume irtgup with mtre details).
# iscaio (tt scaio all the tlgume irtgups).

Ratnakar Page 12
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# iscaio <VG ioame> (tt scaio the specifed tlgume irtgup).


6. How to see the details of the Logical Volumes?
#l s (displays all ltiical tlgumes with less details).
# l display (displays all ltiical tlgumes with mtre details).
# l display <LV ioame> (displays the specifed ltiical tlgume details).
# l scaio (tt scaio all the ltiical tlgumes).
# l scaio <LV ioame> (tt scaio the specifed ltiical tlgume).
7. How to extend the Volume Group?
 Exteiodiioi the tlgume irtgup is actgually addiioi a ioew physical tlgume tt the tlgume
irtgup.
 Tt exteiod the tlgume irtgup we ioeed tt create a ioew partttio gusiioi # fdisk ctmmaiod
aiod make sgure that it's partttio id shtguld be 8e sa e the chaioies aiod gupdate the
partttio table by # partprobe
 Create a physical tlgume tio the ioewly created partttio gusiioi # pvcreate ctmmaiod.
 Add the partttio tt the tlgume irtgup gusiioi # vgextend ctmmaiod
Example : # fdisk /Sde /Ssdb
Ctmmaiod (m ftr help). : io
First cyliioder : press Eioter ftr defagult tioe
Last cyliioder : +500MB (create 500MB partttio).
Ctmmaiod (m ftr help). : t (tt chaioie the partttio id).
Select the partttio : type the partttio iogumber
Specify the Hexa ctde : 8e
Ctmmaiod (m ftr help). : w (tt sa e the chaioies).
# partprtbe /Sde /Ssdb1
# p create /Sde /Ssdb1
# iexteiod <VG ioame> /Sde /Ssdb1
# idisplay <VG ioame> (tt check the sise tf the tlgume irtgup).
8. How to extend the logical volume and update it's file system?
 Stmetmes the fle system sise may be fgull st we ioeed tt iiocrease the sise tf the ltiical
tlgume tt ctiotiogue addiioi the data iio it.
 The sise tf the ltiical tlgume caio be iiocreased tioliioe iot dtwiotme reqguired.
 Check cgurreiot sise tf the ltiical tlgume by # lvdisplay <LV name>aiod the sise tf the fle
system by # df -hT ctmmaiod.
 Iiocrease the sise tf the ltiical tlgume by # lvextend or # lvresize ctmmaiods.
 Theio fioally gupdate the fle system by # resize2fs or # xfs_growfs ctmmaiods.
Example : # df -hT
# l exteiod -L +<sise iio MB ></Sde /S iioame/Sl ioame> tr
# l resise -L +<sise iio MB ></Sde /S iioame/Sl ioame>
# resise2fs </Sde /S iioame/Sl ioame>
# l display </Sde /S iioame/Sl ioame> (tt check the sise tf the ltiical tlgume).

Ratnakar Page 13
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# df -hT (tt check the sise tf the fle system).


9. How to reduce the logical volume and update the file system?
 Redguciioi the sise tf the ltiical tlgume is a ctmplicated task aiod we ha e remember
stme ptiiots beftre redguciioi the ltiical tlgume ttherwise the fle system may be
damaied .
 Ltiical tlgume sise caioiott be redguced tioliioe aiod it reqguires dtwiotme becaguse we ha e
tt guiomtguiot the fle system by # umount <file system mount point>ctmmaiod.
 Check the ctiosisteiocy tf the fle system by # e2fsck <device or partition name>
ctmmaiod.
 Redguce the ltiical tlgume by # lvreduce -L - <Size of in MB></dev/vgname/lvname>
ctmmaiod.
 Theio gupdate the fle system by # resize2fs </dev/vgname/lvname>
 Fiioally mtguiot the fle system by # mount -a
Example : # gumtguiot <fle system mtguiot ptiiot>
# e2fsck <de ice tr partttio ioame>
# l redguce -L -<sise iio MB ></Sde /S iioame/Sl ioame>
# resise2fs </Sde /S iioame/Sl ioame>
# l display </Sde /S iioame/Sl ioame> (tt check the sise tf the ltiical tlgume>
# mtguiot -a (tt mtguiot the fle system).
# df -hT (tt check the sise tf the fle system).
10. How to move or migrate the logical volume data from one physical volume to another
physical volume?
 There miiht be a sitguattio where the physical tlgume miiht be failiioi aiod it is reqguired
tt replaced. Iio sguch case we ioeed tt miirate tr mt e the ltiical tlgume data frtm the
failed physical tlgume ioew physical tlgume aiod istlate (remt e). the failed physical
tlgume.
 First access the mtguiot ptiiot tf the failiioi physical tlgume aiod check the data iio it.
 Verify the sise tf the physical tlgume by #pvs tr #pvdisplay
</dev/vgname/lvname>ctmmaiod.
 Uiomtguiot the fle system tf that physical tlgume by # umount <file system mount
point>
 Add a ioew physical tlgume aiod the sise shtguld be same sise tr hiiher thaio that failiioi
physical tlgume.
 MBiirate the physical tlgume ctioteiots tt the ioew physical tlgume gusiioi # pvmove <old
PV><new PV>
 MBtguiot back the ltiical tlgume access the mtguiot ptiiot aiod erify the data iio it.
 Remt e the failed the physical tlgume by #vgreduce <vgname><pvname> ctmmaiod.
Example : # cd <fle system mtguiot ptiiot>
# ls
# p s <p ioame> tr # p display <p ioame>

Ratnakar Page 14
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# gumtguiot <fle system mtguiot ptiiot>


# p create <de ice tr partttio ioame>
# iexteiod < iioame><p ioame>
# p mt e <tld p ioame><ioew p ioame>
# mtguiot -a
# iredguce < iioame><failed p ioame>
# cd <fle system mtguiot ptiiot>
# ls
11. How to delete or remove the logical volume?
 Tt delete tr remt e the ltiical tlgume frst guiomtguiot the fle system by # umount
<mount point>
 Remt e the eiotry iio /Setc/Sfstab fle.
 Remt e the ltiical tlgume by # lvremove </dev/vgname/lvname>ctmmaiod.
 Verify whether the ltiical tlgume is remt ed tr iott by # lvs or # lvdisplay ctmmaiod.
Example : # gumtguiot <fle system mtguiot ptiiot>
# im /Setc/Sfstab (delete the eiotry tf the ltiical tlgume).
Esc+:+wq! (sa e aiod exit the fle).
# l remt e </Sde /S iioame/Sl ioame>
# l s tr # l display (tt erify whether ltiical tlgume is remt ed tr iott).
12. How to delete or remove the volume group?
 Tt delete tr remt e the tlgume irtgup frst make sgure that aioy ltiical tlgume shtguld iott
be mtguioted becaguse while remt iioi a tlgume irtgup it will delete tr remt e the ltiical
tlgumes iio that tlgume irtgup.
 Theio delete tr remt e the tlgume irtgup by # vgremove <vgname>ctmmaiod.
 Verify whether the tlgume irtgup is remt e tr iott by # vgs or # vgdisplay ctmmaiod.
Example : # gumtguiot <fle system mtguiot ptiiot> (tt guiomtguiot the fle system if there
is aioy LV).
# im /Setc/Sfstab (delete the eiotry tf the ltiical
tlgume).
Esc+:+wq! (sa e aiod exit the fle).
# iremt e < iioame>
# is tr # idisplay (tt erify whether tlgume irtgup is
remt ed tr iott).
13. How to delete or remove the physical volume?
 Deletioi tr remt iioi a physical tlgume is ery simple aiod the tioly thiioi we shtguld check
that the physical tlgume we are itiioi tt delete shtguld iott beltioi tt aioy tlgume irtgup
ie. we caio tioly delete tr remt e the physical tlgume which is free.
 Theio delete tr remt e the physical tlgume by # pvremove <pvname>ctmmaiod.
 Verify whether the physical tlgume is remt ed tr iott by # pvs or #pvdisplay
ctmmaiod.

Ratnakar Page 15
[Pick the date] [LINUX NOTES FOR LEVEL 2]

Example : # p remt e <p ioame>


# p s tr #p display (tt erify whether the physical tlgume is remt ed
tr iott).
14. How to restore the volume group which is removed mistakenly?
 First guiomtguiot fle system by # umount <file system mount point> ctmmaiod.
 Check the tlgume irtgup backgup list by # vgcfgrestore --list <volume group
name>ctmmaiod.
 Theio remt e the ltiical tlgume by # lvremove </dev/vgname/lvname> ctmmaiod.
 Ctpy the backgup fle which is takeio backgup beftre remt ed the tlgume irtgup frtm the
abt e backgup list aiod paste it iio this ctmmaiod # vgcfgrestore -f <paste the above
copied file name><vgname>
 The ltiical tlgume is created aguttmatcally afer resttriioi the tlgume irtgup bgut the
tlgume irtgup aiod ltiical tlgumes btth will be iio iioact e state. St check the state tf the
tlgume irtgup by #vgscanaiod the ltiical tlgume state by # lvscan ctmmaiods.
 Theio act ate that tlgume irtgup by # vgchange -ay <volume group
name>ctmmaiodaiod act ate the ltiical tlgume by # lvchange -ay <logical volume
name>ctmmaiod.
 MBtguiot the ltiical tlgume fle system by # mount -a ctmmaiod.
Example : # gumtguiot <fle system mtguiot ptiiot>
# icfiresttre --list < tlgume irtgup ioame> (ctpy the backgup fle frtm the list).
# l remt e </Sde /S iioame/Sl ioame>
# icfiresttre -f <paste the abt e ctpied fle>< tlgume irtgup ioame>
# iscaio (tt check the statgus tf the tlgume
irtgup).
# l scaio (tt check the statgus tf the ltiical
tlgume).
# ichaioie -ay < tlgume irtgup ioame> (act ate the tlgume irtgup if it is iio
iioact e state).
# l chaioie -ay <ltiical tlgume ioame> (act ate the ltiical tlgume if it is iio
iioact e state).
Note: The tpttio a meaios act e VG tr LV aiod tpttio y meaios yes.

# mtguiot -a
15. How to change the volume group name and other parameters?
# ireioame <existioi tlgume irtgup ioame><ioew tlgume irtgup ioame> (tt reioame the
tlgume irtgup).
y defagult guiolimited ltiical tlgumes caio be created per tlgume irtgup. gut we caio ctiotrtl this
limit by
# ichaioie -l <iot.>< tlgume irtgup> (tt limit max. iot. tf ltiical tlgumes tt the specifed
iogumber).

Ratnakar Page 16
[Pick the date] [LINUX NOTES FOR LEVEL 2]

Example : # ichaioie -l 2 < iioame> (tt limit max. 2 ltiical tlgumes cab be created iio
this tlgume irtgup).
# ichaioie -p <iot.>< tlgume irtgup> (tt limit max. iot. tf physical tlgumes tt the
specifed iogumber).
Example : # ichaioie -p 2 < iioame> (tt limit max. 2 physical tlgumes caio be added tt
this tlgume irtgup).
# ichaioie -s <bltck sise iio iot.>< tlgume irtgup> (tt chaioie the bltck sise tf the
tlgume irtgup).
Example : # ichaioie -s 4 < iioame> (tt chaioie the tlgume irtgup bltck sise tt 4MB ).
16. How to change the logical volume name and other parameters?
# l reioame <existioi l ioame><ioew l ioame> (tt reioame the ltiical tlgume).
# l chaioie -pr <ltiical tlgume> (tt pgut the ltiical tlgume iiott read tioly mtde).
#l s (tt see the ltiical tlgume permissitios).
# l chaioie -prw <ltiical tlgume> (tt pgut the ltiical tlgume iiott read aiod write mtde).
17. How to disable the volume group and logical volume?
# ichaioie -aio < tlgume irtgup> (tt disable the tlgume irtgup).
# l chaioie -aio <ltiical tlgume> (tt disable the ltiical tlgume).
18. How to take a backup of the volume group?
# icfibackgup (tt take a backgup tf all tlgume irtgups).
# icfibackgup < tlgume irtgup> (tt take a backgup tf the specifed tlgume irtgup).
19. What is the configuration file of the logical volume?
# cat /Setc/Sl m/Sl m.ctiof (tt see the ctioteiots tf the LVMB ctiofigurattio fle).
20. What are the locations of the logical volume and volume groups?
# cd /Setc/Sl m/Sbackgup (the ltiical tlgumes backgup ltcattio).
# cd /Setc/Sl m/Sarchi e (the tlgume irtgups backgup ltcattio).
21. How to know the current version of the LVM package?
# rpm -qa l m* (tt kiotw the cgurreiot ersitio tf the LVMB packaie).
22. What are the atributes of the volume group?
# is (tt see the attribgutes tf the tlgume irtgup).
[ The attribgutes are w ----> writable s ----> exteiodable io ----> iotrmal ]
# is - (tt check the UUID tf the tlgume irtgup).
23. How to extend the logical volume to max. disk space and half of the disk space?
# l exteiod -l +100% FREE <ltiical tlgume> (tt exteiod the ltiical tlgume by addiioi the
tlgume irtgup's
tttal a ailable space).
# l exteiod -l 50% < iioame><l ioame> (tt exteiod the ltiical tlgume by addiioi the
50% free space
tf the tlgume irtgup).
24. How to check on which physical volume the data is writing in the logical volume?

Ratnakar Page 17
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# l display -m (tt check tio which physical tlgume the data is cgurreiotly
writioi frtm all
ltiical tlgumes).
# l display -m <l ioame> (tt check tio which physical tlgume the data is writioi frtm
the specifed
ltiical tlgume).
25. How many types of file systems available?
ext2 ---->Sectiod exteioded fle system (defagult iio RHEL - 3 & 4).
ext3 ---->Third exteioded fle system (defagult iio RHEL - 5).
ext4 ----> Ftgurth exteioded fle system (defagult iio RHEL - 6).
xfs ----> Exteioded fle system (defagult iio RHEL - 7).
gufs ----> Uioix fle system (defagult iio Stlaris).
jfs ----> Jtgurioal fle system (defagult iio I MB-AIX).
hfs ----> Hiih perftrmaioce fle system (defagult iio HP-UX).
xfs ----> Veritas fle system
prtcfs ----> Prtcess fle system (temptrary).
tempfs ----> Temptrary fle system (temptrary).
cdfs ----> Ctmpact disk fle system
hdfs ----> DVD fle system
ist9660 ----> Tt read the CD/SDVD.ist imaie ftrmat fles iio Liiogux
26. How to scan and detect the luns over the network?
# ls /Ssys/Sclass/Sfc_htst (tt check the a ailable fbre
chaioioels).
# echt "---" > /Ssys/Sclass/Sscsi_htst/S<lguio iot.>/Sscaio (tt scaio aiod detect the lguios t er
the ioetwtrk).
27. How to mount a pen drive in Linux?
# lsgusb tr # fdisk -l (tt kiotw the peio dri e ioame).
# mkdir /Smiot/Speiodri e (tt create a mtguiot ptiiot ftr peio dri e).
# mtguiot <peio dri e ioame><mtguiot ptiiot> ( tt mtguiot the peio dri e tio the abt e created
mtguiot ptiiot).
# cd /Smiot/Speiodri e (tt access the peio dri e).
28. How to mount a CD/DVD ROM drives in Linux?
The CD/SDVD ROMB de ice ioame iio Liiogux is /Sde /Scdrtm
# mkdir /Smiot/Smycdrtm (tt create the mtguiot ptiiot ftr CD/SDVD).
# mtguiot /Sde /Scdrtm /Smiot/Smycdrtm (tt mtguiot the CD/SDVD tio the abt e created mtguiot
ptiiot).
# cd /Smiot/Smycdrtm (tt access the CD/SDVD ROMB dri es).
29. How to mount the " .iso " image files in Linux?
# mtguiot -t ist9660 /Srttt/Srhel6.ist /Sist -t rt lttp (tt mtguiot the .ist imaie fles).

Ratnakar Page 18
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# cdrectrd /Srttt/SDeskttp/Srhel6.ist (tt write the CD/SDVD ROMB. eftre execgutioi this
ctmmaiod pgut the
empty CD/SDVD iiott CD/SDVD dri e).
# eject (tt eject the CD/SDVD dri e tray).
# eject -t (tt iiosert aiod cltse the CD/SDVD dri e tray).
30. What is RAID? What is the use of the RAID and how many types of RAIDs available?
RAID staiods ftr Redguiodaiot Array tf Iiodepeiodeiot Disks.
It prt ides fagult ttleraioce ltad balaiociioi gusiioi strippiioi mirrtriioi aiod parity ctiocepts.
There are maiioly twt types tf RAIDs a ailable.
(i). Hardware RAID (Depeiods tio eiodtrs aiod alst mtre expeiosi e).
(ii). Stfware RAID (Dtes iott depeiods tio eiodtrs aiod less expeiosi e wheio ctmpared tt
Hardware RAID aiod alst it is maiiotaiioed by system admiioistrattr tioly.
31. How many types of sofware RAIDs available and their requirements?
(i). RAID - 0 ---- Strippiioi ---- MBiioimgum 2 disks reqguired
(ii). RAID - 1 ---- MBirrtriioi ---- MBiioimgum 2 disks reqguired
(iii). RAID - (1+0). --- MBirrtriioi + Strippiioi ---- MBiioimgum 4 disks reqguired
(i ). RAID - (0+1). --- Strippiioi + MBirrtriioi ---- MBiioimgum 4 disks reqguired
( ). RAID - 5 ---- Strippiioi with parity ---- MBiioimgum 3 disks reqguired
32. How to configure RAID - 0 in Linux?
 Tt ctiofigure RAID - 0 miioimgum 2 disks are reqguired aiod the partttio id is "fd".
 Readiioi aiod writioi is ery fast. St it prtdguces hiih perftrmaioce.
 if tioe disk is failed we caioiott rect er the data.
 St there is iot redguiodaiocy aiod fagult ttleraioce iio RAID - 0.
Example : Ftr example if the data is 1 2 3 4 5 aiod 6 theio ....

1 2
3 4
5 6
Disk - 1 Disk - 2

If the Disk - 1 is /Sde /Ssdb aiod the Disk - 2 is /Sde /Ssdc theio
# mdadm -C /Sde /Smd0 -io 2 /Sde /Ssdb /Sde /Ssdc -l 0 (tt create the RAID - 0 gusiioi disk - 1
aiod disk - 2).
# cat /Sprtc/Smdstat (tt check the RAID - 0 is created tr
iott).
# mkfs.ext4 /Sde /Smd0 (tt create the ext4 fle system tio
the RAID - 0).
# mkdir /Smiot/Sraid0 (tt create the RAID - 0 mtguiot ptiiot).
# mtguiot /Sde /Smd0 /Smiot/Sraid0 (tt mtguiot RAID - 0 tio the mtguiot
ptiiot).

Ratnakar Page 19
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# mdadm -D /Sde /Smd0 (tt see the details tf the RAID - 0


partttio).
# mdadm /Sde /Smd0 -f /Sde /Ssdb (tt failed the disk maiogually).
# mdadm /Sde /Smd0 -r /Sde /Ssdb (tt remt e the abt e failed disk).
# mdadm /Sde /Smd0 -a /Sde /Ssdd (tt add the ioew disk iio place tf
failed disk).
# gumtguiot /Smiot/Sraid0 (tt guiomtguiot the raid fle system).
# mdadm --sttp /Sde /Smd0 (tt sttp the RAID - 0 tlgume).
# mdadm /Sde /Smd0 --add /Sde /Ssde (tt add third disk tt the RAID - 0
tlgume).
# mdadm --irtw /Sde /Smd0 --raid_de ice=3 (tt irtw the RAID - 0 fle system).
33. How to configure RAID - 1 in Linux?
 Tt ctiofigure RAID - 1 miioimgum 2 disks are reqguired aiod the partttio id is "fd".
 Iio this the same data will be writteio tio 2 disks ie. exact ctpy tio btth the disks.
 if tioe disk is failed we caio rect er the data frtm aiotther disk.
 St there is a hiih a ailability redguiodaiocy aiod fagult ttleraioce iio RAID - 1.
 Iio this writioi speed is sltw ctmpared tt RAID - 0.
Example : Ftr example if the data is 1 2 3 4 5 aiod 6 theio ....

1 1
2 2
3 3
4 4
5 5
6 6 Disk - 1 Disk - 2

If the Disk - 1 is /Sde /Ssdb aiod the Disk - 2 is /Sde /Ssdc theio
# mdadm -C /Sde /Smd0 -io 2 /Sde /Ssdb /Sde /Ssdc -l 1 (tt create the RAID - 1 gusiioi disk - 1
aiod disk - 2).
# cat /Sprtc/Smdstat (tt check the RAID - 1 is created tr
iott).
# mkfs.ext4 /Sde /Smd0 (tt create the ext4 fle system tio
the RAID - 1).
# mkdir /Smiot/Sraid1 (tt create the RAID - 1 mtguiot ptiiot).
# mtguiot /Sde /Smd0 /Smiot/Sraid1 (tt mtguiot RAID - 1 tio the mtguiot
ptiiot).
# mdadm -D /Sde /Smd0 (tt see the details tf the RAID - 1
partttio).
# mdadm /Sde /Smd0 -f /Sde /Ssdb (tt failed the disk maiogually).
# mdadm /Sde /Smd0 -r /Sde /Ssdb (tt remt e the abt e failed disk).

Ratnakar Page 20
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# mdadm /Sde /Smd0 -a /Sde /Ssdd (tt add the ioew disk iio place tf
failed disk).
# gumtguiot /Smiot/Sraid1 (tt guiomtguiot the raid fle system).
# mdadm --sttp /Sde /Smd0 (tt sttp the RAID - 1 tlgume).
# mdadm /Sde /Smd0 --add /Sde /Ssde (tt add third disk tt the RAID - 1
tlgume).
# mdadm --irtw /Sde /Smd0 --raid_de ice=3 (tt irtw the RAID - 1 fle system).
34. How to configure RAID - 5 in Linux?
 Tt ctiofigure RAID - 5 miioimgum 3 disks are reqguired aiod the partttio id is "fd".
 Iio e ery disk apprtximately 25 - 30% tf space is reser ed ftr parity.
 Readiioi aiod writioi is ery fast. St it prtdguces hiih perftrmaioce.
 This is gused Strippiioi with parity ctiocept.
 if tioe disk is failed we caio rect er the data gusiioi remaiioiioi twt disks aiod parity.
 If twt disks are failed theio we caioiott rect er the data.
 St there is iot redguiodaiocy aiod fagult ttleraioce iio RAID - 5.
Example : Ftr example if the data is 1 2 3 4 5 aiod 6 theio ....

2
1 1+2
3
4
3+4
5+6
5
6
Disk - 1 Disk - 2
Disk - 3

If the Disk - 1 is /Sde /Ssdb the Disk - 2 is /Sde /Ssdc aiod Disk - 3 is /Sde /Ssddtheio
# mdadm -C /Sde /Smd0 -io 2 /Sde /Ssdb /Sde /Ssdc -l 5 (tt create the RAID - 5 gusiioi disks -
1 2 aiod 3).
# cat /Sprtc/Smdstat (tt check the RAID - 5 is created tr
iott).
# mkfs.ext4 /Sde /Smd0 (tt create the ext4 fle system tio
the RAID - 5).
# mkdir /Smiot/Sraid5 (tt create the RAID - 5 mtguiot ptiiot).
# mtguiot /Sde /Smd0 /Smiot/Sraid5 (tt mtguiot RAID - 5 tio the mtguiot
ptiiot).
# mdadm -D /Sde /Smd0 (tt see the details tf the RAID - 5
partttio).
# mdadm /Sde /Smd0 -f /Sde /Ssdb (tt failed the disk maiogually).
# mdadm /Sde /Smd0 -r /Sde /Ssdb (tt remt e the abt e failed disk).
# mdadm /Sde /Smd0 -a /Sde /Ssde (tt add the ioew disk iio place tf
failed disk).
# gumtguiot /Smiot/Sraid5 (tt guiomtguiot the raid fle system).

Ratnakar Page 21
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# mdadm --sttp /Sde /Smd0 (tt sttp the RAID - 5 tlgume).


# mdadm /Sde /Smd0 --add /Sde /Ssdf (tt add ftgurth disk tt the RAID - 5
tlgume).
# mdadm --irtw /Sde /Smd0 --raid_de ice=4 (tt irtw the RAID - 5 fle system).
35. What are the main advantages of RAID - 5
RAID - 5 guses Strippiioi with parity aiod reqguires tioly three disks. ecaguse tf Strippiioi the data
readiioi aiod writioi will be fast.Aiod by gusiioiparity we caio rect er the data if tioe tf the three
disks failed. St the maiio ad aiotaie tf RAID - 5 we caio iet fast writioi readiioi aiod alst
redguiodaiocy fagult ttleraioce with less expeiosi e.
36. How will you troubleshoot if one of the eight disks failed in LVM?
First gumtguiot the fle system aiod add the ioew disk with same sise tf the failed disk tt the
tlgume irtgup. Theio mt e the data frtm failed physical tlgume tt ioewly added physical tlgume
aiod theio remt e the failed physical tlgume frtm the tlgume irtgup. Aiod fioally mtguiot the fle
system.
37. What is pvmove and when it is used in LVM?
The p mt e ctmmaiod is gused tt mt e the data frtm failed physical tlgume tt ioewly added
physical tlgume. This ctmmaiod is gused wheio tioe tf the physical tlgume is failed iio the LVMB.
38. How to inform the client and then troubleshoot if the disk is full?
First check which fles are accessiioi mtre disk space by #du -h |sort - r ctmmaiod. if aioy
temptrary aiod jguiok fles are preseiot remt e them frtm the disk tt make a rttm ftr ioew tr
gupdated data. Theio iioftrm the actgual sitguattio tt the clieiot take the permissitio frtm the clieiot tt
iet the lguio frtm sttraie aiod exteiod the fle system by addiioi that lguio tt the LVMB.
39. Did you work on storage?
Actgually I did iott wtrk tio sttraie bgut I kiotw the prtcedgure htw tt exptrt the lguio frtm sttraie
tt clieiot gusiioi iSCSI tariet. Theio scaio that lguio at cleiiot side aiod add the lguio tt the LVMB. I alst kiotw
the sttraie hardware frtm Emc sqguare Netapp aiod tthers. Aiod I am dreamiioi tt wtrk tio
sttraie cltgud aiod irtgualisattio.
40. I have four disks each 1TB in RAID - (1+0). So, total how much disk space can I utilize in that
RAID - (1+0)? RAID - (1+0). meaios MBirrtriioi + Strippiioi. It reqguires 4 disks ie. 2 disks ftr mirrtriioi
aiod remaiioiioi 2 disks ftr strippiioi. Aiod 5 - 10% disk space is gused ftr sguperbltck iioftrmattio.
St fioally we caio gutlise 2T - 2T X 10% disk space iio that RAID - (1+0)..
41. If two disks failed in RAID - (1+0), can we recover the data?
The RAID - (1+0). reqguires miioimgum 4 disks aiod it guses MBirrtriioi + Strippiioi. If tioe disk is failed
we caio rect er the data bgut if twt disks are failed we caioiott rect er the data.
42. How many types of disk space issues can we normally get?
(i). Disk is fgull.
(ii). Disk is failiioi tr failed.
(iii). File system ctrrgupted tr crashed.
(i ). O/SS is iott rectiioisiioi the remtte lguios wheio scaioioiioi ...etc.
43. What is a link file and how many types?

Ratnakar Page 22
[Pick the date] [LINUX NOTES FOR LEVEL 2]

Liiok fle is a shtrt cgut fle tt the triiiioal fle. Creatioi aiod remt iioi (deletioi). iioks betweeio
twt fles is kiotwio as maioaiiioi liioks. There are twt types tf liioks fles a ailable iio Liiogux.
(i). Stf liiok
(ii). Hard liiok
44. What is sof link and how to create it?
Stf liiok is iotthiioi bgut a shtrt cgut fle. If triiiioal fle is deleted iot guse tf shtrt cgut fle. ie. we
caioiott access the triiiioal data by selectioi the liiok fle. Stf liiok caio be applied tio btth directtries
aiod fles. These fles caio be sttred iio aioy tf the fle system. ie. the triiiioal fle may be iio tioe
fle system aiod the liiok fle may be tio aiotther fle system. If we edit aioy fle the liiok fles are
alst gupdated aguttmatcally. Wheio we create a stf liiok fle the permissitios are fgull permissitios.
The stf liiok fle aiod the triiiioal fle iiotde iot's are difeereiot. The sise tf the stf liiok fle is same as
the leioith tf the triiiioal fle ioame. The stf liiok caio be created by
# lio -s <triiiioal fle tr directtry><liiok fle tr directtrywith path> (tt create a
stf liiok).
# lio -s /Srttt/Sscript /Srttt/SDeskttp/Sscript (tt create a liiok fle ftr the script aiod sttred tio
rttt Deskttp).
45. What is hard link and how to create it?
Hard liiok iio iotthiioi bgut a backgup fle. If the triiiioal fle is deleted there is iot efeect tio hard liiok
fle. ie. we caio access the triiiioal fle data e eio thtguih the liiok fle is deleted. Hard liioks caio be
applied tio fles tioly iott tio directtries. Hard liiok fles caio be sttred iio the same fle system. ie.
triiiioal aiod hard liiok fles btth shtguld be iio the same fle system iott tio difeereiot fle systems.
The iiotde iot's are same ftr triiiioal aiod hard liiok fles. If the triiiioal is edited the gupdattios are
applied tio btth triiiioal aiod hard liiok fles. The sise tf the hard liiok fle is same as the sise tf
the triiiioal fle.
46. What are the commands to search files and directories?
Tt search fles aiod directtries there are twt ctmmaiods.
(i). # ltcate
(ii). # fiod
47. Explain the locate command and how to use it?
ltcate always lttks the ltcate database aiod iott iio a specifc ltcattio. The data tf the ltcate is
sttred iio /var/lib/mlocate/mlocate.db fle. If the data is iott gupdated iio ltcate database tr
the ltcate database is a ailable tr ltcate database is deleted we caioiott ltcate the fles aiod
directtries. # updatedb is the ctmmaiod tt gupdate the ltcate database. ltcate database
caioiott be fiod the ioewly created fles aiod directtries. It is iott rectmmeioded tt guse tio prtdgucttio
ser ers becaguse it impacts tio perftrmaioce tf the ser ers. St tt t erctme this prtblem we
iotrmally guse # find ctmmaiod tio prtdgucttio ser ers.
# gupdatedb (tt gupdate the ltcate
database).
# ltcate <fle ioame/Sdirecttry ioame> (tt search the specifed fle
tr directtry).

Ratnakar Page 23
[Pick the date] [LINUX NOTES FOR LEVEL 2]

48. Explain the find command and how to use it?


fiod ctmmaiod reqguired the specifc ltcattio. Withtgut specifc ltcattio we caioiott fiod the fles
tr directtries.
# fiod <ltcattio><tpttios><fle tr directtry> (tt fiod the specifc fle tr
directtry).
The tpttios are -ioame -----> search fles aiod directtries
-prem -----> search ftr permissitios
-sise -----> search ftr sises
-guser -----> search ftr the twioer
-guid -----> search ftr fles/Sdirecttries tf guid).
-iid -----> search ftr fles/Sdirecttries tf iid).
-irtgup -----> search ftr irtgup twioer
-empty -----> search ftr empty fles
-amiio -----> search ftr access tme
-mmiio -----> " "
-cmiio -----> " "
-atme -----> search ftr access day (access day miiogutes hrs ...etc).
-mtme -----> search ftr mtdify day (chaioie the ctioteiot).
-ctme -----> search ftr chaioie day (permissitios .....etc).
Examples :
# fiod /S -ioame <fle ioame> (tt search ftr fle ioames
iio /S directtry).
# fiod /S -ioame <fle ioame> -type f (tt fiod fle ioames tioly).
# fiod /S -ioame <directtry ioame> -type d (tt fiod directtries with
small letters tioly).
# fiod /S -iioame <fle/Sdirecttry ioame> -t d (tt search ftr small tr capital letter
fles/Sdirecttries).
#fiod /S -empty (tt search empty fles tr
directtries).
# fiod /S -empty -type f (tt search ftr empty fles
tioly).
# fiod /S -empty -type d (tt search ftr empty
directtries tioly).
# fiod /S -ioame " *.mp3" (tt search ftr .mp3 fles
tioly).
# fiod /S -sise 10MB (tt search ftr exact 10MB
sise fle/Sdirecttries).
# fiod /S -sise -10MB (tt search ftr less thaio 10MB sise
fles/Sdirecttries).

Ratnakar Page 24
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# fiod /S -sise +10MB (tt search ftr ireater thaio 10MB sise
fles/Sdirecttries).
# fiod /S -guser stgudeiot (tt search ftr stgudeiot guser
fles/Sdirecttries).
# fiod /S -irtgup stgudeiot (tt search ftr stgudeiot irtgup
fles/Sdirecttries).
# fiod /S -guser stgudeiot -iott -irtgup stgudeiot (tt search ftr stgudeiot guser fles aiod iott
stgudeiot irtgup fles).
# fiod /S -guser stgudeiot -t -irtgup stgudeiot (tt search ftr stgudeiot guser aiod stgudeiot irtgup
fles/Sdirecttries).
# fiod /S -guid <guid iot.> (tt search ftr fles/Sdirecttries which beltiois
tt the guser
ha iioi the specifed guser id).
# fiod /S -iid <iid iot.> (tt search ftr fles/Sdirecttries which beltiois
tt the irtgup
ha iioi the specifed irtgup id).
# fiod /S -prem 755 (tt search fle/Sdirecttries which are ha iioi the
permissitios 755).
# fiod /S -prem -755 (tt search fle/Sdirecttries which are ha iioi the
permissitios
beltw 755 aiod alst at least tioe match alst).
# fiod /S -mmiio 20 (tt search ftr fles/Sdirecttries which are mtdifed withiio 20
miiogutes +20 ----> abt e 20 miiogutes aiod
-20 -----> beltw 20 miiogutes).
# fiod /S -mtme 2 (tt search fles/Sdirecttries which are mtdifed
withiio 2 days).
# fiod /S -ioame "*.mp3" -exec rm -rf { } ; (tt search all .mp3 fles
aiod delete them).
# fiod /S -ioame "*.mp3" -exec cp -a { } /Sram ; (tt search all mp3 fles aiod ctpy them
iiott /Sram directtry).
# fiod /S -guser stgudeiot -exec cp -a { } /Sram ; (tt search stgudeiot guser's fles aiod
directtries aiod
ctpy them iiott /Sram directtry).
# fiod /S -iotguser -exec m -a { } /Shtme/Sram ; (tt search fles/Sdirecttries which
are iott beltiois tt aioy guser aiod
mt e them iiott /Shtme/Sram directtry).
# dgu -h /S |strt -r |head -io 10 (tt search 10 bii sise fles iio re erse
trder).

Ratnakar Page 25
[Pick the date] [LINUX NOTES FOR LEVEL 2]

3. User and Group Administration

1. What is a user?

Ratnakar Page 26
[Pick the date] [LINUX NOTES FOR LEVEL 2]

Iio Liiogux guser is tioe wht guses the system. There caio be at least tioe tr mtre thaio tioe guser iio
Liiogux at a tme.
2. How many types of users available in Linux?
There are 5 types tf gusers a ailable iio Liiogux.
(i). System guser (Admiio guser wht ctiotrtl the whtle system iotthiioi bgut rttt guser)..
(ii). Ntrmal guser (Created by the Sguper guser. Iio RHEL - 7 the guser id's frtm 1000 - 60000)..
(iii). System guser (Created wheio applicattio tr stfware iiostalled aiod are maiiotaiioed system
deamtios)..
(Iio RHEL - 7 the System gusers are (i). Statc system guser id's frtm 1 - 200 aiod (ii). Dyioamic system
guser guser id'sfrtm 201 - 999)..
(i ). Netwtrk guser (Ntthiioi bgut remtte guser ie. wht are ltiiio tt the system trtguih ioetwtrk
created iio Wiiodtws Act e Directtry tr iio Liiogux LDAP tr NIS)..
( ). Sgudt guser (The iotrmal gusers wht are ha iioi admiio tr Sguper guser pri ileies).
The types of users in Linux and their atributes:

Type of Default
Example User ID Group ID Home Directory
User Shell

Sguper User Rttt 0 0 /Srttt /Sbiio/Sbash

ram rajgu itpal


Ntrmal User 500 - 60000 500 - 60000 /Shtme/S<guser ioame> /Sbiio/Sbash
...etc.
fp ssh apache
System User 1 - 499 1 - 499 /S at/Sfp ...etc /Ssbiio/Siotliiio
iotbtdy ...etc.
Remtte guser Same as Same as
Netwtrk User /Shtme/Siguests/Sldapguser /Sbiio/Sbash
like LDAP guser iotrmal gusers iotrmal gusers

Ntrmal gusers
Same as Same as
Sgudt User with admiio /Shtme/S<guser ioame> /Sbiio/Sbash
iotrmal gusers iotrmal gusers
pri ileies

3. What is user management?


User maioaiemeiot meaios maioaiiioi guser. ie. Creatioi the gusers deletioi the gusers aiod
mtdifyiioi the gusers.
4. What are the important points related to users?
 Users aiod irtgups are gused tt ctiotrtl access tt fles aiod restgurces.
 Users caio ltiiio tt the system by sgupplyiioi guserioame aiod passwtrds tt the system.
 E ery fle tio the system is twioed by a guser aiod asstciated with a irtgup.
 E ery prtcess has aio twioer aiod irtgup afliattio.
 E ery guser iio the system is assiiioed a guioiqgue guser id (guid). aiod irtgup id (iid)..
 User ioames aiod guser id are sttred iio /etc/passwd fle.
 User's passwtrds are sttred iio /etc/shadow fle iio aio eiocrypted ftrm.
 Users are assiiioed a htme directtry aiod a shell tt wtrk with the O/SS.

Ratnakar Page 27
[Pick the date] [LINUX NOTES FOR LEVEL 2]

 Users caioiott read write aiod execgute each tther's fles withtgut permissitio.
 Wheioe er a guser is created a mail btx is created aguttmatcally iio /var/spool/mail
ltcattio.
 Aiod stme guser eio irtiomeiotal fles like .bash_ltitgut .bash_prtfle .bashrc ...etc. are
alst ctpied frtm /etc/skell tt his/Sher htme directtry (/home/<username>)..
5. What are fields available in /etc/passwd file?
<guser ioame> : x : <guid> : <iid> : <ctmmeiot> : <guser's htme directtry> : <ltiiio
shell>
(where 'x' meaios liiok tt passwtrd fle ie. /etc/shadow fle).
6. What are fields available in /etc/shadow file?
guser ioame : passwtrd : last chaioied : miio. days : max. days : wario days : iioact e days : expiry
days : reser ed
ftr fgutgure
7. What are the files that are related to user management?
 /etc/passwd -----> Sttres guser's iioftrmattio like guser ioame guid htme directtry aiod
shell ...etc.
 /etc/shadow ----> Sttres guser's passwtrd iio eiocrypted ftrm aiod tther iioftrmattio.
 /etc/group ------> Sttres irtgup's iioftrmattio like irtgup ioame iid aiod tther iioftrmattio.
 /etc/gshadow ---> Sttres irtgup's passwtrd iio eiocrypted ftrm.
 /etc/passwd- ---> Sttres the /Setc/Spasswd fle backgup ctpy.
 /etc/shadow- ---> Sttres the /Setc/Sshadtw fle backgup ctpy.
 /etc/default/useradd ----> Wheioe er the guser created guser's defagult setiois takeio frtm
this fle.
 /etc/login.defs ----> guser's ltiiio defagults setiois iioftrmattio takeio frtm this fle.
 /etc/skell ------> Sttres guser's all eio irtiomeiotal ariables fles aiod these are ctpied frtm
this directtry tt
guser's htme directtry.
8. In how many ways can we create the users?
(i). # guseradd - <tpttios><guser ioame>
(ii). # addguser - <tpttios><guser ioame>
(iii). # ioewgusers <fle ioame> (Iio this fle we ha e tt eioter the guser details same as
/etc/passwd fle).
9. What is the syntax ofuseradd command with full options?
# guseradd -gu <guid> -i <iid> -G <sectiodary irtgup> -c <ctmmeiot> -d <htme directtry> -s
<shell><guser ioame>
Example : # guseradd -gu 600 -i 600 -G ja a -c "tracle guser" -d /Shtme/Srajgu -s /Sbiio/Sbash
rajgu
10. What is the syntax of adduser command with full options?
# addguser -gu <guid> -i <iid> -G <sectiodary irtgup> -c <ctmmeiot> -d <htme directtry> -s
<shell><guser ioame>

Ratnakar Page 28
[Pick the date] [LINUX NOTES FOR LEVEL 2]

Example : # addguser -gu 700 -i 700 -G liiogux -c "tracle guser" -d /Shtme/Sram -s /Sbiio/Sbash
ram
11. What is the syntax of newuser command?
# ioewgusers <fle ioame> (This ctmmaiod will create mgultple gusers at a tme).
* First we shtguld a fle aiod eioter guser's data as felds same as the felds tf /Setc/Spasswd fle ftr
htw maioy gusers dt ytgu waiot tt create aiod meiottio that fle as aio arigumeiot ftr ioewgusers
ctmmaiod.
* Wheio we execgute this ctmmaiod ioew gusers will be created bgut their eio irtiomeiotal fles like
.bash_logout, .bash_profile, .bashrc aiod .bash_history fles will iott be ctpied frtm /etc/skell
directtry. St we ha e tt ctpied maiogually frtm /etc/skell directtry.
12. What is the syntax of userdel command with full options?
# guserdel <tpttios><guser ioame>
* The tpttios are -f -----> ftrcefgully delete the guser e eio thrtguih the guser is ltiiio. The
guser's htme directtry mail aiod messaie directtries are
alst deleted.
-r -----> recgursi ely meaios fles iio the guser's htme directtry will be
deleted aiod his htme directtry alst deleted bgut the
tther fles beltiois tt that guser shtguld be deleted
maiogually.

13. How to check whether is already created or not?


We caio check iio difeereiot ways.
(i). # id <guser ioame> (It shtws the guser id irtgup id aiod guser ioame if that is already
created).
(ii). # cat /Setc/Spasswd |irep <guser ioame> (It shtws the guser's details if that guser is already
created).
14. How to verify or check the integrity of the password file?
# pwck <tpttios> /Setc/Spasswd tr
# pwck <tpttios> /Setc/Sshadtw
* The tpttios are -q ------> qguiet
-r ------> read tioly
-s ------> strt the ctioteiots by uidiio /etc/passwd aiod /etc/shadow
fles.
15. How to verify or check the integrity of the group file?
# irpck <tpttios> /Setc/Sirtgup tr
# irpck <tpttios> /Setc/Sishadtw
* The tpttios are -r -----> read tioly
-s -----> strt the ctioteiots by gidiio /etc/group aiod /etc/gshadow
fles.
16. What is syntax of the usermod command with full options?

Ratnakar Page 29
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# gusermtd <tpttios><guser ioame>


* The tpttios are -L -----> ltck the passwtrd
-U -----> guioltck the passwtrd
-t ----->creates dguplicate guser (mtdify the guser's id as same as tther
guser's id).
-gu ----->mtdify guser id
-i -----> mtdify irtgup id
-G -----> mtdify tr add the sectiodary irtgup
-c -----> mtdify ctmmeiot
-d -----> mtdify htme directtry
-s -----> mtdify guser's ltiiio shell
-l -----> mtdify guser's ltiiio ioame
-md ----> mtdify the gusers htme directtry aiod the tld htme directtry
alst reioame
17. How to create the duplicate root user?
# guseradd -t -gu 0 -i rttt <guser ioame>
18. How to recover if the user deleted by mistake?
# pwunconv (It creates the gusers acctrdiioi /etc/passwd fle aiod deletes the
/etc/shadow fle).
19. What are the uses of .bash_logout, .bash_profile and .bashrc files?
.bash_logout : This is a guser's ltitgut eiodiioi prtiram fle. It will execgute frst wheioe er the guser
is ltitgut.
.bash_profile : This is guser's ltiiio startgup prtiram fle. It will execgute frst wheioe er the guser is
ltiiio. It ctiosists the guser's eio irtiomeiotal ariables.
.bashrc : This fle is gused tt create the guser's cgusttm ctmmaiods aiod tt specify the gumask
algues ftr that guser's tioly.
20. What is a group?
The ctllecttio tf gusers is called a irtgup. There are twt types tf irtgups.
Primary group : It will be created aguttmatcally wheioe er the guser is created. User beltiois tt
tio irtgup is called primary irtgup.
Secondary group : It will iott create aguttmatcally. The admiio guser shtguld be created maiogually
aiod gusers beltiois tt mtre thaio tioe irtgup is called sectiodary
irtgup. A guser caio be assiiioed tt max. 16 irtgups. ie. 1 primary irtgup
aiod 15 sectiodary irtgups.
21. What is the command to check the user belongs to how many groups?
# irtgups <guser ioame>
22. What is the syntax to create the group?
# irtgupadd <tpttios><irtgup ioame>
The tpttios are -f -----> add the irtgup ftrcefgully
-i -----> irtgup id iot.

Ratnakar Page 30
[Pick the date] [LINUX NOTES FOR LEVEL 2]

-t ----->iotio-guioiqgue (dguplicate irtgup id).


-p -----> irtgup passwtrd
-r -----> system irtgup
-R -----> rttt irtgup
23. What is the syntax to modify the group?
# irtgupmtd <tpttios><irtgup ioame>
The tpttios are -i ------> irtgup id
-io ------> ioew ioame ftr existioi tioe ie. reioame the irtgup
-t ------> iotio-guioiqgue (dguplicate irtgup id).
-p ------> irtgup passwd
-R ------>rttt irtgup
24. What is syntax to delete the group?
# irtgupdel <irtgup ioame> (tt delete the irtgup withtgut tpttios).
# irtgupdel -R <irtgup ioame> (tt delete the irtgup aiod apply chaioies tt the rttt
directtry).
25. How to assign the password to the group?
# ipasswd <irtgup ioame> (tt assiiio a passwtrd tt the irtgup withtgut aioy tpttios).
# ipasswd <tpttios><irtgup ioame>
The tpttios are -a ------>add gusers tt the irtgup
-d ------> delete the guser frtm the irtgup
-r ------> remt e the irtgup passwtrd
-R ------> restrict tt access that irtgup
-A ------> set the list tf Admiioistrat e gusers
-MB ------> set the list tf irtgup members
26. How to check the integrity or consistency of the group?
# irpck (it will check the iioteirity tr ctiosisteiocy iio /etc/gpasswd aiod /etc/gshadow
fles).
27. How to restore /etc/gshadow file if deleted by mistake?
# irpctio (it creates the /etc/gshadow fle frtm /etc/group fle).
28. How to change the password aging policies?
we caio chaioie the passwtrd ptlicies iio 2 ways.
(i). First tpeio the /etc/login.defs fle aiod mtdify the cgurreiot algues.
Example : # im /Setc/Sltiiio.defs
miio - 0 -----> meaios the guser caio chaioie the passwtrd tt aioy iot. tf tmes.
miio - 2 -----> meaios the guser caio chaioie the passwtrd withiio 2 days. ie. he caio
chaioie the passwtrd afer 2 days.
max - 5 -----> meaios the guser shtguld chaioie the passwtrd beftre tr afer 5 days.
Otherwise the passwtrd will be expired afer 5 days.
iioact e - 2 -----> meaios afer passwtrd expiry date the irace peritd aiotther 2 days
will be ii eio tt chaioie the passwtrd.

Ratnakar Page 31
[Pick the date] [LINUX NOTES FOR LEVEL 2]

warioiioi - 7 -----> meaios a warioiioi will be ii eio tt the guser abtgut the passwtrd
expiry 7 days beftre expiry date.
(ii). sectiod by execgutioi the # chage ctmmaiod.
Example : # chaie <tpttios><guser ioame>
The tpttios are -d -----> last day
-E -----> expiry date
-I -----> iioact e days
-l -----> list all the ptlicies
-m -----> miio. days
-MB -----> max. days
-w -----> warioiioi days
Note : Wheioe er we chaioie the passwtrd aiiioi ptlicy gusiioi # chage ctmmaiod the
iioftrmattio is will be mtdifed iio /etc/shadow fle.
29. How add 45 days to the current system date?
# date -d "+ 45 days"
30. Explain the sudo user?
 Sgudters (iotthiioi bgut sgudt gusers). alltws partcgular gusers tt rguio aritgus rttt guser
ctmmaiods withtgut ioeediioi a rttt passwtrd.
 /etc/sudoers is the ctiofigurattio fle ftr sgudters tt ctiofigure the iotrmal guser as
pri ileied guser.
 It is iott rectmmeioded tt tpeio this fle gusiioi # vim edittr becaguse this edittr caioiott
check the syiotax by defagult aiod whate er we typed iio that fle that will bliiodly sa e iio this
fle.
 St tioe edittr is specially a ailable ftr tpeioiioi this fle ie. # visudo aiod all iotrmal gusers
caioiott execgute this ctmmaiod. Oioly rttt guser caio rguio this ctmmaiod.
 Oioce this fle is tpeioed iotbtdy caio tpeio this fle aiaiio tio aiotther termiioal becaguse "The
file is busy"messaie is displayed tio the termiioal ftr secgurity reastios.
31. How to give diferent sudo permissions to normal users?
Opeio the /etc/sudoers fle by execgutioi #visudo ctmmaiod aiod it tt liioe iot. 98 aiod type
as
<User name> <Machine>= <Command>
root ALL=(ALL) ALL
raju All= ALL
----Sa e aiod exit this fle.
Note : Wheio we tryiioi tt sa e this fle if aioy syiotax errtrs iio this fle thtse errtrs are displayed
with liioe iot's aiod What you do ? (will be displayed here press 'e' tt edit this fle aiod mtdify
thtse errtrs tr mistakes aiod sa e this fle.
# sgu - rajgu (tt switch tt rajgu guser).
# sgudt guseradd <guseradd> (The iotrmal guser rajgu caio alst add the gusers tt the system).

Ratnakar Page 32
[Pick the date] [LINUX NOTES FOR LEVEL 2]

* We caio assiiio sgudt permissitios tt 'io' iot. tf gusers by specifyiioi ioames separated by
ctmmas ( ). tr liioe by liioe.
* Iiostead tf ii iioi all permissitios tt iotrmal guser we caio ii e tioly stme ctmmaiods.
Example : stgudeiot ALL=/Sgusr/Ssbiio/Sguseradd /Sgusr/Ssbiio/Sgusermtd
rajgu ALL=NOPASSWD:/Sgusr/Ssbiio/Sguseradd /Sgusr/Ssbiio/Sgusermtd
* We caio alst apply tt tioe irtgup tr irtgups as ftlltws.
* First create the gusers assiiio tioe irtgup tt thtse gusers aiod alst assiiio the passwtrds ftr that
gusers. Opeio /etc/sudoers fle by execgutioi the ctmmaiod # visudo aiod type as
ftlltws.
%<irtgup ioame> ALL=ALL
%tracle ALL=ALL tr iiodi idgual ctmmaiods separated by ctmmas
* We caio alst create tioe ctmmaiod alias aiod add stme ctmmaiods tt that alias aiod meiottio
that alias tt gusers as ftlltws.
Cmiod_Alias NETWORKING=/Sgusr/Ssbiio/Srtgute /Sgusr/Ssbiio/Sifctiofi
<guser ioame> <machiioes>=<ctmmaiod alias ioame>
rajgu ALL=NETWORKING
* We caio alst create tioe guser alias aiod add the gusers tt that alias aiod assiiio stme ctmmaiods
tt that alias as ftlltws.
User_Alias <guser alias ioame>=<guser1> <guser2> <guser3> .....
Example : User_Alias OURTEAMB=rajgu shyam ram itpal
OURTEAMB ALL=ALL (tt ii e all permissitios tf sgudt).
Defagults tmestamp_tmetgut=0 (wheioe er the sgudt guser execgutes aioy ctmmaiod theio it
will ask passwtrd
ftr e ery ctmmaiod).
* The abt e will apply tt all gusers iioclgudiioi rttt alst. If we waiot tt make it as tioly ftr iotrmal
gusers theio
Defagults : <guser1> <guser2> <guser3> tmestamp_tmetgut=0 (the system will ask
passwtrds ftr guser1
guser2 guser3 tt execgute sgudt ctmmaiods).
32. In which location the sudo user commands history is logged?
All the sgudt gusers ctmmaiods histtry is ltiied iio /var/log/secure fle tt make a rectrd tf
sgudt guser ctmmaiods.
# cat /S ar/Slti/Ssecgure (tt see the ctioteiots tf this fle).
# tailf /S ar/Slti/Ssecgure (tt see the gupdates tf this fle ctiotiogutgusly aiod press ctrl + c tt qguit
the tailf).
33. How to assign the password to normal user by him whenever first login to the system?
Wheioe er the guser is created aiod that guser is tryiioi tt ltiiio tt the system it will ask the
passwtrd. If the rttt guser is iott assiiio the passwtrd tt that guser theio that iotrmal guser caio
assiiio the passwtrd by his twio gusiioi the ftlltwiioi ctmmaiods.
# guseradd <guser ioame> (tt create the guser).

Ratnakar Page 33
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# passwd -S <guser ioame> (tt see the statgus tf the passwtrd tf that guser. if rttt guser is
iott assiiioed the passwtrd theio
the passwtrd statgus is locked).
# passwd -d <guser ioame> (theio delete the passwtrd ftr that guser).
# chaie -d 0 <guser ioame> (it will chaioie the passwtrd aie ptlicy).
# sgu - <guser ioame> (Try tt switch tt that guser theio it will display the ftlltwiioi
messaie).
Newpasswtrd : (type ioew passwtrd ftr that guser).
Retype passwtrd : (retype the passwtrd aiaiio).
The other useful commands :
# w (this ctmmaiod ii es the ltiiio guser iioftrmattio like htw maioy gusers cgurreiotly ltiiio
aiod their
prtcesses).
# wht (tt see gusers wht are cgurreiotly ltiiio aiod tio which termiioal they ltiiio).
# last (see the list tf gusers wht are ltiiio aiod ltitgut siioce the /var/log/wtmp fle was
created).
# lastb (tt see the list tf the gusers wht tried as bad ltiiios).
# lastrebttt (tt see all rebttts siioce the lti fle was created).
# guptme (tt see the iioftrmattio frtm htw ltioi the system is rguioioiioi htw maioy
gusers ltiiio aiod ltad
a eraie).
* The ltad a eraie is frtm 1 sec : 5 secs : 15 secs
# df (tt see the mtguioted partttios their mtguiot ptiiots aiod amtguiot tf disk
space).
# dgu (tt see the disk gusaie tf the each fle iio bytes).
# guioame -r (ii es the cgurreiot kerioel ersitio).
# last -x (It shtws last shgutdtwio date aiod tme).
# last -x irep shgutdtwio (tioly shgutdtwio tme shtws ie. irep will flter the 'last -x'
ctmmaiod).
* grep: It is gused tt search a wtrd tr seioteioce iio fle (ie. iioside the fle).
* find : It is gused tt search a ctmmaiod tr fle iioside the system).
# cat /Setc/Sshells tr # chsh -l (tt see htw maioy shells that are sgupptrted by Liiogux).
/Sbiio/Ssh -----> defagult shell ftr Uioix
/Sbiio/Sbash -----> defagult shell ftr Liiogux
/Ssbiio/Siotltiiio -----> gusers caioiott ltiiio shell
/Sbiio/Stcsh -----> c shell tt write 'C++' laioiguaie prtirams
/Sbiio/Scsh -----> c shell tt write 'C' laioiguaie prtirams
# echt $SHELL (tt see the cgurreiot shell).
# chsh <guser ioame> (tt chaioie the guser's shell).
Chaioiiioi shell ftr <guser ioame> :

Ratnakar Page 34
[Pick the date] [LINUX NOTES FOR LEVEL 2]

New shell : <type ioew shell ftr example /Sbiio/Ssh tt chaioie the cgurreiot shell>
New shell chaioied ( gut it will efeect by restartioi the ser er).
# date + %R (tt display the tme tioly).
# date + %x (tt display the date tioly).
# histtry (tt see the histtry tf the ctmmaiods).
#histtry -c (tt clear the histtry).
# histtry -r (tt rect er the histtry).
* .bash_history is the hiddeio fle tt sttre the histtry tf the guser ctmmaiods. y defagult
histtry sise is 1000.
# echt $HISTSIZE (tt check the cgurreiot histtry sise).
# exptrt HISTSIZE=500 (tt chaioie the cgurreiot histtry sise tt 500 temptrarily).
#exptrt HISTTIMBEFORMBAT=" "%D" "%T" " (tt display the date aiod tme tf each
ctmmaiod temptrarily).
# im /Setc/Sbashrc (tpeio this fle it tt last liioe aiod type as ftlltws tt make histtry sise
date & tme
ftrmats permaioeiotly).
HISTSIZE=1000
HISTTIMBEFORMBAT=' %D %T '
(sa e aiod exit the fle aiod tt gupdate the efeects by #source /etc/bashrc ctmmaiod).
# ~<guser ioame> (tt it tt gusers htme directtry).
# whats <ctmmaiod> (tt see the shtrt descripttio tf that ctmmaiod).
# whereis <ctmmaiod> (tt see the ltcattio tf that ctmmaiod aiod ltcattio tf the dtcgumeiot
tf that
ctmmaiod).
# reset (tt refresh the termiioal).
# whtami (tt see the cgurreiot guser ioame).
# wht a mi (tt see the cgurreiot guser with fgull details like ltiiio tme aiod tthers).
# passwd <guser ioame> (tt chaioie the passwtrd tf the guser).
# id (tt see the cgurreiot guser ioame guser id irtgup ioame aiod irtgup id ....
etc. ).
# id <guser ioame> (tt see the specifed guser ioame guser id irtgup ioame aiod irtgup id).
# sgu (tt switch tt rttt guser withtgut rttt guser htme directtry).
# sgu - (tt switch tt rttt guser with rttt guser htme directtry).
# sgu <guser ioame). (tt switch tt the specifed guser withtgut his htme directtry).
# sgu - <guser ioame> (tt switch tt the specifed guser with his htme directtry).
# lspci (tt list all the PCI sltts preseiot iio the system).
# dgu -sh /Setc/S (tt see the sise tf the /etc tio the disk iio K s tr MB s).
# ls -l (tt see the ltioi listioi tf the fles aiod directtries).
d rwx rwx rwx . 2 rttt rttt 6 Dec 17 18:00 File ioame
d -----> type tf fle

Ratnakar Page 35
[Pick the date] [LINUX NOTES FOR LEVEL 2]

rwx -----> twioer permissitios


rwx -----> irtgup permissitios
rwx -----> tthers permissitios
. -----> Nt ACL permissitios applied
rttt ----> twioer tf the fle
rttt ----> irtgup twioership
6 -----> sise tf the fle
Dec 7 18:00 -----> Date aiod Time tf the created tr mtdifed
File ioame -----> File ioame tf that fle

# ls -ld <directtry ioame> (tt see the ltioi listioi tf the directtries).
# stat <fle ioame/Sdirecttry ioame> (tt see the statstcs tf the fle tr directtry).
34. How many types of the files are there?
There are 7 types tf fles.
1. - -----> reigular fle
2. d -----> directtry
3. c -----> character de ice fle (Ex. ctiostle fle tpeio aiod cltse termiioals ...etc. ).
4. b -----> bltck de ice fle (Ex. de ice bltcks like hard disks CD/SDVD disks).
5. s -----> stcket fle (prtirammers will deal this fle).
6. p -----> pipe fle (prtirammers will deal this fle).
7. l -----> liioked fle (iotthiioi bgut shtrt cgut fle).
35. What are permission types available in Linux and their numeric representations?
There are maiioly three types tf permissitios a ailable iio Liiogux aiod thtse are
read ----- r ----- 4 iogull permissitio ------ 0
write ----- r ----- 4
execgute ----- r ----- 4
Permissitios File Directtry
r Read a fle Ex. # cat <fle ioame> Read a directtry ctioteiots Ex. ls /Sdir
Create delete tr mtdify the fles iio a
w Create delete tr mtdify the fle ctioteiots
directtry
Ntt reqguired ftr fle. It is reqguired tioly ftr
x Gt tt iioside the directtry Ex. # cd /Sdir
scriptioi fles

36. What is syntax of chmod command with full options?


# chmtd <tpttios><fle ioame tr directtry ioame> (tt chaioie the twioer tr
permissitios tf the fle tr
directtry).
The tpttios are -c -----> chaioies
-f -----> sileiot (ftrcefgully).
- -----> erbtse
-R -----> recgursi e (iioclgudiioi sgub directtries aiod fles).

Ratnakar Page 36
[Pick the date] [LINUX NOTES FOR LEVEL 2]

Tt chaioie the permissitios the syiotax is


# chmtd <wht> <what> <which> <fle ioame tr
directtry>
guser (gu). add (+). read (4). tr (r). " "
irtgup(i). remt e(-). write (2). tr (w). " "
tther (t). eqgual (=). execgute (1). tr (x). " "
37. What is the syntax of chown command with full options?
# chtwio <tpttios><fle ioame tr directtry> (tt chaioie the twioership tf the fle tr
directtry).
The tpttios are -c -----> chaioies
-f -----> sileiot (ftrcefgully).
- -----> erbtse
-h -----> iot difeereioce
-R -----> recgursi e (iioclgudiioi sgub directtries aiod fles).
-H -----> symbtlic liiok tt a directtry (ctmmaiod liioe arigumeiot).
-L -----> symbtlic liiok tt a directtry (all).
-p -----> dt iott tra erse
# chtwio <guserioame> : <irtgup ioame> <fle ioame tr directtry ioame> (tt chaioie twioer
aiod irtgup
twioership tf the fle tr directtry).
38. What is syntax of chgrp command with full options?
# chirp <tpttios><fle ioame tr directtry> (tt chaioie irtgup twioership tf the fle
directtry).
The tpttios are -c -----> chaioies
-f -----> sileiot (ftrcefgully).
- -----> erbtse
-h -----> iot difeereioce
-R -----> recgursi e (iioclgudiioi sgub directtries aiod fles).
-H -----> symbtlic liiok tt a directtry
-L -----> dt iott tra erse-p -----> dt iott tra erse
39. What are the default permissions of a file and directory?
The defagult permissitios tf a fle = 6 6 6
The defagult permissitios tf a directtry = 7 7 7
40. What is umask in linux?
The guser fle-creattio mtde mask (gumask). is gused tt determiioe the fle permissitios ftr ioewly
created fles tr directtries. It caio be gused tt ctiotrtl the defagult fle tr directtry permissitios ftr ioew
fles. It is a ftgur-diiit tctal iogumber. The gumask algue ftr iotrmal guser is 0002 aiod the gumask
algue ftr rttt guser is 0022.
St the efeected fle permissitios ftr iotrmal gusers = 6 6 6 - 0 0 2 = 6 6 4.
The efeected directtry permissitios ftr iotrmal gusers = 7 7 7 - 0 0 2 = 7 7 5.

Ratnakar Page 37
[Pick the date] [LINUX NOTES FOR LEVEL 2]

The efeected fle permissitios ftr rttt guser = 6 6 6 - 0 2 2 = 6 4 4


The efeected directtry permissitios ftr rttt guser = 7 7 7 - 0 2 2 = 7 5 5
# gumask < algue> (tt chaioie the gumask algue temptrarily).
# im /Setc/Sbashrc (tpeio this fle aiod chaioie the gumask algue tt efeect the whtle
system).
# stgurce /Setc/Sbashrc (tt gupdated the stgurce fle).
# im .bashrc (tpeio this fle iio guser's htme directtry aiod at last type as ftlltws).
gumask < algue>(sa e aiod exit the fle).
# stgurce .bashrc tr ltitgut aiod ltiiio aiaiio (tt the system tt efeect that gumask algue).
* If the/etc/login.defs fle is ctrrgupted theio ioew gusers will be added aiod caio be assiiioed the
passwtrds bgut gusers caioiott ltiiio.
* If the /etc/login.defs fle is deleted theio ioew gusers caioiott be added.
41. How change the permissions using numeric representation?
The algues ftr read = 4 write = 2 execgute = 1 aiod iogull = 0. The tttal algue = 4 + 2 + 1 = 7
# chmtd <iot.><iot.><iot.><fle ioame tr directtry ioame>
Example : # chmtd 7 7 4 fle1 (tt ii e read write aiod execgute tt twioer aiod read write
aiod execgute tt irtgup
aiod read permissitio tt tthers).
# chmtd 6 6 0 fle2 (tt ii e read aiod write tt twioer aiod read aiod write tt
irtgup aiod iogull (0).
permissitio tt tthers).
42. Explain about set uid (suid)?
If we plaio tt alltw all the gusers tt execgute the rttt gusers ctmmaiod theio we it ftr set guid
(sguid)..
It caio be applied ftr guser le el aiod is applicable ftr fles tioly.
# chmtd gu+s <fle ioame> (tt set the sguid tio that fle).
# chmtd gu-s <fle ioame> (tt remt e the sguid frtm that fle).
# ls -l (if 'x' is replaced with 's' iio twioer's le el permissitios that meaios sguid is applied
tio that fle).
-rwsrwxrwx <fle ioame> (here 's' is called set guid tr sguid).
Example : # chmtd gu+s /Sgusr/Ssbiio/Siioit 6 (theio aioy guser caio restart the system gusiioi
this ctmmaiod
#iioit 6).
# chmtd gu+s /Ssbiio/Sfdisk (theio aioy guser caio rguio the fdisk ctmmaiod).
# striiois <ctmmaiod ioame> (tt read the biioary laioiguaie tf the ctmmaiod ie. the striioi
ctmmaiod ctio erts the biioary
laioiguaie iiott hgumaio readable laioiguaie).
# striiois mkfs (tt read the mkfs ctmmaiod's biioary laioiguaie iiott hgumaio readable
laioiguaie).
* Ntrmally set guid (sguid). permissitio will be ii eio tio scriptioi fles tioly.

Ratnakar Page 38
[Pick the date] [LINUX NOTES FOR LEVEL 2]

43. Explain about set gid (sgid)?


If we plaio tt alltw all the gusers tf tioe irtgup tt iet the irtgup twioership permissitios theio we
it ftr set iid
(siid)..
It caio be applied ftr irtgup le el aiod is applicable tio directtries tioly.
Example: # chmtd i+s <directtry ioame> (tt set the siid tio that directtry).
# chmtd i-s <directtry ioame> (tt remt e the siid frtm that directtry).
44. Explain about sticky bit?
It prttects the data frtm tther gusers wheio all the gusers ha iioi fgull permissitios tio tioe
directtry.
It caio be applied tio tthers le el aiod applicable ftr directtries tioly.
Example : # chmtd t+t <directtry ioame> (tt set the stcky bit permissitio tio that
directtry).
# ls -ld <directtry ioame>
rwxrwxrwt <directtry ioame> (where 't' is called the stcky bit).
45. What are the uses of passwd and shadow files?
Passwd file : (i). Wheio we create the guser tioe eiotry is gupdated iio passwtrd aiod shadtw fles.
(ii). It represeiots aiod tell abtgut that guser ltiiio ioame guid iid defagult htme directtry tf the
guse aiod defagult shell.
(iii). St gusiioi this fle we caio easily iet gusers iioftrmattio.
Shadow file : (i). This fle tells abtgut the ltiiio id guser's eiocrypted passwtrd passwtrd wheio
last chaioied miio. days the passwtrd alid max. days alid warioiioi days
iioact e days aiod expiry days.
(ii). If shadtw fle is missed tr deleted we caio rect er thtse eiotries tf shadtw fle gusiioi
passwtrd fle.
(iii). We caio chaioie the gusers eiocrypted passwtrds with the permissitios tf the hiiher
aguthtrites iio case tf emerieiocy.
46. What is the use of group?
(i). Iio aio triaioisattio the whtle wtrk is di ided iiott departmeiots ftr easy maiioteioaioce aiod
easy admiioistrattio.
(ii). Ftr each departmeiot is alst represeioted as irtgup aiod that irtgup ha iioi st maioy gusers tt dt
difeereiot wtrks.
(iii). St if we create tioe irtgup aiod assiiio that irtgup tt all the gusers iio that departmeiot theio
we caio easily ideiotfy which guser beltiois tt which irtgup.
(i ). We caio share fles directtries aiod execgute stme prtirams tt that irtgup aiod alst ii e
permissitios tt that irtgup. St each guser tf that irtgup caio easily share thtse directtries
aiod alst caio easily access execgute tr e eio write iio thtse shared fles aiod directtries.
47. Can we login to the user without password?
Yes we caio ltiiio.
48. How to recover the root password if missed or deleted?

Ratnakar Page 39
[Pick the date] [LINUX NOTES FOR LEVEL 2]

RHEL - 6 :
(i). Restart the system.
(ii). Select 1st tpttio aiod press 'e'.
(iii). Select 2iod tpttio aiod press 'e'.
(i ). At the eiod ii e tioe blaiok space aiod type 1 aiod press Eioter key.
( ). Theio press 'b' tt bttt the system iio siioile guser mtde.
( i). Theio prtmpt appears aiod type # passwd root ctmmaiod.
New passwtrd : XXXXXX
Retype passwtrd : XXXXXX
( ii). Exit
( iii). Theio system starts as gusgual.
RHEL - 7 :
(i). Restart the system.
(ii). Usiioi arrtw keys select 1st liioe aiod press 'e' tt edit.
(iii). Gt tt Linux 16 liioe press Eiod key tr Ctrl + e tt it tt the eiod tf the liioe aiod ii e tioe
space.
(i ). Theio type as rd.break console=ty1 selinux=0
( ). Theio press Ctrl + x tt start the ctmpguter iio siioile guser mtde.
( i). Afer startioi we iet swith_root :/# prtmpt appears aiod theio type as ftlltws.
( ii). # mount -o remount, rw /sysroot aiod press Eioter aiod theio type as ftlltws.
( iii). # chroot /sysroot press Eioter.
(ix). Theio sh - 4.2 # prtmpt appears aiod type as
(x). sh - 4.2 #passwd root
New passwtrd : XXXXXX
Retype passwtrd : XXXXXX
(xi). sh - 4.2 # exit
(xii). switch-root :/# exit
(xiii). Theio the system starts aiod the deskttp appears.
49. How to restrict the users from login?
(i). y remt iioi (deletioi). the guser we caio restrict the guser frtm ltiiio.
(ii). Pgut the guser's htstioames as eiotries iio /etc/hosts.deny fle (applyiioi TCP wrappers)..
(iii). #passwd -l <user name> (by ltckiioi his passwtrd we caio restrict the gusers)..
50. How to put never expiry to a user?
# passwd -x -1 <guser ltiiio ioame>
51. Which one is the default sticky bit directory?
/tmp is the defagult stcky bit directtry.
52. What is the purpose of the profiles?
(i). Prtfle is a fle tt eioter stme setiois abtgut gusers wtrkiioi eio irtiomeiot. ie. we caio set guser
htme directtry ltiiio shell path ...etc.
Prtfles are twt types.

Ratnakar Page 40
[Pick the date] [LINUX NOTES FOR LEVEL 2]

(a). Gltbal prtfle


(b). Ltcal prtfle
Global profile :
(1). Oioly rttt guser caio set aiod applicable tt all the gusers.
(2). Oioly iltbal parameters caio eiotered iio this prtfle.
(3). The ltcattio tf the iltbal prtfle is /etc/bashrc
Local profile :
(1). E ery guser has his/Sher twio prtfle.
(2). The setiois eiotered iio this prtfle are tioly ftr that guser.
(3). The ltcattio tf the prtfle is .bash_profile (hiddeio fle). iio that partcgular guser's htme
directtry.
53. Can we mount/unmount the O/S file system?
Nt we caioiott mtguiot tr guiomtguiot the O/SS fle system.
54. How to find the users who are login and how to kill them?
# fguser -cgu (tt see wht are ltiiio).
#fguser -ck <guser ltiiio ioame> (tt kill the specifed guser).
55. what is Access Control List (ACL)?
Defioe mtre access riihts iotthiioi bgut permissitios tt fles aiod directtries. Usiioi Access Ctiotrtl
list we assiiio the permissitios tt stme partcgular gusers tt access the fles aiod directtries.
ACL caio cab be applied tio ACL eioabled partttio that meaios ytgu ioeed tt eioable ACL while
mtguiotioi the partttio.
56. How to implement ACLs?
 Create a partttio aiod ftrmat it with ext4 fle system.
 MBtguiot the fle system with ACL.
 Apply ACL tio it.
Create a partttio gusiioi # fdisk ctmmaiod.
Ftrmat the abt e partttio with ext4 fle system gusiioi # mkfs.ext4 <partition name>
ctmmaiod.
Create the mtguiot ptiiot gusiioi # mkdir /<mount point> ctmmaiod.
MBtguiot that fle system tio the mtguiot ptiiot gusiioi # mount -o acl <partition name><mount
point> ctmmaiod.
MBtguiot the partttio permaioeiotly gusiioi # vim /etc/fstab (tpeio this fle aiod make aio eiotry
as beltw).
<partition name><mount point><file system type> defaults, acl 0 0
Sa e aiod exit this fle.
If the partttio is already mtguioted theio jgust add acl afer defagults iio /etc/fstab fle aiod
execgute the beltw ctmmaiod # mount -o remount <partition name>
57. How to check the ACL permissions?
# ietacl <tpttios><fle tr directtry ioame>
The tpttios are -d -----> Display the defagult ACLs.

Ratnakar Page 41
[Pick the date] [LINUX NOTES FOR LEVEL 2]

-R -----> Recgurses iiott sgubdirecttries.


58. How to assign ACL permissions?
# setacl <tpttios><arigumeiot> : <guserioame>: <permissitios><fle tr directtry ioame>
The tpttios are -m -----> MBtdifes aio ACL.
-x -----> Remt es aio ACL.
-b -----> Remt e all the ACL permissitios tio that directtry.
-R -----> Recgurses iiott sgubdirecttries.
The arigumeiots are gu -----> guser
i -----> irtgup
t -----> tther
59. What is the syntax to assign read and write permissions to particular user, group and other?
# setacl -m gu : <guser ioame> : <permissitios><fle tr directtry>
# setacl -m i : <guser ioame> : <permissitios><fle tr directtry>
# setacl -m t : <guser ioame> : <permissitios><fle tr directtry>
60. What is the syntax to assign read and write permissions to particular user, group and other
at a time?
# setacl -m gu : <guser ioame> : <permissitios> i : <guser ioame> : <permissitios> t : <guser
ioame> : <permissitios><fle tr directtry>
Useful commands :
# setacl -x gu : <guser ioame><fle tr directtry ioame> (tt remt e the ACL permissitios
frtm the guser).
# setacl -x i : <guser ioame><fle tr directtry ioame> (tt remt e the ACL permissitios
frtm the irtgup).
# setacl -x t : <guser ioame><fle tr directtry ioame> (tt remt e the ACL permissitios
frtm the tther).
# setacl -b <fle tr directtry> (tt remt e all the ACL permissitios
tio that fle
directtry).
61. How will you lock a user, if he enters wrong password 3 times?
pam_tally.st mtdgule maiiotaiios a ctguiot tf attempted accesses caio reset ctguiot tio sguccess caio
deioy access if ttt maioy attempts fail. Edit /Setc/Spam.d/Ssystem-aguth fle eioter:
(i). # i /Setc/Spam.d/Ssystem-aguth
MBtdify as ftlltws:
auth required pam_tally.so no_magic_root
account required pam_tally.so deny=3 no_magic_root lock_time=180
Where
 deny=3 : Deioy access if tally ftr this guser exceeds 3 tmes.
 lock_time=180 : Always deioy ftr 180 sectiods afer failed attempt. There is
alstunlock_time=n tpttio. It alltw access afer io sectiods afer failed attempt. If this
tpttio is gused the guser will be ltcked tgut ftr the specifed amtguiot tf tme afer he

Ratnakar Page 42
[Pick the date] [LINUX NOTES FOR LEVEL 2]

exceeded his maximgum alltwed attempts. Otherwise the acctguiot is ltcked guiotl the ltck is
remt ed by a maiogual iioter eiottio tf the system admiioistrattr.
 magic_root : If the mtdgule is iio tked by a guser with guid=0 the ctguioter is iott iiocremeioted.
The sys-admiio shtguld guse this ftr guser laguioched ser ices like sgu ttherwise this arigumeiot
shtguld be tmitted.
 no_magic_root : A tid rttt acctguiot ltckiioi if the mtdgule is iio tked by a guser with guid=0
Sa e aiod cltse the fle.
62. How to see the no. of failed logins of the users?
# faillti -gu <guser ioame> (tt see the specifed gusers failed
ltiiio attempts).
# faillti -a (tt see failed ltiiio attempts tf all
gusers).
# faillti -MB <MBax. iot> -gu <guser ioame> (tt set MBax. ltiiio failed attempts tt
that guser).
# faillti -MB 5 -gu rajgu (tt set MBax. ltiiio failed attempts tt
5 ftr guser rajgu).
63. What is disk quotas and how to enable them?
y ctiofiguriioi the disk qguttas we caio restrict the guser tt guse guiolimited space tio the fle system
aiod alst tt restrict the guiolimited fles iio the fle system. We caio ctiofigure the disk qguttas iio
ways. They are
(i). guser qguttas
(ii). irtgup qguttas
Steps to enable :
First check whether the qgutta packaie is iiostalled tr iott by # rpm -qa |grep quota
ctmmaiod. If qgutta packaie is iott Iiostalled theio iiostall the qgutta packaie by # yum install
quota* -y ctmmaiod.
# qguttatio (tt eioable the qgutta).
# qguttatfe (tt disable the qgutta).
# edqgutta (tt edit tr mtdify the qgutta).
# repqgutta (tt display tr reptrt the preseiot qgutta).
# qguttacheck (tt create a qgutta database).
* qguttas cab be applied tio fle systems tioly.
64. How to enable the user quota on a file system?
(i). Opeio the /etc/fstab fle by # vim /etc/fstabctmmaiod aiod ittt the mtguiot ptiiot eiotry
liioe aiod type as
/Sde /Ssdb1 /Smiot/Sprtd ext4 defagults gusrqgutta 0 0 (sa e aiod
exit this fle).
(ii). Update the qgutta tio mtguiot ptiiot by # mount -o remount, usrquota <mount point>
ctmmaiod.

Ratnakar Page 43
[Pick the date] [LINUX NOTES FOR LEVEL 2]

(iii). Create the guser qgutta database by # quotacheck -cu <mount point> ctmmaiod
(where -c meaios created the qgutta
database aiod -gu meaios guser qgutta)..
(i ). Check whether the qgutta is applied tr iott by # mount ctmmaiod.
( ). Eioable the qgutta by # quotaon <mount point> ctmmaiod.
( i). Apply the guser qgutta ftr a guser by # edquota -u <user name><mount point>
ctmmaiod.
File system bltcks stf hard iiotdes stf
hard
/Sde /Ssdb1 0 0 0 0 0
0
bltcks -----> Nt. tf bltcks gused (already).
stf -----> Warioiioi limit
hard -----> MBaximgum limit
0 -----> Uiolimited gusaie
iiotdes -----> Nt. tf fles created (already).
* If stf=10 aiod hard=15 meaios afer crtssiioi the stf limit a warioiioi messaie will be
displayed aiod if hard limit is alst crtsses theio it wtio't alltw tt create the fles ftr
that guser.
(sa e aiod exit the abt e qgutta edittr).
65. How to enable the quota on block level?
(i). Apply the guser qgutta ftr a guser by # edquota -eu <user name><mount point>
ctmmaiod.
File system bltcks stf hard iiotdes stf
hard irace peritd
/Sde /Ssdb1 0 5000 10000 0 0 0
6 days
(sa e aiod exit the qgutta edittr).
stf=5000 -----> meaios if it reaches guptt 5MB there is iot warioiiois. If it exceeds ie.
frtm 5MB - 10MB there will be warioiiois messaies displayed bgut
the fles will be created.
hard=10000 ---> If it reached tt 10MB theio it will iott alltw tt create the fles. The irace
peritd by defagult is 7 days. St we caio chaioie the irace peritd by
#edquota -t ctmmaiod here we caio chaioie the defagult 7
days irace peritd tt tgur reqguired days tf irace peritd.
irace peritd meaios if the guser iott created aioy fles withiio the irace peritd days the stf
limit bectmes as hard limit. ie. stf aiod hard limits are eqgual.
# edqgutta -p <guser ioame 1><guser ioame 2> (tt apply guser ioame 1 qguttas tt guser ioame
2 ie. iot ioeed tt edit
the qgutta edittr ftr guser ioame 2).

Ratnakar Page 44
[Pick the date] [LINUX NOTES FOR LEVEL 2]

66. How to enable the group quota?


(i). Opeio the /etc/fstab fle by # vim /etc/fstab ctmmaiod aiod ittt the mtguiot ptiiot eiotry
liioe aiod type as
/Sde /Ssdb1 /Smiot/Sprtd ext4 defagults irpqgutta 0 0 (sa e aiod
exit this fle).
(ii). Update the qgutta tio mtguiot ptiiot by # mount -o remount, usrquota, grpquota <mount
point>ctmmaiod.
(iii). Create the guser qgutta database by # quotacheck -cug <mount point> ctmmaiod
(where -c meaios created the qgutta database -gu meaios
guser qgutta aiod -i meaios irtgup qgutta )..
(i ). Check whether the qgutta is applied tr iott by # mount ctmmaiod.
( ). Eioable the qgutta by # quotaon <mount point> ctmmaiod.
( i). Apply the guser qgutta ftr a guser by # edquota -g <group name><mount point>
ctmmaiod.
File system bltcks stf hard iiotdes stf
hard
/Sde /Ssdb1 0 0 0 0 0
0
bltcks -----> Nt. tf bltcks gused (already).
stf -----> Warioiioi limit
hard -----> MBaximgum limit
0 -----> Uiolimited gusaie
iiotdes -----> Nt. tf fles created (already).
* Here we caio specify the bltck le el qgutta tr fle le el qguttas.
* irtgup qgutta caio be applicable tt all the gusers tf that specifed irtgup.
(sa e aiod exit the abt e qgutta edittr).
67. How to change the password for multiple users at a time?
# chpasswd (tt chaioie mgultple guser's
passwtrds).
<guser ioame 1> : <passwtrd>
<guser ioame 2> : <passwtrd>
<guser ioame 3> : <passwtrd>
<guser ioame 4> : <passwtrd>
<guser ioame 5> : <passwtrd> (Ctrl + d -----> tt sa e aiod exit).
* Theio the abt e 5 guser's passwtrds will be chaioied at a tme. gut here the passwtrds will
iott be eiocrypted while typiioi passwtrds. St aioybtdy caio see the passwtrds. ie.
there is iot secgurity.

4. Network Configuration and Troubleshooting

Ratnakar Page 45
[Pick the date] [LINUX NOTES FOR LEVEL 2]

1. What is Network?
Ctmbiioattio tf twt mtre ctmpguters ctioioected ttiether tt share their restgurces each tther by
meaios tf ctmmguioicattio like cable is called Netwtrk.
2. What is Networking?
It is a ctioioecttio betweeio twt tr mtre ctmpguters tt ctmmguioicate with each tther.
3. what are the basic requirements for networking?
(a). NIC (Netwtrk Iioterface Card tr ctiotrtller).
(b). MBedia (iotthiioi bgut cables).
(c). Ttptltiy
(d). Prtttctl
(e). IP Addresses
4. Explain about NIC card?
A Netwtrk Iioterface Card tr ctiotrtller is hardware ctmptioeiot that ctioioects a ctmpguter tt a
ctmpguter ioetwtrk. Each NIC card will be ha iioi MBAC (MBedia Access Ctiotrtller). address tt
a tid ctioficts betweeio same NIC adapters. Iio Liiogux these NIC adapter is represeioted by the wtrd
"eth" . Ftr example if twt NIC cards are there iio a system theio it will be deiotted as
"eho","eth1", .....etc.
5. What is media?
MBedia is iotthiioi bgut cable tt ctioioect twt tr systems. Example : RJ 45, CAT 5 aiod CAT 6
....etc.
6. What is topology?
Ttptltiy is a desiiio iio which the ctmpguters iio ioetwtrk will be ctioioected tt each tther.
Example ftr ttptltiies are gus Riioi Star MBesh Tree ttptltiies.
7. What is protocol?
A Network Protocol defioes rgules aiod ctio eiottios ftr ctmmguioicattio betweeio the ioetwtrk
de ices. Prtttctls are ieioerally guse packet switchiioi techioiqgues tt seiod aiod recei e messaies
iio the ftrm tf packets.
Example ftr prtttctls are TCP/IP (Traiosmissitio Ctiotrtl Prtttctl aiod Iioterioet Prtttctl). UPD
(User Datairam Prtttctl). aiod HTTP (Hyper Text Traiosfer Prtttctl). ....etc.
8. What are the diferences between TCP/IP and UDP protocols?
TCP/SIP UDP
Traiosmissitio Ctiotrtl Prtttctl User Datairam Prtttctl
It is ctioioecttio trieioted It is ctioioecttio less
Reliable Ntio-Reliable
TCP Ackiotwlediemeiot will be seiot /S recei ed Nt Ackiotwlediemeiot
Sltw ctmmguioicattio Fast ctmmguioicattio
Prtttctl Nt. ftr TCP is 6 Prtttctl Nt. ftr UDP is 17
HTTP FTP SMBTP ....etc. guses TCP DNS DHCP ....etc. guses UDP

9. What is an IP address?

Ratnakar Page 46
[Pick the date] [LINUX NOTES FOR LEVEL 2]

E ery Ctmpguter will be assiiioed aio IP address tt ideiotfy each tioe tt ctmmguioicate iio the
ioetwtrk. The IP address sgub ctmptioeiots are Classes tf aio IP address Sgubioet masks aiod
Gateway.
Classes of IP address :
The IP addresses are fgurther di ided iiott classes. The classes are A C D E aiod the raioies
are ii eio beltw.
Class Start Eiod Defagult Sgubioet mask Classless Iioter Dtmaiio Rtgutioi
Class A 0.0.0.0 127.255.255.255 255.0.0.0 /S8
Class 128.0.0.0 191.255.255.255 255.255.0.0 /S16
Class C 192.0.0.0 223.255.255.255 255.255.255.0 /S24
Class D 224.0.0.0 239.255.255.255
Class E 240.0.0.0 255.255.255.255

10. What is loopback address?


A special IP iogumber (127.0.0.1). is desiiioated ftr the stfware lttpback iioterface tf a machiioe.
127.0.0.0 aiod 127.255.255.255 is alst reser ed ftr lttpback aiod is gused ftr iioterioal testioi tio
ltcal machiioes.
11. What is multicasting?
MBgultcastioi alltws a siioile messaie tt be seiot tt a irtgup tf recipieiots. Emailiioi aiod
Telectiofereiociioi are examples tf mgultcastioi. It guses the ioetwtrk iiofrastrguctgure aiod staiodards
tt seiod messaies.
12. What is subnet mask?
A sgubioet mask alltws the gusers tt ideiotfy which part tf aio IP address is reser ed ftr the
ioetwtrk aiod which part is a ailable ftr htst guse.
13. What is Gateway?
A Gateway is the ioetwtrk ptiiot that prt ides eiotraioce iiott aiotther ioetwtrk. Oio the iioterioet a
iotde tr sttppiioi ptiiot caio be either iateway iotde tr a htst (eiod ptiiot). iotde. tth the
ctmpguters tf iioterioet gusers aiod the ctmpguter that ser e the paies tt gusers are htst iotdes.
The ctmpguter that ctiotrtl trafc withiio ytgur ctmpaioy's ioetwtrk tr at tgur ltcal iioterioet ser ice
prt ider (ISP). are the iateway iotdes.
14. What are important configuration files in network configuration?
# cat /etc/sysconfig/network (This fle keeps the iioftrmattio abtgut the htstioame
assiiioed tt the system aiod if we waiot tt chaioie the htstioame permaioeiotly we
ioeed tt chaioie the htstioame iio this fle).
# cat /etc/sysconfig/network-scripts/ (This directtry keeps the ctiofigurattio tf ioetwtrk
de ices ctioioected tt the system. Examples are
ifcfg-eht0, ifcfg-eth1, ifcfg-eth2, .....etc. ).
# cat /etc/hosts (This fle is resptiosible ftr restl iioi htstioame iiott IP address ltcally. ie.
ltcal DNS if DNS
ser er is iott a ailable).

Ratnakar Page 47
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# cat /etc/resolve.conf (This fle keeps the address tf the DNS ser er tt which the clieiots
will be accessiioi tt restl e IP address tt
htstioame aiod htstioame tt IP address).
15. What are the diferences between MAC and IP addresses?
MAC Address IP Address
It is a permaioeiot address. St we caioiott chaioie this It is a temptrary address. St we caio chaioie this
address. address aioy iot. tf tmes.
It staiods ftr MBedia Access Ctiotrtl Address. Iioterioet Prtttctl address.
It is a physical address. It is a ltiical address.
It is twt types.
IPV4 :(It is di ided iiott 4 parts ).
It is di ided iiott 6 parts. --- . --- . --- . --- (each 8 bits. St 8 X 4 = 32 bits
--- : --- : --- : --- : --- : --- (each 8 bits. St 8 X 6 = 48 bits IPV6 : ( It is di ided iiott 16 parts ).
--- . --- . --- . --- . --- . --- . --- . --- . --- . --- . --- . --- .
--- . --- . --- . --- (each 8 bits. St 8 X 16 = 128 bits.
ifconfig (tt see the MBAC address). # ifconfig (tt see the IP address).
16. How many types of NIC cards available?
(a). eth0 (1st NIC card).
(b). eth1 (2iod NIC card).
(c). br0 ( ridie -----> gused ftr ctmmguioicattio frtm physical tt irtgual).
(d). lt (lttpback de ice ioame aiod IP address is 127.0.0.1).
# ifctiofi (tt see all the NIC de ices ctioioected tt the system).
17. How many types of cable connections available?
(i). Crtss cable (tt ctioioect twt systems directly).
(ii). Straiiht cable (tt ctioioect mtre systems with the help tf switch).
# ethtttl <de ice ioame> (tt check the ioetwtrk cable is ctioioected tr iott).
# miitttl <de ice ioame> (It is alst gused tt check the ioetwtrk cable bgut it will iott
sgupptrts RHEL - 7 aiod tioly sgupptrts RHEL - 6 aiod it alst wtrks tio
physical system tioly iott tio irtgual system).
18. In how many ways we can configure the network?
There are twt ways tt ctiofigure the ioetwtrk.
(a). Statc Netwtrk.
(b). Dyioamic Netwtrk.
Static Network :
Iio this way we assiiio the IP address aiod htstioame maiogually. Oioce we ctiofigure the IP address
it will iott chaioie.
Dynamic Network :
Iio this way we assiiio the IP address aiod htstioame dyioamically. This meaios the IP address will
chaioie at e ery bttt.
19. How to assign the static IP address to the NIC card?

Ratnakar Page 48
[Pick the date] [LINUX NOTES FOR LEVEL 2]

In RHEL - 6 :
# setgup
(MBt e the cgurstr tt Netwtrk ctiofigurattio aiod press Eioter key).
(MBt e the cgurstr tt De ice ctiofigurattio aiod press Eioter key).
(Select the NIC adapter ie. eth0 aiod press Eioter key).
(Assiiio the abt e IP address aiod tther details as per tgur reqguiremeiots aiod mt e the cgurstr tt
"OK" aiod press
Eioter key).
(MBt e the cgurstr tt "Sa e" tt sa e the chaioies iio de ice ctiofigurattio aiod press Eioter key).
(Oioce aiaiio mt e the cgurstr tt "Sa e & Qguit" bgutttio aiod press Eioter key).
(Fiioally mt e the cgurstr tt "Qguit" bgutttio aiod press Eioter key tt qguit the gutlity).
(Theio restart the ioetwtrk ser ice aiod check ftr the IP address by # service network restart
ctmmaiod).
(If the chaioie is iott refected with the abt e ser ice theio restart the ioetwtrk maioaier by
# service NetworkManager restart
ctmmaiod).
# ifctiofi (tt see the IP address tf the NIC card).
# piioi < IP address > (tt check whether the IP is piioiiioi tr iott).
In RHEL - 7 :
# iomcli ctioioecttio shtw (tt see all the ioetwtrk ctioioecttios).
# iomcli de ice shtw (tt see the ioetwtrk details if already ctiofigured maiogually tr
dyioamically).
# iomcli ctioioecttio add ctio-ioame "System eth0" ifioame eth0 type etherioet (tt add the
ioetwtrk ctioioecttio).
# iomcli ctioioecttio mtdify "System eth0" ip 4.addresses ' < IP address >/S< ioetmask ><
iateway > ' ip 4.dios < dios ser er IP address > ip 4.dios-search < dtmaiio ioame>
ip 4.methtd <statc tr maiogually> (tt assiiio IP address iateway dios dtmaiio ioame
aiod ctiofigure the ioetwtrk as statc tr maiogually).
# iomcli ctioioecttio gup "System eth0" (tt gup the ctioioecttio).
# systemctl restart ioetwtrk (tt restart the ioetwtrk ser ice).
# systemctl eioable ioetwtrk (tt eioable the ioetwtrk ser ice).
# ifctiofi (tt see the IP address tf the NIC card).
# piioi < IP address > (tt check whether the IP is piioiiioi tr iott).
20. What are the diferences between RHEL - 6 and RHEL - 7 network configuration files?
RHEL - 6 RHEL - 7
/etc/sysconfig/network-scripts is the directtry /etc/sysconfig/network-scripts is the directtry
which ctiotaiios the NIC ctiofigurattio iioftrmattio. which ctiotaiios the NIC ctiofigurattio iioftrmattio.
/etc/sysconfig/network-scripts/ifcfg-<device name> /etc/sysconfig/network-scripts/ifcfg-<device name>
is the fle which ctiotaiios the NIC ctiofigurattio details. is the fle which ctiotaiios the NIC ctiofigurattio details
/etc/resolve.conf is the fle which ctiotaiios DNS /etc/resolve.conf is the fle which ctiotaiios DNS

Ratnakar Page 49
[Pick the date] [LINUX NOTES FOR LEVEL 2]

ser er IP aiod dtmaiio ioame ltcattio. ser er IP aiod dtmaiio ioame ltcattio.
/etc/sysconfig/network is the htstioame
/etc/hostname is the htstioame ctiofigurattio fle.
ctiofigurattio fle.
/etc/hosts is the fle which ctiotaiios the ltcal DNS /etc/hosts is the fle which ctiotaiios the ltcal DNS
ser er IP address. ser er IP address.

21. What are the diferences between Dynamic and Static configuration information?
Dynamic configuration information Static configuration information
Device =<NIC de ice ioame> Device =<NIC de ice ioame>
HWADDR=02:8a:a6:30:45 HWADDR=02:8a:a6:30:45
Bootproto=DHCP Bootproto=iotioe (meaios statc ioetwtrk).
Onboot=yes (yes meaios wheioe er we restart the
system this ctioioecttio will be act ated aiod no
Onboot=yes
meaios wheioe er we restart the system the
ctioioecttio will be deact ated).
Type=Etherioet Type=Etherioet
Userctl=yes/Siot ----> If it is yes all iotrmal gusers caio Userctl=yes/Siot ----> If it is yes all iotrmal gusers caio
disable the NIC card aiod If it is no except rttt guser disable the NIC card aiod If it is no except rttt guser
iotbtdy caio disable the NIC card. iotbtdy caio disable the NIC card.

22. How to set the hostname temporarily and permanently?


RHEL - 6 :
# htstioame <fgully qgualifed dtmaiio ioame> (tt set the htstioame temptrarily).
# im /Setc/Ssysctiofi/Sioetwtrk (tt set the htstioame permaioeiotly).
HOSTNAMBE=<fgully qgualifed dtmaiio ioame>
(sa e aiod exit this fle).
# ser ice ioetwtrk restart (tt gupdate the htstioame iio the ioetwtrk).
# chkctiofi ioetwtrk tio (tt eioable the ctioioecttio at ioext rebttt).

RHEL - 7 :
# htstioame <fgully qgualifed dtmaiio ioame> (tt set the htstioame
temptrarily).
# htstioamectl set-htstioame <fgully qgualifed dtmaiio ioame> (tt set the htstioame
permaioeiotly).
# systemctl restart ioetwtrk (tt gupdate the htstioame iio
the ioetwtrk).
# systemctl eioable ioetwtrk (tt eioable the ctioioecttio at
ioext rebttt).
23. How to troubleshoot if the NIC is notworking?
(a). First check the NIC card is preseiot tr iott by # ifconfig ctmmaiod.
(b). If preseiot theiocheck the statgus tf the NIC card is eioabled tr disabledby click tio System
meiogu tio the statgus bar theio select Netwtrk Ctioioecttios meiogu.

Ratnakar Page 50
[Pick the date] [LINUX NOTES FOR LEVEL 2]

(c). Click tio IPV4 setiois tab select the de ice eth0 tr aioy tther aiod select Eioable bgutttio
theio Apply aiod OK.
(d).Opeio /etc/sysconfig/network-scripts/ifcfg-eth0 fle check Userctl=yes tr iot. If it is yes
make it as iot theio check Oiobttt= yes tr iot. If it is iot make it as yes aiod sa e that fle.
(e). If iott preseiot theiocheck the statgus tf the NIC card is eioabled tr disabled by click tio System
meiogu tio the statgus bar theio select Netwtrk Ctioioecttios meiogu.
(f). Click tio IPV4 setiois tab select the de ice eth0 tr aioy tther aiod select Eioable bgutttio theio
Apply aiod OK.
(i). Usiioi # setup (iio RHEL - 6). tr # nmcli (iio RHEL - 7). ctmmaiods assiiio the IP address tt the
system aiod restart the ioetwtrk ser ice by # service network restart (iio RHEL - 6). tr #
systemctl restart network (iio RHEL - 7). ctmmaiods aiod eioable the ser ice at ioext rebttt
by # chkconfig network on (iio RHEL - 6). tr # systemctl enable network (iio RHEL - 7).
ctmmaiods.
(h). Theio gup the ctioioecttio by # ifconfig eth0 up (iio RHEL - 6). tr # nmcli connection up
<connection name> ctmmaiods.
(i). E eio thtguih it is iott wtrkiioi may be the fagult iio NIC card. If st ctiotact the hardware eiodtr
by takiioi the permissitios frtm hiiher aguthtrites.
24. What is bonding and how to configure bonding? (from RHEL - 6)
What is link aggregation or bridging or teaming and how to configure teaming? (from RHEL -
7)
Bonding or Teaming or Bridging:
Ctllecttio tf mgultple NIC cards aiod make them as siioile ctioioecttio ( irtgual). NIC card is called
btiodiioi.
It is iotthiioi bgut backgup tf NIC cards.
Iio RHEL - 6 it is called as tiodiioi tr ridiiioi.
Iio RHEL - 7 it is called as Teamiioi tr Liiok aiireiattio.
There are 3 types tf backgup iio tiodiioi tr Teamiioi.
(a). MBtde 0 -----> Rtguiod Rtbbiio
(b). MBtde 1 -----> Act ebackgup
(c). MBtde 3 -----> rtadcastioi
Mode 0 :
 It prt ides ltad balaiociioi aiod fagult ttleraioce.
 Data will be shared by btth NIC cards iio rtguiod rtbbiio.
 If tioe NIC card failed theio aiotther NIC card will be act ated tt ctmmguioicate with the
ser er
 St there is a ltad balaiociioi aiod fagult ttleraioce featgures.
Mode 1 :
 Act ebackgup meaios tioly tioe NIC card is act ated at a tme aiod aiotther tioe is iio dtwio
state.
 St there is iot ltad balaiociioi.

Ratnakar Page 51
[Pick the date] [LINUX NOTES FOR LEVEL 2]

 gut if tioe NIC card is failed theio aiotther NIC card will be act ated aguttmatcally.
Mode 3 :
 Iio this mtde brtadcastioi is dtioe.
 Iio this the same data will be traiosferred thrtguih twt NIC cards.
 St there is iot ltad balaiociioi.
 gut if tioe NIC card is failed theio sectiod NIC card will be act ated aguttmatcally.
St all the 3 mtdes are sgupptrts tioly fagult ttleraioce bgut rtguiod rtbbiio is the tioly tioe mtde
that prt ides ltad balaiociioi.
Requirements to configure :
(i). MBiioimgum twt NIC cards.
(ii). Oioe IP address.
(iii).Ctioioecttio type is btiod (iio RHEL - 6). aiod team (iio RHEL - 7). iott the etherioet type.
Here iot ioeed tt assiiio the IP addresses ftr twt NIC cards aiod we are ii iioi tioly tioe IP
address tt btiod tr team.
Bonding configuration : (iio RHEL - 6).
(i). # im /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-btiod0
DEVICE=btiod0
IP ADDR=<IP address>
TYPE=etherioet
NETMBASK=255.225.225.0 tr <IP address class ioetmask>
ON OOT=yes
OOTPROTO=iotioe
USERCTL=iot
MBASTER=yes
ONDING_OPTS="mtde0 tr mtde1 tr mtde3 miimtio=50" (Sa e aiod exit this
fle).
(ii). im /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-eth1
DEVICE=eth1
ON OOT=yes
OOTPROTO=iotioe
USERCTL=iot
MBASTER=btiod0
SLAVE=yes (Sa e aiod exit this fle).
(iii). im /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-eth2
DEVICE=eth2
ON OOT=yes
OOTPROTO=iotioe
USERCTL=iot
MBASTER=btiod0
SLAVE=yes (Sa e aiod exit this fle).

Ratnakar Page 52
[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i ).To add virtual NIC cards eth1 and eth2 :


# setgup -----> Netwtrkiioi -----> De ice ctiofigurattio -----> New De ice -----> eth1
Name : eth1
De ice : eth1 (sa e aiod exit this setgup).
# setgup -----> Netwtrkiioi -----> De ice ctiofigurattio -----> New De ice -----> eth2
Name : eth2
De ice : eth2 (sa e aiod exit this setgup).
( ). Adding bond0 connection :
# setgup -----> Netwtrkiioi -----> De ice ctiofigurattio -----> New De ice -----> btiod0
Name : btiod0
De ice : btiod0
IP address : <IP address>
Netmask : 255.255.255.0
Defagult iateway : <iateway IP address> (sa e aiod exit this setgup).
# ifdtwio btiod0
# ifdtwio eth1
# ifdtwio eth2
# ifgup btiod0
# ser ice NetwtrkMBaioaier sttp
# ser ice ioetwtrk restart
# chkctiofi ioetwtrk tio
# ser ice NetwtrkMBaioaier restart
# cat /Sprtc/Sioet/Sbtiodiioi/Sbtiod0 (tt check the btiodiioi iioftrmattio).
# watch -io 1 cat /Sprtc/Sioet/Sbtiodiioi/Sbtiod0 (tt check the btiodiioi iioftrmattio ftr e ery
1 miiogute).
# echt "eth1" > /Ssys/Sde ices/S irtgual/Sioet/Sbtiod0/Sbtiodiioi/Sact e_sla e (tt pgut the eth1
NIC iio act e state).
Teaming configuration :
(i). Add the team0 ctioioecttio by
# iomcli ctioioecttio add ctio-ioame team0 ifioame team0 type team
ctiofi ' { "rguioioer" : { "ioame" : "rtguiodrtbbiio" tr "act ebackgup" tr
"brtadcastioi" }} '
(ii). Add the twt NIC cards tioe by tioe tt the abt e created ctioioecttio by
# iomcli ctioioecttio add ctio-ioame ptrt1 ifioame eth1 type team-sla e master team0
# iomcli ctioioecttio add ctio-ioame ptrt2 ifioame eth2 type team-sla e master team0
(iii). Assiiio the statc IP address tt the team0 ctioioecttio by
#iomcli ctioioecttio mtdify team0 ip 4.addresses <IP address>/S<ioetmask> ip 4.methtd
statc
(i ).Up the ctioioecttio by
# iomcli ctioioecttio gup team0

Ratnakar Page 53
[Pick the date] [LINUX NOTES FOR LEVEL 2]

( ). Tt see the team0 ctioioecttio gup details by


# teamdctl team0 state
( i).Tt check the ctioioecttio ctmmguioicattio by
# piioi -I team0 <IP address>
( ii). Tt dtwio the tioe NIC card iio team0 by
# iomcli ctioioecttio dtwio ptrt1
( iii). teamdctl team0 state (tt check the team0 NIC card gup tr dtwio details).
25. What is the diference between TCP and UDP protocol?
TCP is a ctioioecttio trieioted prtttctl aiod ctiotaiio the iioftrmattio tf seioder as well as recei er.
Example : HTTP FTP Telioet
 TCP is sltwer thaio UDP dgue tt its errtr checkiioi mechaioism
 UDP prtttctls are ctioioecttio less packets ha e iot iioftrmattio tt where they are itiioi.
These type tf ptrts are ieioerally gused ftr brtadcastioi.
For example : DNS DHCP
 UDP are faster
26. What are the benefits of NIC Teaming?
(i). Ltad balaiociioi
(ii). Fagult Ttleraioce
(iii).Failt er
27. Mention all the network configuration files you would check to configure your ethernet card?
(i). /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-eth*
(ii). /Setc/Ssysctiofi/Sioetwtrk
(iii)./Setc/Srestl e.ctiof
(i ). /Setc/Siosswitch.ctiof
28. What is the use of /etc/resolve.conf?
It ctiotaiios the details tf ioameser er i.e. details tf ytgur DNS ser er which helps gus ctioioect tt
Iioterioet.
29. What is the use of /etc/hosts file?
Tt map aioy htstioame tt its rele aiot IP address.
30. What is the command to check all the open ports of your machine?
#iomap ltcalhtst
31. What is the command to check all the open ports of remote machine?
# iomap <IP address tr htstioame tf the remtte system>
32. What is the command to check all the listening ports and services of your machine?
# ioetstat -iotgulp
33. How can you make a service run automatically afer boot?
# chkctiofi <ser ice ioame> tio
34. What are the 6 run levels of linux? And how can you configure your script to run only when
the system boots into GUI and not to any other runlevel?

Ratnakar Page 54
[Pick the date] [LINUX NOTES FOR LEVEL 2]

0 Ptwer tfe
1 Siioile guser
2 MBgult guser withtgut ioetwtrk
3 MBgultguser with ioetwtrk
4 De eltpmeiot pgurptse
5 GUI
6 Restart
# chkctiofi --le el 5 ser ice_ioame tio
# chkctiofi --le el 1234 ser ice_ioame tfe
35. What is a 3 way handshake protocol? Give an example of it.
SYN - system 1 seiods SYN siiioal tt remtte system.
SYN-ACK - remtte system recei es the syio siiioal aiod seiods ack siiioal.
ACK - system aiaiio recei es ack siiioal frtm remtte system aiod ctioioecttio is established.
For Example: Wheio ytgu piioi tt a machiioe ytgu are seiodiioi a SYN siiioal which is ACK by the
remtte machiioe theio it seiods a SYN ACK siiioal back tt the htst machiioe. Theio the htst
machiioe recei es SYN ACK aiod seiods the ACK siiioal back tt ctiofrm the same.
36. What are the possible ways to check if your system is listening to port 67?
# iomap ltcalhtst | irep 67
# ioetstat -iotgulp | irep 67
37. Explain about IPV6?
It's leioith is 128 bits. It's ioetmask is 64
# iomcli ctioioecttio mtdify "System eth0" ip 6.addresses 2005:db8:0:1::a00:1/S64
ip 6.methtd statc
(tt add the IPV6 ersitio tf IP address tt the ctioioecttio
"System eth0" ).
# iomcli ctioioecttio mtdify "System eth0" ip 4.addresses '172.25.5.11/S24 172.25.5.254'
ip 4.dios
172.25.254.254 ip 4.dios-search example.ctm ip 4.methtd statc ip 6. addresses
2005:ac18::45/S64
ip 6.methtd statc (tt assiiio ip 4 aiod ip 6 IP addresses tt "System
eth0 ctioioecttio).
# iomcli ctioioecttio dtwio "System eth0" (tt dtwio the "System eth0" ctioioecttio).
# iomcli ctioioecttio gup "System eth0" (tt gup the "System eth0" ctioioecttio).
38. How to troubleshoot if the network is not reaching?
(i). First check the ioetwtrk cable is ctioioected tr iott by # ethtool <NIC device name>
ctmmaiod. if ctioioected theio check the IP address is assiiioed tr iott by # ifconfig <NIC
device name> ctmmaiod.
(ii). Theio check the system guptme by # uptime ctmmaiod.
(iii). Theio check the ioetwtrk ser ices statgus by # service network status aiod # service
NetworkManager status ctmmaiods.

Ratnakar Page 55
[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i ). Theio check the ioetwtrk ser ice at Rguio Le el by # Chkconfig --list network ctmmaiod.
( ). Theio check whether the stgurce ioetwtrk aiod destioattio ioetwtrk are iio the same dtmaiio tr
iott.
( ). Theio fioally check the rtgutioi table by # route -n ctmmaiod.

Other useful commands :


# piioi <IP address tr htstioame> (tt check the piioiiioi).
Ntrmally the piioi ctmmaiod piiois ctiotiogutgusly guiotl a sttp siiioal reaches by Ctrl + c st tt
a tid ctiotiogutgus piioiiioi by
# piioi -c <iogumber><IP address> (tt piioi guptt the specifed iot tf tmes).
# ipcalc -m <IP address). (tt fiod the sgubioet mask ftr that specifed IP
address).
Ntrmally IP addresses are assiiioed by ISP (Iioterioet Ser ice Prt ider). aiod maioaied by IANA
(Iioterioet Assiiio
Ngumber Aguthtrity).
# ifctiofi (tt see tr check all the NIC de ice ioames
aiod IP addresses).
# ethtttl <NIC de ice ioame> (tt check the ioetwtrk cable is ctioioected tr
iott).
# miitttl <NIC de ice ioame> (It is alst gused tt check the ioetwtrk cable
bgut it wtrks tio physical system iott tio irtgual
system aiod sgupptrts iio RHEL - 6 tioly).
# ip addr shtw (tt shtw all NIC de ices preseiot tio the
system).
# htstioame (tt see the htstioame with fgully qgualifed
dtmaiio ioame).
# htstioame -i (tt see the IP address tf the system).
# htstioame -d (tt check the dtmaiio ioame tf the system).
# htstioame -s (tt check the htstioame withtgut dtmaiio
ioame).
# ioetstat -r (tt check the defagult iateway aiod rtgutioi
table).
# rtgute (tt check the defagult iateway with rtgutioi
table).
# ip rtgute (tt display the NIC de ice with defagult
iateway).
# dii tr # htst tr #ioslttkgup (all are gused tt restl e the ioame tt IP aiod
IP tt ioame).
# ioslttkgup <IP address> (tt restl e IP tt ioame).
# ioslttkgup <htstioame> (tt restl e ioame tt IP).

Ratnakar Page 56
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# htst <IP address> (tt restl e IP tt ioame).


# htst <fgully qgualifed dtmaiio ioame> (tt restl e ioame tt IP address).
# dii -x <IP address> (tt restl e IP address tt ioame).
# dii <fgully qgualifed dtmaiio ioame> (tt restl e ioame tt IP address).
# iomcli (Netwtrk MBaioaier Ctmmaiod Liioe Iioterface
gused tt ctiofigure
the ioetwtrk setgup iio RHEL - 7).
# setgup (tt setgup the statc ioetwtrk iio RHEL - 2 3 4
5 aiod 6).
# iomtgui (tt setgup the statc ioetwtrk iio GUI mtde ftr
RHEL - 7).
# iomcli de ice shtw (It displays all the NIC de ices ioetwtrk iioftrmattio
tf the system ).
# iomcli de ice shtw eth0 (tt see all the ioetwtrk de ices iioftrmattio
tf the eth0).
# iomcli ctioioecttio tr iomcli ctioioecttio shtw (tt see all the ioetwtrk ctioioecttio ioames).
# iomcli ctioioecttio add ctio-ioame <ctioioecttio ioame> ifioame <NIC de ice ioame> type
etherioet
(tt create a ioew ctioioecttio ioame ftr eth0).
# iomcli ctioioecttio shtw --act ate (it shtws which ctioioecttio is act e
cgurreiotly).
# iomcli ctioioecttio add ctio-ioame <ctioioecttio ioame> ifioame <NIC de ice ioame> type
etherioet
(tt add a ctioioecttio ioame tt NIC de ice).
# iomcli ctioioecttio mtdify <ctioioecttio ioame> ip 4.addresses ' <IP
address>/S<ioetmask><defagult iateway> '
ip 4.dios <dios ser er IP address> ip 4.dsio-search <dtmaiio ioame> ip 4.methtd
<statc/Smaiogual>
(tt mtdify the ctioioecttio as statc aiod assiiio the IP iateway dios IP
dtmaiio ioame).
# iomcli ctioioecttio delete <ctioioecttio ioame> (tt delete the specifed ctioioecttio).
# iomcli ctioioecttio mtdify <ctioioecttio ioame> ip 4.methtd <statc/Smaiogual> (tt mtdify
dyioamic ctioioecttio
tt statc ctioioecttio).
# iomcli ctioioecttio gup <ctioioecttio ioame> (tt act ate tr gup the specifed ctioioecttio).
# iomcli ctioioecttio dtwio <ctioioecttio ioame> (tt disable tr dtwio the specifed
ctioioecttio).
# iomcli ctioioecttio shtw <ctioioecttio ioame> (tt see the iioftrmattio abtgut the specifed
NIC de ice).

Ratnakar Page 57
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# piioi -I <NIC de ice ioame><IP address> (tt check the ctioioecttio frtm NIC de ice tt IP
address).
# htstioame <fgully qgualifed dtmaiio ioame> (tt set the htstioame temptrarily).
# htstioamectl set-htstioame <fgully qgualifed dtmaiio ioame> (tt set the htstioame
permaioeiotly iio RHEL - 7).
NOTE: Wheioe er we chaioie aioy parameters iio /etc/sysconfig/network-scripts/ifcfg-<NIC
device name> fle theio we ha e tt reltad that fle aiod aiaiio we ha e tt gup the ctioioecttio
(iotthiioi bgut act ate the ctioioecttio by # nmcli connection reload ctmmaiod.
# iomcli ctioioecttio reltad (tt reltad the ctiofigurattio tf the ctioioecttio if aioy chaioies tio it
aiod it reltads all
ctiofigurattio fles).
# iomcli ctioioecttio reltad /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-<NIC de ice ioame> (tt
reltad a siioile fle).
# htstioamectl statgus (it displays fgull details tf the htstioame aiod wtrks
iio RHEL - 7 tioly).
# iomcli ioetwtrkiioi tfe (tt disable all the ctioioecttios at a tme).
# iomcli de ice statgus (tt display all NIC de ice ctioioecttios
statguses).
# iomcli ctioioecttio mtdify <ctioioecttio ioame> + ip 4.dios <sectiodary dios ser er IP> (tt
add a sectiodary dios
ser er IP tt the existioi ctioioecttio).
# ioetstat -iotgulp (tt check htw maioy tpeio ptrts are there iio
ltcal system).
# ss -iotgulp ( " "
).
# iomap (tt check htw maioy tpeio ptrts are there iio
remtte system).
# tracepath (it displays the rtgutioi iioftrmattio).
# miitttl <NIC de ice ioame> (tt check the ioetwtrk cable is ctioioected tr
iott).
# ethtttl <NIC de ice ioame> ( " "
).
# ifctiofi (tt check the NIC card is eioable tr iott).
# ifgup <NIC de ice ioame> (tt eioable tr gup the NIC card).
#ifdtwio <NIC de ice ioame> (tt disable tr dtwio the NIC card).
# rtgute -io (tt check the iateway).
# cat /Setc/Srestl e.ctiof (tt check the dios ser er iioftrmattio).
# cat /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-<NIC de ice ioame> (tt see the NIC de ice
iioftrmattio).
# htstioame tr cat /Setc/Ssysctiofi/Sioetwtrk (tt check the htstioame iio RHEL - 6).

Ratnakar Page 58
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# htstioamectl statgus tr cat /Setc/Shtstioame (tt check the htstioame iio RHEL - 7).
# piioi <IP address> (tt check the ctioioecttio ctmmguioicattio).
# chkctiofi --list (tt list all the ser ices which are rguioioiioi at btt tme
iio RHEL - 6 & 7).
# systemctl list-guioit-fles (tt list all the prtcesses which are rguioioiioi at bttt
tme iio RHEL - 7).
# chkctiofi --le el <ser ice ioame> (it will set the ser ice at rguio le el 3 wheio the system
is btttioi).
# ser ice --statgus-all (tt see the list tf all the prtcesses which are
cgurreiotly rguioioiioi).
# ls /Setc/Siioit.d (is the ltcattio tf all the ser ices aiod deamtios iio
RHEL - 6).
# ls /Sgusr/Slib/Ssystemd/Ssystem (is the ltcattio tf all the ser ices aiod deamtios iio
RHEL - 7).
# /Setc/Src.ltcal (is the last script tt be rguio wheio the system is
btttioi).
(If we eioter as sshd stop at the last liioe tf the script fle theio sshd will be sttpped e eio
thtguih that
sshd is eioabled).
# ser ice sshd statgus (tt check the sshd statgus).
# ser ice --ser ice -all (tt see the prtcess ID tf all the ser ices).
# ioetstat -iotgulp (tt see all the ser ices with ptrt iot. statgus prtcess
ID aiod all tpeio ptrts iio ltcal system rtgutioi table
aiod NIC de ice iioftrmattio).
-io -----> ptrt iot. (iogumeric iot). -t ----->tcp prtttctl
-gu -----> gupd prtttctl -l -----> ptrt is listeioiioi tr iott
-p -----> display the prtcess ID
# ioetstat -r (tt see all rtgutioi table iioftrmattio).
# ioetstat -i (tt see all the NIC cards iioftrmattio).
# iomap (tt see the ioetwtrk mappiioi ie. tpeio ptrts list tio
remtte system).
Note : y defagult this ctmmaiod will iott a ailable. St frst iiostall the nmap packaie by # you
install nmap -y
# iomap <remtte system IP address> (tt see all the ser ices which are rguioioiioi iio the specifed
remtte system).
# iomap <remtte IP 1><remtte IP 2><remtte IP 3> (tt see the rguioioiioi ser ices tio specifed
remtte systems).
# iomap 172.25.0.11 - 50 (tt see the rguioioiioi ser ice tio 172.25.0.11 tt
172.25.0.50 systems).

Ratnakar Page 59
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# iomap -p 80 <remtte IP> (tt see the http ptrt is rguioioiioi tr iott tio specifed remtte
system).
# iomap -p 80 - 90 <remtte IP> (tt see ptrt iot's 80 tt 90 are rguioioiioi tr iott tio remtte
systems).
# iomap -sp 172.25.0.0/S24 (tt see all the systems which are iio gupstate ie. 172.25.0.1
172.25.0.2
(where s -- scaio & p -- piioi). 172.25.0.3 ......guptt
172.25.0.254 systems).
Opeio a fle write all the systems IP addresses sa e & exit the fle. Example has ii eio beltw
# im ctss
172.25.2.50
172.25.3.50
172.25.4.50 ....etc. (sa e aiod exit this fle).
# iomap -iL ctss (tt scaio all the IP addresses by readiioi the ctss fle).(where -i ---->
iiopgut -L ----> list).
# iomap --ifist (tt see all the rtgutioi table iioftrmattio iio the ioetwtrk).
# iomap 172.25.0.10 - 20 --exclgude 172.25.0.15 (tt scaio all the systems frtm 172.25.0.10
tt 172.25.0.20 systems aiod
exclgudiioi 172.25.0.15 system).
# iomcli ctioioecttio shtw --act e (tt ctiotrtl the ioetwtrk ctioioecttios).
# ip liiok (tt check the ioetwtrk ctioioecttio).
# piioi -I eth1 <IP address> (tt check the 2iod NIC card ctioioecttio).

Ratnakar Page 60
[Pick the date] [LINUX NOTES FOR LEVEL 2]

5. Managing SELinux

1. What is SELinux?
It is a tioe type tf secgurity that eiohaioces the secgurity that alltws gusers aiod admiioistrattrs mtre
ctiotrtl t er which gusers aiod applicattios caio access which restgurces sguch as fles Staiodard
Liiogux access ctiotrtls etc.
It is maiioly gused tt prttect iioterioal data (iott frtm exterioal data). frtm system ser ices. Iio real
tme SELiiogux is disabled aiod iiostead tf this IP tables are gused. It prttects all the ser ices fles
aiod directtries by defagult if SELiiogux is eioabled.
2. In how many ways we can implement the SELinux? Explain them.
We caio implemeiot the SELiiogux maiioly iio 2 mtdes.
(i). Eioabled
(ii). Disabled (defagult mtde).
Enabled :
Eioabled meaios eioabliioi the SELiiogux ptlicy aiod this mtde tf SELiiogux is di ided iiott twt parts.
(a). Eioftrciioi
(b). Permissi e

Ratnakar Page 61
[Pick the date] [LINUX NOTES FOR LEVEL 2]

Disabled :
Disabled meaios disabliioi the SELiiogux ptlicy.
3. What is Enforcing mode in SELinux?
Eioftrciioi meaios SELiiogux is tio. It checks SELiiogux ptlicy aiod sttred a lti. Nt caio access the
ser ices by defagult bgut we caio chaioie the ptlicy wheioe er we ioeeded.
4. What is Permissive mode in SELinux?
SELiiogux is tio aiod it dtio't check SELiiogux ptlicy aiod sttred the lti. E erybtdy caio access the
ser ices by defagult aiod we caio alst chaioie the SELiiogux ptlicy. It is alst called as debguiiiioi
mtde tr trtgubleshtttioi mtde. Iio this mtde SELiiogux ptlicies aiod rgules are applied tt sgubjects
aiod tbjects bgut acttios are iott afeected.
5. What is Disabled mode in SELinux?
SELiiogux is tgurioed tfe aiod iot warioiioi aiod lti messaies will be ieioerated aiod sttred.
6. What are Booleans?
ttleaios are ariables that caio either be set as trgue tr false. ttleaios eiohaioce the efeect tf
SELiiogux ptlicies implemeioted by the System Admiioistrattrs. A ptlicy may prttects certaiio
deamtios tr ser ices by applyiioi aritgus access ctiotrtl rgules.
7. What is SELinux policy?
The SELiiogux ptlicy is the set tf rgules that iguide the SELiiogux secgurity eioiiioe. It defioes types ftr
fle tbjects aiod dtmaiios ftr prtcess. It guses rtles tt limit the dtmaiios that caio be eiotered aiod
the guser ideiottes tt specify the rtle that caio be attaiioed.
8. What are the required files for SELinux?
# im /Setc/Sseliiogux/Sctiofi -----> It is maiio fle ftr SELiiogux.
# im /Setc/Ssysctiofi/Sseliiogux -----> It is a liiok fle tt the abt e fle.
# im /S ar/Slti/Sagudit/Sagudit.lti -----> SELiiogux lti messaies will be sttred iio this fle.
9. what is the command to see the SELinux mode?
# ieteioftrce (tt check the SELiiogux mtde).
10. What is command to set the SELinux mode temporarily?
# seteioftrce 0 tr 1 (tt set the SELiiogux mtde. Where ' 0 ' -----> permissi e aiod ' 1 '
-----> Eioftrciioi).
Note : (i). Tt chaioie the SELiiogux mtde frtm Permissi e tt Eioftrciioi tr Eioftrciioi tt
Permissi e mtdes the system restart is iott reqguired.
(ii). Tt chaioie Eioftrciioi mtde tt Disabled mtde tr Disabled mtde tt Eioftrciioi mtde
the system restart is reqguired.
(iii). The abt e ctmmaiods are chaioied the SELiiogux mtde temptrarily tioly. Tt make the
seliiogux chaioies permaioeiotly theio tpeio /etc/selinux/config aiod it tt
SELINUX=Enforcing or Permissive or Disabled (sa e aiod
exit this fle).
11. What is command to see the SELinux policy details?
# sestatgus (tt see the SELiiogux ptlicy details).
Other useful commands :

Ratnakar Page 62
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# ls -Z <fle ioame> (tt see the SELiiogux ctiotext tf the fle).


# ls -ldZ <directtry ioame> (tt see the SELiiogux ctiotext tf the directtry).
# ps -efZ | irep <prtcess ioame> (tt see the SELiiogux ctiotext tf the prtcess rguioioiioi tio the
system).
# ps -efZ | irep http (tt see the SELiiogux ctiotext tf the http prtcess rguioioiioi tio
the system).
# chctio -t <arigumeiot> <fle/Sdirecttry ioame> (tt chaioie SELiiogux ctiotext tf the fle tr
directtry).
# chctio -t pgublic_ctioteiot_t /Spgublic (tt chaioie the SELiiogux ctiotext tf the
/public directtry).
# chctio -R pgublic_ctioteiot_t /Spgublic (tt chaioie the SELiiogux ctiotext tf the
/public directtry aiod
its ctioteiots).
# resttrectio - <fle/Sdirecttry ioame> (tt resttre the pre itgus SELiiogux ctiotext tf
the fle/Sdirecttry).
# resttrectio - /Spgublic (tt resttre the pre itgus SELiiogux ctiotext tf
that directtry).
# resttrectio -R <directtry> (tt resttre the pre itgus SELiiogux ctiotext tf
the directtry aiod
its ctioteiots).
# resttrectio -R /Spgublic (tt resttre the pre itgus SELiiogux ctiotext tf
the /Spgublic
directtry aiod its ctioteiots).
# ietsebttl -a | irep <ser ice ioame> (tt see the bttleaios tf the specifed
ser ice).
# ietsebttl -a | irep fp (tt see the bttleaios tf the fp ser ice).
# setsebttl <bttleaio><tpttio tio/Stfe> (tt chaioie the bttleaio tf a specifed ser ice).
# setsebttl alltw_fpd_aiotio_write tio (tt chaioie the bttleaio tf the fpd ser ice
temptrarily).
# setsebttl -P <ser ice ioame> = <0/S1> (tt chaioie the bttleaio ftr the ser ice tio tr tfe
permaioeiotly).
# setsebttl -P samba_exptrt_all_rw = 1 (tt chaioie the bttleaio ftr samba ser ice
permaioeiotly tio).

Ratnakar Page 63
[Pick the date] [LINUX NOTES FOR LEVEL 2]

6. Booting Procedure and Kernel parameters

1. Explain the booting procedure?


Iio Liiogux systems the btttioi is dtioe iio 6 staies.
 IOS
 MB R
 GRU
 Kerioel
 Iioit
 Rguiole el
BIOS :
IOS staiods ftr asic Iiopgut aiod Ogutpgut System. Wheioe er we ptwer tio the system the system
rguios self diaiiotstc checks aiod detects all the ctioioected iiopgut aiod tgut peripherals. This
prtcess is called POST (Ptwer Oio Self Test).. If aioy errtrs ftguiod it displays tio the screeio. Theio
IOS ltcates the btttioi disk iio the system aiod ltcates aiod ltads the Primary bttt ltader iotthiioi
bgut MB R (MBaster ttt Rectrd). iiott the memtry. St iio simple terms the IOS ltads the MB R iiott
memtry aiod execgutes the MB R.
MBR :
MB R staiods ftr MBaster ttt Rectrd. It is ltcated iio the 1st secttr tf the btttable disk (it may
be /Sde /Shda tr /Sde /Ssda).. The sise tf the MB R is 512 bytes aiod it ctiotaiios three ctmptioeiots.
(i). Primary bttt ltader iioftrmattio aiod its sise is 446 bytes.
(ii). Partttio table iioftrmattio aiod its sise is 64 bytes.
(iii).MB R alidattio check aiod its sise is 2 bytes. Its maiio pgurptse is whether the MB R is alid tr
iott.
The primary bttt ltader ctiotaiios the sectiodary bttt ltader iotthiioi bgut GRU tr LILO (iio tld
systems)..
Theio primary bttt ltader ltcates aiod ltads the sectiodary bttt ltader iiott memtry.
St iio simple terms the MB R ltads aiod execgutes the GRU bttt ltader.
GRUB or LILO :
GRU staiods ftr Graiod Uioifed ttt ltader. LILO staiods ftr Liiogux Ltader aiod is gused iio tld Liiogux
systems. If we ha e mgultple kerioel imaies iiostalled iio tgur system we caio chttse which tioe tt be
execguted. GRU displays a splash screeio waits ftr few sectiods. If we dt iott eioter aioythiioi it

Ratnakar Page 64
[Pick the date] [LINUX NOTES FOR LEVEL 2]

ltads the defagult kerioel imaie as specifed iio the irgub ctiofigurattio fle. GRU has the
kiotwledie tf the fle system (the tld LILO didio't guioderstaiod the system).. GRU
ctiofigurattio fle is /boot/grub/grub.conf (/etc/grub.conf is a liiok tt this).. This fle ctiotaiios
kerioel aiod iioitrd imaies. St iio simple terms GRU jgust ltads aiod execgutes kerioel aiod iioitrd
imaies.
Kernel :
Kerioel iioitalises itself aiod ltads the kerioel mtdgules aiod mtguiots the rttt fle system as
specifed iio the "rttt=" iio irgub.ctiof aiod theio kerioel execgutes the /sbin/init prtiram. Siioce iioit
was the 1st prtiram tt be execguted by Liiogux kerioel it has the prtcess ID (PID). tf 1. We caio see this
id by # ps -ef | grep init ctmmaiod. iioitrd staiods ftr iioital RAMB Disk. iioitrd is gused by kerioel
as temptrary fle system guiotl kerioel is bttted aiod the real rttt the fle system is mtguioted. It
alst ctiotaiios ioecessary dri ers ctmpiled iioside which helps it tt access the hard dri e partttios
aiod tther hardware.
init level :
Iio this iioit prtiram reads the /etc/initab fle aiod pgut the system iiott specifed rguio le el. iioit
ideiotfes the defagult rguio le el frtm /etc/initab fle aiod we caio chaioie the this defagult rguio le el
wheioe er we ioeeded. We caio fiod the defagult rguio le el by # grep "initdefault" /etc/initab
ctmmaiod tio tgur system. Ntrmally the
defagult rguio le el iio Liiogux is 3 iio CLI (Ctmmaiod Liioe Iioterface). mtde aiod 5 iio GUI (Graphical
User Iioterface). mtde.
Run Level Programs :
The ftlltwiioi rguio le els are a ailable iio Liiogux systems.
 0 -----> halt tr shgutdtwio the system
 1 -----> Siioile guser mtde
 2 -----> MBgult guser withtgut NFS
 3 -----> Fgull mgult guser mtde bgut iot GUI aiod tioly CLI mtde
 4 -----> Uiogused
 5 -----> Fgull mgult guser mtde with GUI (X11 system).
 6 -----> rebttt the system
Wheioe er we start the Liiogux system is btttioi we caio see aritgus ser ices ietioi started.
Thtse ser ices are ltcated iio difeereiot rguio le els prtirams execguted frtm the rguio le el
directtry as defioed by tgur defagult rguio le el. Depeiodiioi tio tgur defagult iioit le el setioi the system
will execgute the prtirams frtm tioe tf the ftlltwiioi directtries.
 Rguio le el 0 -----> /Setc/Src.d/Src0.d
 Rguio le el 1 -----> /Setc/Src.d/Src1.d
 Rguio le el 2 -----> /Setc/Src.d/Src2.d
 Rguio le el 3 -----> /Setc/Src.d/Src3.d
 Rguio le el 4 -----> /Setc/Src.d/Src4.d
 Rguio le el 5 -----> /Setc/Src.d/Src5.d
 Rguio le el 6 -----> /Setc/Src.d/Src6.d

Ratnakar Page 65
[Pick the date] [LINUX NOTES FOR LEVEL 2]

The abt e directtries are alst ha iioi symbtlic liioks a ailable ftr thtse directtries guioder
/etc/rc0.d, /etc/rc1.d, ....etc. St the /Setc/Src0.d is liioked tt /Setc/Src.d/Src0.d
Booting procedure in RHEL - 7:
Uptt kerioel the btttioi prtcess is same as the abt e. /boot/grub2/grub.conf is the GRU
ctiofigurattio fle iio RHEL - 7. systemd is the iioital prtcess iio RHEL - 7 aiod its prtcess ID is 1.
linux16 read the rttt ( /S ). fle system aiod theio initrd16prtcess will mtguiot the rttt ( /S ). fle
system iio read & write mtde aiod starts the systemdprtcess. Aiod the systemd prtcess will
read the /etc/fstab fle aiod mtguiot all the fle systems. Theio it reads the fle
/etc/systemd/system/default.target fle aiod briiois the system iiott the defagult rguio le el
acctrdiioi tt the scripts the prtcesses will start tr sttp.
2. How to check the current run level of the system?
# wht -r (tt see the preseiot rguio le el tf the system).
3. How to change the default run level?
First tpeio the /etc/initab fle by # vim /etc/initab ctmmaiod aiod it tt last liioe chaioie
the rguio le el iogumber as we reqguired aiod theio rebttt the system by # init 6 ctmmaiod. Afer
rebtttioi the system check the cgurreiot rguio le el by # who -r ctmmaiod.
4. How to start the graphical interface if the system is in run level 3 now?
# startx (it chaioies the rguio le el 3 tt 5 aiod rebttts the system).
5. How to troubleshoot if the boot disk is not available?
(i). First check the hard disk is preseiot iio the system tr iott. If iott preseiot ctioioect the hard disk
aiod restart the system.
(ii). If the hard disk is preseiot theio it tt IOS aiod fiod the ltcattio tf the hard disk.
(iii). Check the bttt pritrity iio the IOS. If bttt pritrity is iott the hard disk theio chaioie it tt
hard disk aiod restart the system.
(i ).E eio thtguih the system is iott started theio bttt the system with CDROMB iio siioile guser
mtde aiod tpeio the /Sbttt/Sirgub/Sirgub.ctiof fle aiod see the hard disk ioame aiod partttio
iogumber. Ntrmally it shtguld be /dev/hda1 (if the hard disk is IDE hard disk). tr
/dev/sda1 (if the hard disk is SATA tr SCSI).. If the hard disk ioame aiod partttio
iogumber is difeereiot iiostead tf the triiiioal theio chaioie them aiod rebttt the system
with hard disk.
( ).If the GRU is ctrrgupted theio rebttt the system with CDROMB iio siioile guser mtde aiod
resttre the irgub iioftrmattio frtm the receiot backgup aiod theio restart the
system with hard disk.
6. How to reboot the production server?
(i). Iio ieioeral the prtdgucttio ser ers will iott be rebttted freqgueiotly becaguse the eiod gusers will
sgufeer if the prtdgucttios ser er are iio dtwio state. If aioy chaioies made tt the system like
irgub seliiogux ptlicy defagult rguio le el is chaioied aiod if kerioel patches are applied the system
rebttt is reqguired.
(ii). If aioy iioctiosisteiocy is rttt ( /S ). fle system theio take the bgusiioess apprt al frtm hiiher
aguthtrites make a plaio ftr prtper schedguleaiod alst iioftrm tt the difeereiot teams like

Ratnakar Page 66
[Pick the date] [LINUX NOTES FOR LEVEL 2]

applicattio team tt sttp the applicattio databaseteam tt sttp the databases QC


team tt sttp the testioi mtioittriioi petple tt iiiotre the alerts frtm thisser er aiod tther
teams if aioy aiod theio rebttt the system withCDROMB iio siioile guser mtde aiod theio rguio
#fsck ctmmaiod tio that fle system.
(iii).If O/SS disk is ctrrgupted tr damaied theio rebttt the system temptrarily with the mirrtr
disk theio fx that prtblem aiod aiaiio bttt the system with triiiioal disk.
7. What is the diference between # reboot and # init 6 commands?
tth ctmmaiods are gused tt restart tr rebttt the system.
# reboot ctmmaiod will iott seiod the kill siiioals tt the system aiod it will kill all the rguioioiioi
prtcesses aiod ser ices ftrcefgully aiod theio restart the system.
# init 6 ctmmaiod will seiod the kill siiioals tt the system aiod it will sttp all the prtcesses aiod
ser ices tioe by tioe aiod theio restart the system.
8. What is console port and how to connect to the console port?
Ctiostle ptrt is gused tt ctioioect the system e eio thtguih the system is iott bttted with the maiio
O/SS. This ptrt is gused tt ctioioect the system ftr trtgubleshtttioi pgurptse tioly. We caio ctioioect
the ctiostle ptrt as same as ctioioect tt systems LAN ptrt aiod it is alst ha iioi IP address guser
ioame aiod passwtrd tt ctioioect tt the ctiostle.
There are difeereiot types tf ctiostle ptrts ftr difeereiot types tf ser ers. They are ii eio beltw.
Server Name Name of the Console port Expansion name
DRAC ---> DELL Remtte Access Ctiotrtllers
DELL DRAC tr i-DRAC i-DRAC ---> Iioteirated DELL Remtte Access
Ctiotrtllers
I MB Ptwer series HMBC Hardware MBaioaiemeiot Ctiostle
HP ILO Iioteirated Liiht Ogut

9. System is continuously rebooting. How to troubleshoot it?


(i). Ctioioect the system thrtguih ctiostle ptrt thrtguih pgutty by prt idiioi IP address guser ioame
aiod passwtrd. (ii). At ctiostle prtmpt aiod bttt with CDROMB iio siioile guser mtde aiod mtguiot
the rttt ( /S ---> O/SS). fle system tio temptrary mtguiot ptiiot.
(iii).Check aioy wrtioi eiotries iio the crtio jtbs ie. crtiotab edittr see aioy rebttt scripts are there
tr iott. If ftguiod remt e thtse eiotries aiod rebttt the system.
(i ).If the abt e is iott restl ed theio check the memtry (RAMB)..
( ). If RAMB mtdgule is iott wtrkiioi the system iet paioic aiod it may ctiotiogutgusly rebttts.
( i). If the RAMB mtdgule is wtrkiioi theio check the RAMB sise whether the sgufcieiot RAMB that
reqguires tt rguio the applicattio is a ailable tr iott. If iott there theio iiocreasiioi the RAMB
sise may be restl e this issgue.
( ii). Check "/var/log/messages" fle ftr aioy messaies reiardiioi ctiotiogutgus rebtttioi.
( iii). E eio thtguih there is a sgufcieiot RAMB may be swap space is iott sgufcieiot tt rguio all the
ser ices aiod applicattios theio system iet paioic aiod may ctiotiogutgusly rebttts.
If st theio iiocreasiioi the swap sise may restl e this issgue.
10. What is TCP handshaking?

Ratnakar Page 67
[Pick the date] [LINUX NOTES FOR LEVEL 2]

The prtcedgure that takes place betweeio twt TCP/SIP iotdes tt establish a ctioioecttio. Kiotwio as
the Syiochrtioisattio Syiochrtioise-Ackiotwlediemeiot aiod Ackiotwlediemeiot haiodshake.
Ftr example if ctmpguter A traiosmits a Syiochrtioise packet tt ctmpguter which seiods back a
Syiochrtioise- Ackiotwledie packet tt ctmpgute A. Ctmpguter A theio traiosmits aio Ackiotwledie
packet tt ctmpguter aiod the ctioioecttio is established. This whtle abt e said prtcess is called
the TCP haiodshakiioi.
11. How many links will be created when we create the directory?
Wheioe er we create aioy directtry there are twt liioks will be created.
12. What are the diferences between run level 2 and run level 3?
Run Level 2 :
(i). It sgupptrts mgultguser tperattios.
(ii). MBgultple gusers caio access the system.
(iii).All the system deamtios will rguio except NFS aiod stme tther ioetwtrk ser ice related
deamtios.
(i ).St withtgut NFS we caio guse all tther ser ices.
Run Level 3 :
(i). It is alst sgupptrts MBgult guser tperattios.
(ii). MBgultple gusers caio access the system.
(iii).All the system deamtios iioclgudiioi NFS aiod tther ioetwtrk related ser ice deamtios will
rguio.
(i ). St we caio a ail all the ser ices iioclgudiioi NFS alst.
13. Server running in single user mode, can you login remotely and how?
We caio ltiiio tt the system remttely iio siioile guser mtde alst bgut it is ptssible tt ctioioect tt
ctiostle iiostead tf LAN ptrt thrtguih pgutty tttl by ii iioi IP address guser ioame aiod passwtrd.
Theio ctiostle ptrt appears aiod bttt the system with CDROMB iio siioile guser mtde.
14. How to check the present kernel version?
# guioame -r (it displays the preseiot kerioel ersitio).
# guioame -a (it displays the preseiot kerioel ersitio with tther details).
# cat /Sbttt/Sirgub/Sirgub.ctiof (iio this fle alst we caio fiod the kerioel ersitio).
15. What is the command to see the system architecture?
# arch tr # guioame -m (btth ctmmaiods ii es the architectgure tf the system).
16. How to check the version of the O/S ?
# cat /Setc/Sredhat-release (ii es the ersitio tf the O/SS).
17. How to repair the corrupted boot loader and recover it?
This prtblems may be tccgur if the GRU is ctrrgupted. St we ha e tt rect er the GRU .
asically the repairiioi tf GRU meaios iiostalliioi the ioew irgub tio the existioi tioe frtm RHEL - 6
DVD. The steps are ii eio beltw.
(i). Iiosert the RHEL - 6 DVD aiod make sgure that system shtguld bttt frtm CD/SDVD.
(ii). ttt the system iio Rescgue Iiostalled System mtde.
(iii).Select the laioiguaie with which we waiot tt ctiotiogue aiod click tio OK.

Ratnakar Page 68
[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i ). Select the Keybtard type as US aiod click OK.


( ). Select Ltcal CD/SDVD aiod click OK.
( i).MBt e the cgurstr tt NO tt iiiotre the Netwtrkiioi.
( ii). MBt e the cgurstr tt Ctiotiogue tab tt mtguiot the rttt ( /S ). frtm CD/SDVD aiod press Eioter
key.
( iii). Ntw the rttt ( /S ). fle system is mtguioted tio /Smiot/Ssysimaie here click tio OK aiod Press
Eioter tt ctiotiogue.
(ix).Select the "shell Start shell" tpttio aiod click tio OK theio shell will be displayed tio screeio.
(xi). At shell prtmpt type as # chroot /mnt/sysimage ctmmaiod press Eioter.
(xii). Check the /Sbttt partttio by # fdisk -l ctmmaiod.
(xiii). Iiostall the ioew irgub tio the bttt de ice ie. may be /Sde /Ssda2 by # grub-install <device
name> ctmmaiod (Ftr example #
irgub-iiostall /Sde /Ssda2)..
(xi ). If it shtw iot errtr reptrted that meaios we ha e sguccessfgully rect ered the irgub.
(x ). Theio type # exit ctmmaiod aiod aiaiio type # exit tr # reboot ctmmaiod tt rebttt the
system.
18. What are Modules or Kernel Modules? How to find the Kernel Modules?
The dri ers is Liiogux system are kiotwio as MBtdgules tr Kerioel MBtdgules. These mtdgules are
assiiioed by kerioel depeiodiioi tio the hardware. Hardware caio tioly be ctmmguioicated aiod caio
wtrk efcieiotly wheio the prtper mtdgule is ltaded iio the kerioel. we caio fiod the kerioel
mtdgules by # ls /etc/lib/modules ctmmaiod.
All the kerioel mtdgules iio the system will be eioded with " .ko " exteiositio. St we caio see all
the mtdgules iio the system by # find / -name *.ko ctmmaiod.
19. What other commands related to kernel modules?
# lsmtd (tt list all the cgurreiotly ltaded mtdgules).
# lsmtd |irep -i <mtdgule ioame> (tt check whether the partcgular mtdgule is
ltaded tr iott).
# lsmtd |irep -i fat (tt check the fat mtdgule is ltaded tr iott).
There miiht be a sitguattio where tgur mtdgule is iott wtrkiioi prtperly iio that case we ha e tt
remt e that mtdgule aiod re-iiostall it aiaiio by
# mtdprtbe -r <mtdgule ioame> (tt remt e the specifed mtdgule).
# mtdprtbe -r fat (tt remt e the fat mtdgule).
# mtdprtbe <mtdgule ioame> (tt iiostall tr re-iiostall the mtdgule).
# mtdprtbe fat (tt iiostall tr re-iiostall the mtdgule).
# mtdiioft <mtdgule ioame> (tt see the specifed mtdgule iioftrmattio).
# guioame (tt see the which O/SS is preseiot iio the
system).
# guioame -s (tt see which O/SS kerioel is this either Liiogux
tr Uioix).
# rpm -qa kerioel --last (tt see the kerioel iiostallattio date aiod tme).

Ratnakar Page 69
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# rpm -qa kerioel* (tt see htw maioy kerioels are there iio the
system).
# ls /Sprtc (tt see the kerioel prtcesses iioftrmattio).
# ls /Sbttt (tt see the preseiot kerioel ersitio created
tme). # ls /Setc/Slib/Smtdgules (iiostalled kerioel mtdgule dri ers).
# ls /Sgusr/Ssrc (kerioel stgurce ctde ltcattio).
# kgudsgu (tt scaio the ioew hardware iio RHEL - 4).
# depmtd (tt scaio the ioew hardware frtm RHEL - 5 6
aiod 7).
# rmmtd <mtdgule ioame> (tt remt e the specifed mtdgule).
# iiosmtd <mtdgule ioame> (tt iiostall the kerioel mtdgule withtgut
depeiodeiocy mtdgules).
20. How to see the run level?
# wht -r (tt see the cgurreiot rguio le el).
21. How to block the USB / CDROM driver?
# lsmtd |irep -i gusb (tt see the US mtdgule is ltaded tr iott).
# mtguiot (tt check the US is mtguioted tr iott).
# mtdprtbe -r gusb_sttraie (remt e the US mtdgule if it is mtguioted it
will iott remt e).
# gumtguiot /S<mtguiot ptiiot> (tt guiomtguiot the US if it is mtguioted).
# im /Setc/Smtdprtbe.d/Sbltcklist.ctiof (it will tpeio the bltcklist.ctiof fle theio pgut
aio eiotry tf US ).
bltcklist gusb_sttraie (afer type this sa e aiod exit this fle).
22. What is " wait " and where it is stored?
(i). If there is iott eiotguih memtry tt rguio the prtcess theio it will wait ftr free space iio memtry.
That prtcess is called wait.
(ii). wait is sttred iio bgufeer like cache memtry.
23. What is run level?
(i). Rguio le el is iotthiioi bgut tt pgut the system iio difeereiot le els tt perftrm difeereiot
maiioteioaioce mtdes.
(ii). There are 7 rguio le els. Thtse are 0 1 2 3 4 5 aiod 6.
(iii). The abt e le els are gused tt pgut the system iio difeereiot staies tt a ail difeereiot ser ices.
24. What is the default run level?
(i). Wheio we bttt the ser er the system aguttmatcally it tt tioe partcgular rguio le el. That rguio
le el is called the defagult rguio le el.
(ii). Iio Liiogux the defagult rguio le el is 5 iio GUI aiod 3 iio CLI.
(iii). We caio mtdify the defagult rguio le el by pgut aio eiotry iio /etc/initab fle.
25. Which run level are you using?
Rguio le el 3.
26. How to change the run level temporarily?

Ratnakar Page 70
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# iioit <rguio le el iot.> (tt chaioie the rguio le el temptrarily).


Example : # iioit 0 tr iioit 1 tr iioit 2 tr iioit 3 tr iioit 4 tr iioit 5 tr iioit 6
27. Can I mount on two disks alternatively when booting?
Nt it is iott ptssible tt mtguiot tio twt disks alterioat ely wheio btttioi becaguse we caio specify
tioly tioe disk as bttt disk bgut iott twt disks as btttioi disks iio IOS setiois.
St it is iott ptssible tt mtguiot tio twt disks alterioat ely wheio btttioi.

7. Job Automation

1. What is Job scheduling?


The prtcess tf creatioi the jtbs aiod make them tccgur tio the system repeatedly htgurly daily
weekly mtiothly aiod yearly is called Jtb schedguliioi. Iio Liiogux aiod tther Uioix systems this
prtcess is haiodled by the cron ser ice tr deamtio called crondaiod atd is the at jtbs deamtio
which caio be gused tt schedgule the tasks (alst called as jtbs)..
2. What is the importance of the job scheduling?
The imptrtaioce tf the jtb schedguliioi is that the critcal tasks like backgups which the clieiot
gusgually waiots tt be takeio iio ioiihts caio easily perftrmed withtgut the iioter eiottio tf the
admiioistrattr by schedguliioi a crtio jtb. If the crtio jtb is schedguled carefgully theio the backgup
will be takeio at aioy ii eio tme tf the clieiot aiod there will be iot ioeed ftr the admiioistrattr tt
remaiio back at ioiihts tt take the backgup.
3. What are the diferences between cron and at jobs?
cron job :
(i). crtio jtbs are schedguliioi jtbs aguttmatcally at a partcgular tme day tf the week week tf
the mtioth aiod mtioth tf the year.
(ii). The jtb may be a fle tr fle system.

Ratnakar Page 71
[Pick the date] [LINUX NOTES FOR LEVEL 2]

(iii).We caioiott iet the iioftrmattio as a lti fle if the jtb was failed tt execgute ie. wheio it was
failed aiod where is was failed aiod alst caioiott execgute aguttmatcally the failed jtbs.
at job :
(i). at jtbs are execgutes tioly tioce.
(ii). Here alst we caioiott iet the iioftrmattio if the jtb is failed aiod it is alst dt iott execgute the
failed jtbs aguttmatcally.
4. What are the important files related to cron and at jobs?
 /etc/crontab -----> is the fle which sttres all the schedguled jtbs.
 /etc/cron.deny -----> is the fle gused tt restrict the gusers frtm gusiioi crtio jtbs.
 /etc/cron.allow -----> is gused tt alltw tioly gusers whtse ioames are meiottioed iio this fle
tt guse crtio jtbs aiod
this fle dtes iott exist by defagult.
 /etc/at.deny ----->same as crtio.deioy ftr restrictioi the gusers tt guse at jtbs.
 /etc/at.allow -----> same as crtio.alltw ftr alltwiioi gusers tt guse at jtbs.
5. What is the format of the cron job?
# crtiotab -e (tt edit the crtio jtb edittr tt create tr remt e the
crtio jtbs).
<miiogutes><htgurs><day tf the mtioth><mtioth tf the year><day tf the week><jtb tr script>
(0 - 59). (0 - 23). (1 - 31). (1 - 12 tr jaio feb ...). (0 - 6 tr sguio mtio ...).

Options Explanation
* Is treated as a wild card. MBeaioiioi aioy ptssible algue.
Is treated as e er 5 miiogutes htgurs days tr mtioths. Replaciioi he 5 with aioy iogumerical algue
*/S 5
will chaioie this tpttio.
2 4 6 Treated as aio OR st if placed iio the htgurs this ctguld meaio at 2 4 tr 6 t-cltck
Treats ftr aioy algue betweeio 9 aiod 17. St if placed iio day tf the mtioth this wtguld be days
9-17
9 thrtguih 17 tr if pgut iio htgurs it wtguld be betweeio 9 AMB aiod 5 PMB.

6. How to check the assigned cron jobs of currently login user?


# crtiotab -l -gu <guser ioame> (tt check the specifed guser's assiiioed crtio
jtbs).
# crtiotab -l -gu rajgu (tt check the rajgu guser's assiiioed crtio jtbs).
# crtiotab -l (tt check the rttt guser's assiiioed crtio
jtbs).
7. How to allow or deny cron jobs for a user?
For allow For deny
(i). Opeio /etc/cron.allow fle. (i). Opeio /etc/cron.deny fle.

(ii). Pgut the eiotries tf the guser ioames whtm dt we (ii). Pgut the eiotries tf the guser ioames whtm dt we
waiot tt alltw the crtio jtbs. waiot tt deioy the crtio jtbs.

8. What is at job and atq source?


(i). at jtbs are execgutes tioly tioce.

Ratnakar Page 72
[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). atq meaios htw maioy at jtbs are iio qguegue by # atq ctmmaiod.
9. How to check the jobs?
# at -l (tt check the at jtbs).
10. How to add crontab entry in command mode?
(i). # defioe edittr= im (tt defioe the edittr as im).
(ii). # exptrt $edittr (exptrt the defioed edittr).
(iii).# crtiotab -e (tt edit the crtiotab).
11. How to troubleshoot if the cron job failed?
(i). See the crtiotab eiotries ftr syiotactcal errtrs. If there are aioy errtrs theio ctrrect them
ttherwise it will iott execgute.
(ii). Check whether the crond deamtio is wtrkiioi tr iott. If it is rguioioiioi theio sttp the deamtio
aiod aiaiio start the deamtio. E eio thtguih the prtblem tccgurs theio the crtiotab eiotries
may be wrtioi.
(iii).If all the abt e are tk theio see whether the guser wht execgutioi crtio jtb has permissitios
tt execgute the crtio jtbs tr iott ie. check the guser eiotries iio /etc/cron.allow aiod
/etc/cron.deny fles.
(i ). If all are tk aiaiio pgut the jtb eiotry iio crtiotab aiod execgute it.
12. How to schedule the cron task or job?
(i). Opeio tioe shell script fle.
(ii). Eioter all the ctmmaiods which are reqguired tt ctmplete the task tr jtb.
(iii).If the jtb reqguires mtre CPU aiod mtre memtry theio schedgule thtse jtbs at ioiiht tme tr
iotio-peak htgurs (ieioerally ioiiht tme is the iotio-peak tme)..
(i ). Theio tpeio crtiotab edittr by # crontab -e <user name> ctmmaiod aiod theio pgut the
eiotries as beltw
<miiogutes><htgurs><day tf the mtioth><mtioth tf the year><day tf the week><script ioame
with path>
( ). Sa e aiod exit frtm the crtiotab edittr.
13. How to add at job and delete the at job?
Adding :
(i). # at <tme> (tt eioter the at jtb).
(ii). eftre that tpeio a fle im aiod eioter the jtb ctmmaiods iio that fle aiod sa e as xxxx.sh
(stme ioame with exteiositio mgust be as .sh).
(iii).Eioter the abt e sa ed fle ioame withiio the at jtb edittr.
(i ). Press Ctrl + d tt exit frtm the edittr.
( ). Theio system will assiiio a jtb id tt that jtb. We caio see the list tf at jtbs by # atq
ctmmaiod.
Delete :
(i). See the jtb id which jtb we waiot tt delete by # atq ctmmaiod aiod iotte that jtb id.
(ii). Theio delete that jtb by # at -r <job id> ctmmaiod.
14. How to know currently scheduled at jobs?

Ratnakar Page 73
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# atq (tt see the cgurreiotly schedguled at jtbs).


15. How to allow or deny at jobs for a user?
For allow For deny
(i). Opeio /etc/at.allow fle. (i). Opeio /etc/at.deny fle.

(ii). Pgut the eiotries tf the guser ioames whtm dt we (ii). Pgut the eiotries tf the guser ioames whtm dt we
waiot tt alltw the at jtbs. waiot tt deioy the at jtbs.

16. Where is the location of the crontab and at jobs?


/S ar/Sspttl/Scrtio -----> is the crtiotab fle ltcattio.
/S ar/Sspttl/Sat -----> is the at jtbs fle ltcattio.
17. Where is the location of the crontab and at jobs log files?
/S ar/Slti/Scrtio -----> is the lti fle ltcattio ftr btth crtio aiod at jtbs.
Other useful commands :
# ser ice atd restart (tt restart the atd deamtio iio RHEL - 6).
# chkctiofi atd tio (tt eioable the atd deamtio at ioext bttt iio
RHEL - 6).
# ser ice atd statgus (tt see the statgus tf the atd deamtio iio RHEL
- 6).
# ser ice atd sttp (tt sttp the atd deamtio iio RHEL - 6).
# ser ice atd start (tt start the atd deamtio iio RHEL - 6).
# ser ice crtiod restart (tt restart the crtiod deamtio iio RHEL - 6).
# chkctiofi crtiod tio (tt eioable the crtiod deamtio at ioext bttt iio
RHEL - 6).
# ser ice crtiod statgus (tt see the statgus tf the crtiod deamtio iio
RHEL - 6).
# ser ice crtiod sttp (tt sttp the crtiod deamtio iio RHEL - 6).
# ser ice crtiod start (tt start the crtiod deamtio iio RHEL - 6).
# systemctl restart atd (tt restart the atd deamtio iio RHEL - 7).
# systemctl eioable atd (tt eioable the atd deamtio at ioext bttt iio
RHEL - 7).
# systemctl statgus atd (tt see the statgus tf the atd deamtio iio RHEL
- 7).
# systemctl sttp atd (tt sttp the atd deamtio iio RHEL - 7).
# systemctl start atd (tt start the atd deamtio iio RHEL - 7).
# systemctl restart crtiod (tt restart the crtiod deamtio iio RHEL - 7).
# systemctl eioable crtiod (tt eioable the crtiod deamtio at ioext bttt iio
RHEL - 7).
# systemctl statgus crtiod (tt see the statgus tf the crtiod deamtio iio
RHEL - 7).
# systemctl sttp crtiod (tt sttp the crtiod deamtio iio RHEL - 7).

Ratnakar Page 74
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# systemctl start crtiod (tt start the crtio deamtio iio RHEL - 7).
# at -l (tt see the list tf at jtbs).
# atq (tt see the jtbs iio the qguegue).
# atrm <jtb id> (tt remt e the specifed at jtb).
# at <tme> (tt set the at jtb tt be execguted at the
specifed tme).
# at 9:30 (tt set the at jtb tt be execguted at 9:30
AMB).
Example : # at 9:30
at> guseradd itpal
at> irtgupadd maioaier
at> rm -rf /Stpt
at> tar -c f /Srttt/Setc.tar /Setc/S*
press Ctrl + d tt sa e aiod exit frtm at jtb
# at -r <jtb id> (tt remt e the specifed jtb).
* at jtbs caio be perftrmed tioly tioe tme. It caioiott repeat daily.
* at jtbs tioce schedguled we caioiott edit the jtbs tr mtdify the tme tf the jtb.
# at iotw +5miio (tt execgute the at jtb iotw afer 5 miiogutes).
at> ttguch f1 f2 f3
at> mkdir /Sram
at><EOT> tr Ctrl + d (tt sa e aiod exit frtm at jtb edittr).
# tailf /S ar/Slti/Scrtio (tt see the last 10 liioes tf at tr crtio lti fle
ctioteiots).
# at Jaio 20 2015 (tt schedgule the at jtb tio 20th Jaio 2015).
# at 5PMB Jaio 13 2015 (tt schedgule the at jtb tio 13th Jaio 2015 at
5PMB).
# at iottio + 4days (tt schedgule the at jtb ttday aiod afer 4
days).
# at midioiiht (tt schedgule the at jtb ttday midioiiht).
# at midioiiht + 4days (tt schedgule the at jtb ttday midioiiht aiod
afer 4 days).
# im /Setc/Sat.deioy (tt deioy the at jtbs ftr specifed gusers).
# im /Setc/Sat.alltw (tt alltw the at jtbs ftr specifed gusers).
* If btth /etc/at.deny aiod /etc/at.allow fles are deleted except rttt guser e ery guser will
be deioy tt
execgute at jtbs.
* Oioce schedguled the crtio jtbs we caio mtdify edit that jtb aioy iot. tf tmes.
# cat /Setc/Scrtiotab (tt see the crtio jtbs list).
# crtiotab -lgu <guser ioame> (tt list all the crtio jtbs tf the specifed guser).
# crtiotab -egu <guser ioame> (tt create tr edit the crtio jtbs).

Ratnakar Page 75
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# crtiotab -rgu <guser ioame> (tt erase tr remt e the specifed guser's
crtio jtbs).
# crtiotab -r <jtb id> (tt remt e the specifed crtio jtbs).
# im /Setc/Scrtio.deioy (tt deioy the crtio jtbs ftr specifed gusers).
# im /Setc/Scrtio.alltw (tt alltw the crtio jtbs ftr specifed gusers).
* If btth fles are remt e tr deleted except rttt guser all the gusers are deioy tt execgute the
crtiojtbs.
# crtiotab -egu rajgu
55 14 20 1 2 /Sgusr/Ssbiio/Sguseradd itpal gusr/Ssbiio/Sirtgupadd team
(sa e & exit this crtiotab).
* This jtb execgutes the guseradd aiod irtgupadd ctmmaiods tio Tguesday 20th Jaio e ery year
Examples for crontab :
(i). 58 14 15 20-25 1 236 /Sgusr/Ssbiio/Spasswd
where 58 -----> 58 miiogutes
14 15 -----> 14 htgurs aiod 15 htgurs ( 14:58 aiod 15:58).
20-25 -----> dates 20 21 22. 23 24 aiod 25
1 -----> Jaioguary
2 3 6 -----> 2iod day 3rd day aiod 6th day
(ii). 58 15 * * * <ctmmaiod>
where 58 -----> 58 miiogutes
15 -----> 15 htgurs (at 15:58).
* * * -----> e ery day

(iii).58 */S2 * * * <ctmmaiods>


where 58 -----> 58 miiogutes
*/S2 -----> E ery 2 htgurs
* * * -----> e ery day
(i ). 00 */S2 * * * syioc echt "---" > /Ssys/Sclass/Sscsi_htsts/Shtst2/Sscaio
( ). @rebttt <mail ctmmaiod> (e ery rebttt tioe mail will be seiod tt the rttt).
( i).@mtiothly <ctmmaiod> (e ery mtioth the ctmmaiod will be execguted).
( ii). @yearly <ctmmaiod> (e ery year the specifed ctmmaiod will be
execguted).
( iii). @rebttt /Sgusr/Ssbiio/S tr /Sbiio/Ssh /Srttt/Sctss.sh (e ery rebttt the specifed script
fle will be
execguted).
* If the system is schedguled ftr a jtb bgut at that tme the system is guioder dtwio theio anacron
ctmmaiod is
resptiosible ftr thtse peiodiioi jtbs tt be execguted.
# cat /etc/anacron is the ctiofigurattio fle ftr aioacrtio jtbs.
# aioacrtio (aioacrtio is gused tt execgute the peiodiioi crtio jtbs).

Ratnakar Page 76
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# im /Setc/Src.ltcal (tt execgute the crtio peiodiioi jtbs aguttmatcally wheioe er the
system is rebttted).
* Opeio the abt e fle aiod it tt last liioe aiod type as anacron theio sa e aiod exit this fle tt
execgute the peiodiioi jtbs aguttmatcally wheioe er the system is rebttted.

8. Administrating Remote Systems (SSH)

1. What is remote administration and explain it?


(i). Remtte admiioistrattio meaios admiioistrattio tf ser ers which are ltcated iio remttely.
(ii). Ntrmally ser ers are placed iio dataceioters like bttks arraioied iio a rack.
(iii).These dataceioters are iotrmally ltcated iio US UK aiod Agustralia ... etc.
(i ). Geioerally we ltiiio as iotrmal guser iio ltcal systems aiod iet the remtte deskttp tr ctiostle
gusiioi remtte deskttp tttls like pgutty VNC ser er ... etc.
( ). If it is thrtguih remtte deskttp we caio maioaie the ser ers gusiioi the GUI tttls.

Ratnakar Page 77
[Pick the date] [LINUX NOTES FOR LEVEL 2]

( i). If it is thrtguih pgutty we caio maioaie the ser es gusiioi ctmmaiod liioe iioterface tioly. Iio btth
ways we shtguld ii e ser er ioame tr IP address ptrt iot. guser ioame aiod passwtrd.
2. What is SSH and explain it?
SSH is staiods ftr Secgure Shell. It was desiiioed aiod created tt prt ide the best secgurity wheio
accessiioi aiotther ctmpguter remttely. Ntt tioly dtes it eiocrypt the sessitio it alst prt ides
better agutheiotcattio facilites.
Oio wiiodtws systems iiostall the pgutty stfware aiod thrtguih pgutty we caio access the remtte
system by ctiofiguriioi ssh.
SSh is prtttctl which facilitates secgured ctmmguioicattio betweeio twt systems gusiioi Clieiot-
Ser er architectgure aiod alltws gusers tt ltiiio tt the ser er htst systems remttely.
It is gused tt ctioioect tt remtte system aiod perftrm admiioistrat e task tr jtbs. y defagult ssh
takes passwtrd agutheiotcattio mechaioism aiod its ptrt iot. is 22. Thrtguih ssh the data will be
traiosferred iio eiocrypted ftrmat.
3. What is telnet?
Telioet is a mechaioism tt ctioioect aiod tt admiioistrate the remtte system frtm ltcal system.
This is the tldest prtiram which is a ailable tio mtst ioetwtrk capable tperatioi systems.
Accessiioi a remtte shell acctguiot thrtguih the telioet methtd is daioier becaguse iio that
e erythiioi that ytgu seiod tr recei e t er that telioet sessitio is isible iio plaiio text tio ytgur ltcal
ioetwtrk aiod the ltcal ioetwtrk tf the machiioe ytgu are ctioioectioi tt.
St aioytioe caio sioife the ctioioecttio iio-betweeio caio see tgur guser ioame passwtrd email aiod
tther messaies that we read aiod ctmmaiod that we rguio. Ftr these reastios we ioeed a mtre
stphistcated prtiram thaio telioet tt ctioioect tt a remtte htst.
4. What are the diferences between Telnet and SSH?
Telnet SSH
(a). Thrtguih telioet we caio ctioioect the remtte (a). Thrtguih ssh alst we caio ctioioect the remtte
system bgut aioy ioetwtrk hacker may see the system bgut iotbtdy caio see the traiosferred data.
traiosferred data. Aiod the telioet ptrt iot. is 23. Aiod the ssh ptrt iot. is 22.
(b). Data will be traiosferred iio iotio-eiocrypted ftrmat. (b). Data will be traiosferred iio eiocrypted ftrmat.

(c). We caioiott trgust this telioet ctioioecttio. (c). We caio trgust this ssh ctioioecttio.

(d). We caioiott ii e the trgustioi iio telioet. (d). We caio ii e the trgustioi iio ssh.

(e). y siottpiioi tr sioifioi techiotltiies we caio see (e). y siottpiioi tr sioifioi techiotltiies we caioiott
the data like system tr htstioame ltiiio ioame see the data like system ioame tr htstioame ltiiio
passwtrd aiod tther data. ioame passwtrd aiod tther data.
St there is iot secgurity. St there is a secgurity
(f). # telioet<IP address tf the remtte system> (f). # ssh<IP address tf the remtte system>
(prt ide ltiiio ioame aiod passwtrd). (prt ide ltiiio ioame aiod passwtrd).

5. In how many ways we can connect the remote host through ssh?
Thrtguih ssh we caio ctioioect the remtte htst by twt methtds.

Ratnakar Page 78
[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i). Ctmmaiod Liioe Iioterface (CLI)..


Example : # ssh <IP address tf the remtte system> (prt ide ltiiio ioame aiod passwtrd).
(ii). Graphical User Iioterface (GUI)..
Example : tpeio VNS ser er wiiodtw aiod prt ide remtte htstioame ltiiio ioame aiod
passwtrd.
6. What are the requirements for ssh?
(i). Remtte systems IP address.
(ii). Remtte systems guser ioame aiod passwtrd
(iii). A prtper ioetwtrk ie. tgur ltcal aiod remtte systems shtguld be iio the same ioetwtrk.
(i ). Opeio ssh packaie tt ctiofigure the ssh.
7. In how many ways we can connect the remote system?
(i). telioet (ii). ssh
(iii). rltiiio (i ). rcp
( ). fp ( i). scp
( ii). sfp ( iii). ttp
8. What is the syntax for ssh?
# ssh <IP address tf the remtte system> -l <guser ioame>
# ssh <guser ioame>@<IP address tf the remtte system>
# ssh <guser ioame>@<remtte htstioame with fgully qgualifed dtmaiio ioame>
* Afer execgutioi aioy tf the abt e ctmmaiods it may asks guser ioame aiod passwtrd. Theio type
guser ioame aiod
passwtrds tt ctioioect the remtte systems.
9. How to configure the ssh with keybased authentication or explain the ssh trusting?
(i). SSH keybased agutheiotcattio is gused tt access the remtte system withtgut askiioi aioy
passwtrds.
(ii). Ftr that frst we ha e tt ieioerate the pgublic aiod pri ate keys by execgutioi # ssh-keygen
ctmmaiod tio tgur system. Theio the pgublic aiod pri ate keys are ieioerated iio /home/<user
name>/.ssh ltcattio. ie. .ssh directtry iio gusers htme directtry. Aiod the keys are id_rsa
(pri ate key). aiod id_rsa.pub (pgublic key)..
(iii). Theio ctpy the pgublic key id_rsa.pub tio the remtte system by execgutioi the beltw
ctmmaiod.
# ssh-copy-id -i <user name>@<IP address of the remote system>
(i ). Gt tt remtte system aiod check whether the abt e key is ctpied tr iott by # cat
/home/<user name>/.ssh/authorized_keys fle. Aiod the pri ate key shtguld be iio tgur
system.
( ). Wheioe er we are tryiioi tt establish a ctioioecttio the pgublic key tio remtte system shtguld
be matched with the pri ate key tio tgur system. ttherwise there is iot ctioioecttio is
established.

Ratnakar Page 79
[Pick the date] [LINUX NOTES FOR LEVEL 2]

( i). If btth pgublic aiod pri ate keys are matched theio ctioioecttio will be established aiod frst
tme it will ask the passwtrd. Oioce the ctioioecttio is established ioext tme tiowards it wtio't
ask aioy passwtrds.
# ssh <user name>@<remote hostname or IP address> (frst tme it will asks
the passwtrd).
( ii). The agutheiotcattio is dtioe thrtguih the pgublic aiod pri ate keys st this type tf
agutheiotcattio is called keybased agutheiotcattio.
10. How to prevent the remote login root user or how to configure the ssh to prevent the
remote login for root?
(i). The ltcattio tf the ssh ctiofigurattio fle is /etc/ssh/sshd_config
(ii). Opeio the ctiofigurattio fle by # vim /etc/ssh/sshd_config
-----> it tt liioe iot. 42 (iio RHEL - 6). tr
-----> it tt liioe iot. 48 (iio RHEL - 7). PermitRootLogin yes
aiod guioctmmeiot that liioe aiod type as " no " iio place tf " yes " aiodsa e aiod exit this fle.
(iii). Theio restart the tr reltad the sshd deamtio by
# service sshd restart (tt restart the sshd deamtio tr ser ice iio
RHEL - 6).
# systemctl restart sshd (tt restart the sshd deamtio tr ser ice iio
RHEL - 7).
# chkconfig sshd on (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 6).
# systemctl enable sshd (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 7).
# service sshd reload (tt reltad the sshd deamtio iio RHEL - 6).
# systemctl reload sshd (tt reltad the sshd deamtio iio RHEL - 7).
(i ). Theio iot rttt guser caioiott access tgur system remttely thrtguih ssh ser ice.
11. How to allow the remote users to run GUI commands through ssh?
(i). Opeio ssh ctiofigurattio fle by # vim /etc/ssh/sshd_config
-----> it tt liioe iot. 109 iio RHEL - 6 tr
-----> it tt liioe iot. 117 iio RHEL - 7 X11 Forwarding no
type as " yes " iio place tf " no " theio sa e aiod exit this fle.
* If it is yes theio GUI ctmmaiods caio be execguted tio the remtte system.
* If it is iot theio GUI ctmmaiods caioiott be execguted tio the remtte system.
(ii). Theio restart the sshd ser ice tr deamtio tt efeect the abt e mtdifcattio by
# service sshd restart (tt restart the sshd deamtio tr ser ice iio
RHEL - 6).
# systemctl restart sshd (tt restart the sshd deamtio tr ser ice iio
RHEL - 7).
# chkconfig sshd on (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 6).

Ratnakar Page 80
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# systemctl enable sshd (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 7).
# service sshd reload (tt reltad the sshd deamtio iio RHEL - 6).
# systemctl reload sshd (tt reltad the sshd deamtio iio RHEL - 7).
(iii). # iedit (tt tpeio the iedit edittr tio remttely).
12. How to allow empty password through ssh?
(i). Opeio the ssh ctiofigurattio fle by # vim /etc/ssh/sshd_config
-----> it tt liioe iot. 65 iio RHEL - 6 tr
-----> it tt liioe iot. 77 iio RHEL - 7 PermitEmptyPassword no
type as " yes " iio place tf " no " theio sa e aiod exit this fle.
* If it is yes theio the remtte system will be alltw the gusers with empty passwtrd ie.
withtgut passwtrd.
* If it is iot theio the remtte system will iott be alltw the gusers with empty passwtrds.
(ii). Theio restart the sshd ser ice tr deamtio tt efeect the abt e mtdifcattios by
# service sshd restart (tt restart the sshd deamtio tr ser ice iio
RHEL - 6).
# systemctl restart sshd (tt restart the sshd deamtio tr ser ice iio
RHEL - 7).
# chkconfig sshd on (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 6).
# systemctl enable sshd (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 7).
# service sshd reload (tt reltad the sshd deamtio iio RHEL - 6).
# systemctl reload sshd (tt reltad the sshd deamtio iio RHEL - 7).
(iii). Ntw the gusers wht are ha iioi empty passwtrds are alst access the remtte systems
thrtguih ssh.
13. How to prevent the password authentication mechanism in ssh?
(i). Opeio the ssh ctiofigurattio fle by # vim /etc/ssh/sshd_config
-----> it tt liioe iot. 66 iio RHEL - 6 tr
-----> it tt liioe iot. 78 iio RHEL - 7 PasswordAuthentication no
type as " no " iio place tf " yes " theio sa e aiod exit this fle.
* If it is yes theio the remtte system will ask the passwtrd.
* If it is iot theio the remtte system will iott ask aioy type tf passwtrds.
(ii). Theio restart the sshd ser ice tr deamtio tt efeect the abt e mtdifcattios by
# service sshd restart (tt restart the sshd deamtio tr ser ice iio
RHEL - 6).
# systemctl restart sshd (tt restart the sshd deamtio tr ser ice iio
RHEL - 7).
# chkconfig sshd on (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 6).

Ratnakar Page 81
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# systemctl enable sshd (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 7).
# service sshd reload (tt reltad the sshd deamtio iio RHEL - 6).
# systemctl reload sshd (tt reltad the sshd deamtio iio RHEL - 7).
(iii). Ntw we caio access the remtte systems thrtguih ssh withtgut Passwtrd Agutheiotcattio
mechaioism.
14. How to allow or deny the uses or group to access the remote systems through ssh?
(i). If we waiot tt alltw tr deioy the partcgular gusers theio it tt last liioe tf the ssh ctiofigurattio
fle aiod type as
DeioyUsers <guser 1><guser 2><guser3> ...etc. (these gusers will be deioied the ssh ser ice).
AlltwUsers <stgudeiot><guser 4><guser 5> ...etc. (these gusers will be alltwed the ssh
ser ice).
DeioyGrtgup <irtgup 1><irtgup 2><irtgup 3> ...etc. (these irtgup gusers will be deioied the
ssh ser ice).
AlltwGrtgup <irtgup 1><irtgup 2><irtgup 3> ...etc. (these irtgup gusers will be alltwed the
ssh ser ice).
(ii). Theio restart the sshd ser ice tr deamtio tt efeect the abt e mtdifcattios by
# service sshd restart (tt restart the sshd deamtio tr ser ice iio
RHEL - 6).
# systemctl restart sshd (tt restart the sshd deamtio tr ser ice iio
RHEL - 7).
# chkconfig sshd on (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 6).
# systemctl enable sshd (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 7).
# service sshd reload (tt reltad the sshd deamtio iio RHEL - 6).
# systemctl reload sshd (tt reltad the sshd deamtio iio RHEL - 7).
15. How allow the specified no. of users to access remote system at a time?
(i). Opeio the ssh ctiofigurattio fle by # vim /etc/ssh/sshd_config theio it tt MaxAuthTries
liioe aiod type as
MaxAuthTries <no.> (type aioy iogumeric algue eqgual tt MBax. gusers tt alltwat a tme iio
place tf <iot.>
theio sa e aiod exit this fle).
(ii). Theio restart the sshd ser ice tr deamtio tt efeect the abt e mtdifcattios by
# service sshd restart (tt restart the sshd deamtio tr ser ice iio
RHEL - 6).
# systemctl restart sshd (tt restart the sshd deamtio tr ser ice iio
RHEL - 7).
# chkconfig sshd on (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 6).

Ratnakar Page 82
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# systemctl enable sshd (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 7).
# service sshd reload (tt reltad the sshd deamtio iio RHEL - 6).
# systemctl reload sshd (tt reltad the sshd deamtio iio RHEL - 7).
16. How to allow or deny the hosts or networks to use the ssh?
To deny IP addresses or hostnames :
(i). Opeio /etc/hosts.denyfle by # vim /etc/hosts.deny aiod it tt last liioe aiod type as
sshd: <IP address 1><IP address 2><IP address 3> ...etc. (tt deioy IP 1 IP 2 IP 3 ...etc. ).
sshd: <hostname 1><hostname 2><hostname 3> ...etc.
sshd: *.example.com *.my133t.org ...etc. (tt deioy all the htsts frtm these dtmaiios).
sshd: 192.168.0. 172.25.0. ...etc. (tt deioy 192.168.0 aiod 172.25.0 ioetwtrks).
sshd: ALL Except <hostname or IP address> (tt deioy all the htsts tr IP addresses
except the specifed tioe iio
that ioetwtrk). aiod sa e & exit the fle.
(ii). Theio restart the sshd ser ice tr deamtio tt efeect the abt e mtdifcattios by
# service sshd restart (tt restart the sshd deamtio tr ser ice iio
RHEL - 6).
# systemctl restart sshd (tt restart the sshd deamtio tr ser ice iio
RHEL - 7).
# chkconfig sshd on (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 6).
# systemctl enable sshd (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 7).
# service sshd reload (tt reltad the sshd deamtio iio RHEL - 6).
# systemctl reload sshd (tt reltad the sshd deamtio iio RHEL - 7).
To allow IP addresses or hostnames :
(i). Opeio /etc/hosts.allow fle by # vim /etc/hosts.allow aiod it tt last liioe aiod type as
sshd: <IP address 1><IP address 2><IP address 3> ...etc. (tt alltw IP 1 IP 2 IP 3 ...etc. ).
sshd: <hostname 1><hostname 2><hostname 3> ...etc.
sshd: *.example.com *.my133t.org ...etc. (tt alltw all the htsts frtm these dtmaiios).
sshd: 192.168.0. 172.25.0. ...etc. (tt alltw 192.168.0 aiod 172.25.0
ioetwtrks).
sshd: ALL Except <hostname or IP address> (tt alltw all the htsts tr IP addresses
except the specifed tioe iio
that ioetwtrk). aiod sa e & exit the fle.
(ii). Theio restart the sshd ser ice tr deamtio tt efeect the abt e mtdifcattios by
# service sshd restart (tt restart the sshd deamtio tr ser ice iio
RHEL - 6).
# systemctl restart sshd (tt restart the sshd deamtio tr ser ice iio
RHEL - 7).

Ratnakar Page 83
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# chkconfig sshd on (tt eioable the sshd deamtio at ioext rebttt


iio RHEL - 6).
# systemctl enable sshd (tt eioable the sshd deamtio at ioext rebttt
iio RHEL - 7).
# service sshd reload (tt reltad the sshd deamtio iio RHEL - 6).
# systemctl reload sshd (tt reltad the sshd deamtio iio RHEL - 7).
17. How to check whether the ssh is running or not on remote host?
# iomap -p 22 <IP address tf the remtte htst> (tt see the ssh is rguioioiioi tr iott tio remtte
system).
18. How to troubleshoot if the client has complain that I am not accessing the server using ssh?
(i). First check the piioiiioi tf the clieiot system. If it is iott piioiiioi theio check the IP address tf
the clieiot system. If clieiot system aiod se er system are iio difeereiot dtmaiios tr ioetwtrks it will
iott piioi. St briioi the clieiot system iiott the ioetwtrk tf the ser er system. Check the
ioetwtrk is wtrkiioi tr iott aiod alst check whether the ioetwtrk cable is ctioioected tr iott.
(ii). If btth systems are piioiiioi theio check whether the openssh packaie is iiostalled tr iott. If
iott iiostalled theio iiostall that packaie aiod ctiofigure ssh tio the clieiot system aiod restart
the sshd deamtio.
(iii). Check the clieiot <IP address tr htstioame> iio /etc/hosts.deny fles. If there is aio eiotry
tf the clieiot system iio this fle theio remt e that eiotry aiod restart the sshd deamtio.
(i ). Fiioally tpeio the ssh ctiofigurattio fle by # vim /etc/ssh/sshd_config aiod see aioy clieiot
guser ioame is preseiot tr iott aiod check tther liioes ftr clieiot eiotries iio this fle if preseiot
remt e thtse eiotries sa e that fle aiod restart the sshd ser ice.
( ). Fiioally check whether the clieiot guser is there iio the ser er tr iott if iott create the clieiot
guser assiiio the passwtrd share thtse details tt clieiot. If guser is there theio check whether
the clieiot guser's passwtrd is ltcked acctguiot expired aiod aioy tther tr iott if ltcked theio
remt e the ltck if clieiot acctguiot is expired theio act ate that acctguiot assiiio the passwtrd
aiod make the ssh trgustioi betweeio clieiot aiod ser er systems.
19. How to copy the file from our system to remote system?
# scp <stgurce fle ioame with fgull path><IP address tf the remtte system>:<destioattio
ltcattio>
Example : ssh /Srttt/Sscript1 192.168.1.1:/Srttt/Sscript1 (tt ctpy /Srttt/Sscript1 fle iiott
192.168.1.1 system).
ssh -r /Srttt/Srajgu/S 192.168.1.1:/Srttt/Srajgu/S (tt ctpy /Srttt/Srajgu directtry tt remtte
system).
* scp meaios secgured ctpy tt ctpy the fles tr directtries frtm ltcal system tt remtte
system.

20. What is rsync and explain it?


rsync is a ery ittd prtiram ftr backiioi gup tr mirrtriioi a directtry tree tf fles frtm tioe
machiioe tt aiotther machiioe aiod ftr keepiioi the twt machiioes " in sync ". It is desiiioed tt

Ratnakar Page 84
[Pick the date] [LINUX NOTES FOR LEVEL 2]

speedgup fle traiosfer by ctpiioi the difeereioces betweeio twt fles rather thaio ctpiioi aio eiotre
fle e ery tme.
If rsync is ctmbiioed with ssh it makes a ireat gutlity tt syioc the data secgurely ttherwise by
sioifioi aioy tioe caio see tgur data ie. iot secgurity ftr tgur data.
21. A system is able to ping locally but not out site. Why?
(i). MBay be there is iot access tt tgutside.
(ii). MBay be tgutside is iio difeereiot ioetwtrk frtm the ltcal.
(iii). MBay be permissitio is deioied ftr that system tt access tgutside.
(i ). If there is access bgut rtguter tr mtdem tr ioetwtrk switch tr NIC may iott be wtrkiioi tt
access the tgutside.
( ). MBay be tgutside is iott a ailable temptrarily.
22. A system is echoing the ping, but not able to login via telnet. Why?
(i). Check telioet ser ice is started tr iott. If iott started start the telioet ser ice.
(ii). MBay be telioet ser ice is disabled if st eioable the telioet ser ice.
(iii). MBay be telioet ptrt is bltcked if st release that ptrt iot.
(i ). MBay be telioet permissitio is deioied if st chaioie the permissitios tt alltw the telioet ser ice.
( ). Check all the fles whether the telioet ser ice is bltcked tr iott if bltcked remt e thtse
eiotries.
23. How will you login or start the system in what mode if you don't know the root password?
(i). If the guser ha iioi sgudt permissitios theio ltiiio as sgudt guser.
(ii). If iot sgudt permissitios theio bttt with CDROMB iio siioile guser mtde aiod start the system.
Theio prt ide the rttt passwtrd tt rttt guser if there is iot rttt passwtrd.
(iii). E eio thtguih if it is iott ptssible theio fioally break the rttt passwtrd.
Other useful commands :
# telioet <IP address tr htstioame> (tt ctioioect the specifed remtte system
thrtguih telioet).
# ssh <IP address tr htstioame> (tt ctioioect the specifed remtte system
thrtguih ssh).
Userioame : xxxxxx
Passwtrd : xxxxxxx
# ssh <IP address> -l <guser ioame> (tt ctioioect the remtte system gusiioi guser
ioame).
Passwtrd : xxxxxxx
# ssh 192.168.1.1 -l rttt (tt ctioioect this remtte system as rttt guser).
# ssh rttt@192.168.1.1 (tt ctioioect this remtte system as rttt guser).
# ssh rttt@ser er1.example.ctm (tt ctioioect the ser er1 system iio
example.ctm dtmaiio).
#w (tt see all the gusers wht are ltiiio tt tgur
system).

Ratnakar Page 85
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# w -f (tt see all the gusers wht are ltiiio tt tgur system
with tther details).
# ssh <IP address> (if we iott specifed the guser ioame theio it will ask the cgurreiot gusers
passwtrd aiod search the
cgurreiot acctguiot iio remtte system).
# cat /Srttt/S.ssh/Skiotwio_htsts (tt see the ssh trgustioi remtte htsts fioier
priiot iioftrmattio).
# ssh rttt@192.168.1.1 <ctmmaiod> (tt rguio a ctmmaiod tio remtte htst withtgut ltiiio
tt that system).
# ssh rttt@192.168.1.1 -X (tt rguio GUI ctmmaiods tio the remtte system becaguse by
defagult the ssh is ctiofigured as
ctmmaiod liioe iioterface X is capital).
# lastb (tt see the ltiiio failed tries).
# last -x |irep shgutdtwio (tt see the date & tme tf the system's last
shgutdtwio).
9. Memory Management (Swap)

1. What is swap?
Swap space iio Liiogux is gused wheio the amtguiot tf the Physical memtry (RAMB). is fgull. If the
system ioeeds mtre memtry restgurces aiod the RAMB is fgull iioact e paies iio the memtry are
mt ed frtm RAMB tt swap space. It helps the machiioes which are ha iioi small amtguiot RAMB
aiod it shtguld iott be ctiosidered a replacemeiot ftr mtre RAMB. Swap is ltcated tio the hard disks
which ha e sltwer access tme thaio Physical memtry.
2. What is the recommended swap space?
Geioerally the rectmmeioded swap space is dtguble the RAMB sise bgut the ftlltwiioi table shtws
actgual amtguiot.
Apart frtm the beltw rectmmeiodattio a basic rgule is applied tt create the swap partttio.
* If the RAMB sise is less than or equal to 2 GB theio the sise tf the swap = 2 X RAM size.
* If the RAMB sise is more than 2 GB theio the sise tf the swap = 2 GB + RAM size.
Recommended Amount of Swap
Amount of RAM in the System
Space
4 G tr less MBiio. 2 G
4 G - 16 G MBiio. 4 G
16 G - 64 G MBiio. 8 G
64 G - 256 G MBiio. 16 G
256 G - 512 G MBiio. 32 G

3. Is it necessary to create the swap at the time of installation?


Yes swap space is ctmpgulstry tt be created at the tme tf iiostallattio. gut addittioal swap
space caio be created aiod deleted at aioy ptiiot tf tme wheio it is reqguired. Stmetmes we ioeed

Ratnakar Page 86
[Pick the date] [LINUX NOTES FOR LEVEL 2]

tt iiocrease the swap space st we create addittioal swap space which will be added tt the
existioi swap space tt iiocrease the sise.
4. What is swap-in and swap-out or page-in and page-out?
swap-in tr page-out :
If we rguio tr tpeio aioy applicattio it reqguires stme amtguiot tf memtry tt ltad its featgures. St
frst it lttks tr tccgupy physical memtry (RAMB).. If there is iott eiotguih space iio RAMB the
applicattio's data is traiosferred frtm RAMB tt swap space. If the paies are mt iioi frtm RAMB
tt swap space that is called swap-iio tr paie-tgut.
swap-out tr page-in :
If tlder tr pre itgus applicattio is cltsed theio the space tccgupied by thtse applicattios alst
cleared. ie. stme tf the space is a ailable iio RAMB. St aguttmatcally stme data which is already
tccgupied iio swap space is alst mt ed frtm swap tt RAMB. If the paies are mt iioi frtm swap
space tt RAMB that is called swap-tgut tr paie-iio.
5. How paging space is allocated?
(i). Paiiioi meaios data traiosferred frtm RAMB tt swap space.
(ii). If we tpeio tr rguio aioy applicattio frst it will tccgupy the reqguired space iio RAMB. If there is
iott eiotguih space iio RAMB theio stme amtguiot tf applicattio's data will be traiosferred frtm
RAMB tt swap space. ie. swap space is alltcated tt that applicattio. This alltcattio is
called paiiioi space tr paie-tgut alltcattio.
(iii). paiiioi will takes place iio swap by bltcks. First it will create the reqguired iot. tf bltcks iio
swap space.
(i ). If RAMB space cleared by tlder tr tther applicattios theio swap tccgupied data is traiosferred
frtm swap tt RAMB. This is called paie-iio. St that mguch amtguiot tf space is guioalltcated iio
swap ie. remt ed the created bltcks iio swap.
6. How to create the swap partition?
# fdisk -l (tt see the a ailable disks iio the system).
# fdisk /Sde /Ssdb
Ctmmaiod (m ftr help). : io (tt create a ioew partttio).
First cyliioder : (press Eioter key).
Last cyliioder : +2048MB
Ctmmaiod (m tr help). : t (tt chaioie the hex ctde).
Partttio iot. (1-2). : 2 (tt chaioie the partttio iogumber hex ctde).
Hex ctde : 82 (82 is the hex ctde ftr Liiogux swap).
Ctmmaiod (m ftr help). : w (write the chaioies tt the disk).
# partprtbe tr # partprtbe /Sde /Ssdb (tt gupdate the partttio table iioftrmattio).
# mkswap /Sde /Ssdb2 (tt ctio ert the raw disk tt swap fle system).
# swaptio /Sde /Ssdb2 (tt tgurio tio the swap partttio).
# im /Setc/Sfstab (tt make the permaioeiot mtguiot tf swap partttio).
/Sde /Ssdb2 swap swap defagults 0 0
(sa e aiod exit this fle).

Ratnakar Page 87
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# mtguiot -a (tt mtguiot all the partttios which are ha iioi eiotries iio
/Setc/Sfstab fle).
# df -hT (will iott shtw the swap sise).
# free -m (tt see the tttal RAMB aiod swap sise).
7. How to remove the swap partition?
# swaptio -s (tt see the swap partttio ioames tr disks).
# swaptfe /Sde /Ssdb2 (tt tgurio tfe the swap space).
# im /Setc/Sfstab (tpeio this fle aiod remt e the swap partttio eiotry).
(afer remt iioi the swap partttio sa e aiod exit this fle).
# fdisk /Sde /Ssdb (tt delete the swap partttio).
Ctmmaiod (m ftr help). : d (d ftr tt delete the partttio).
Partttio iot. (1-2). : 2
Ctmmaiod (m ftr help). : w (tt write the chaioies iiott the disk).
# partprtbe tr # partprtbe /Sde /Ssdb
# free -m (tt see the RAMB as well as swap sises).
8. In how many ways can we create the swap spaces?
(i). y creatioi a ioew swap partttio tio the disk. (separate swap partttio).
(ii). y creatioi swap fle.
9. How to create the swap space using the swap file?
Stmetmes it is guioable tt create a swap partttio becaguse may be there is iot disk space tr may
be the partttio limit is already exceeded. St iio these sceioarits we ha e tt create tioly the
space fle.
# dd if = /Sde /Ssert tf = /Srttt/Sliioguxswap bs = 1MB ctguiot = 2048 (tt create 2048MB
empty fle).
# dgu - /Srttt/Sliioguxswap (tt see the liioguxswap sise).
# mkswap /Srttt/Sliioguxswap (tt ctio ert the existioi fle system tt swap fle
system).
# swaptio /Srttt/Sliioguxswap (tt tgurio tio the swap fle).
# im /Setc/Sfstab (tt make a permaioeiot mtguiot tf swap space).
/Srttt/Sliioguxswap swap swap defagults 0 0
(sa e aiod exit this fle).
# mtguiot -a (tt mtguiot all the partttios which are ha iioi eiotries iio
/Setc/Sfstab fle).
# df -hT (will iott shtw the swap sise).
# free -m (tt see the tttal RAMB aiod swap sise).
10. What is virtual memory?
The ctmbiioattio tf Physical memtry (RAMB). aiod swap space is called the irtgual memtry.
St Virtgual memtry = Physical memtry (RAMB). + swap space.
Other useful commands :

Ratnakar Page 88
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# swap -s (tt see htw maioy swap partttios are there aiod with their
ioames).
# swaptio -a (tt tgurio tio all the swap partttios).
# swaptfe -a (tt tgurio tfe all the swap partttios).
# cat /Setc/Smtab (tt see the cgurreiot aiod temptrary mtguiot ptiiots).
# mtguiotptiiot <directtry tr mtguiot ptiiot> (tt check the specifed directtry is a iotrmal
directtry tr a
mtguiot ptiiot).
# df -ih (tt check htw maioy iiotde iogumbers are a ailable iio the mtguioted
partttios).
11. What happens when the /usr is full?
(i). Users caioiott ltiiio tt the system.
(ii). If already ltiiio gusers iott able tt execgute aioy ctmmaiod.
12. What happens when memory ie., pagein space is full?
(i). The ioew applicattios caioiott ltad dgue tt lack tf memtry.
(ii). St gusers caioiott ltiiio tt the applicattio aiod caioiott access the applicattios featgures.
(iii).St if we iiocrease the swap memtry tt the reqguired sise theio the prtblem will be stl ed.
13. How to restore the data and upgrade your O/S ?
(i). We caio resttre the data frtm backgup by tar cpit dd ioet backgup tr tther tttls.
(ii). If it is iio mirrtr we caio syioc the data frtm mirrtred disk.
(iii).We caio gupirade the O/SS iio twt ways.
(a). Online :
The O/SS is gupiraded frtm pre itgus tt preseiot while the system is rguioioiioi. It is risky aiod
takes ltioi tme.
(b). Offline :
First take backgup tf all the system aiod theio remt e pre itgus O/SS aiod iiostall the
preseiot O/SS aiod resttre the backgup frtm backgup disks tr tapes. St it is ery
easy aiod iotio-risky jtb.

Ratnakar Page 89
[Pick the date] [LINUX NOTES FOR LEVEL 2]

10. Software Management

1. What is sofware?
Stfware is a ctllecttio tf prtirams tt perftrm stme tasks tr maioaie systems applicattios
databases ...etc.
2. What is package and package management?
Packaie is iotthiioi bgut a stfware tt perftrm stme tasks. Stfware is the basic tf aioy O/SS
alltwiioi tt iiostall aiod guse difeereiot gutlites.
Packaie maioaiemeiot meaios iiostalliioi gupdatioi qgueryiioi repairiioi aiod remt iioi packaies.
Iio Liiogux there are twt tttls tt perftrm packaie maioaiemeiot.
rpm -----> redhat packaie maioaier aiod ygum -----> yelltwdti gupdater mtdifer.
3. What is rpm?
rpm is a packaie maioaiiioi system (ctllecttio tf tttls tt maioaie stfware packaies).. rpm is a
ptwerfgul aiod mtst ptpgular tpeio stgurce tttl gused ftr stfware maioaiemeiot ftr iiostalliioi
guioiiostalliioi (remt iioi). erifyiioi qgueryiioi aiod gupdatioi stfware packaies. It is iiostalled guioder
/var/lib/rpm database directtry. It deals with .rpm fles which ctiotaiios the actgual
iioftrmattio abtgut the packaies. The rpm lti messaies will be sttred iio /var/log/yum.log fle.
4. What are the draw backs of rpm?
(i). rpm caioiott restl e the depeiodeiocy. It meaios if we waiot tt iiostall aioy stfware frst the
depeiodeiocy packaies shtguld be iiostalled.
(ii). There is iot ctiofigurattio fle ftr rpm.
5. What are the basic modes of rpm commands?
(i). Iiostall -----> gused tt iiostall rpm packaies.
(ii). Update -----> gused tt gupdated the packaies.
(iii). Trtgubleshtttioi -----> gused tt repair the packaies.
(i ). Remt e -----> gused tt remt e tr guioiiostall the packaies.
( ). Qgueryiioi -----> gused tt qguery (iather iioftrmattio). tio packaies.
6. How many types of packages are available in Linux?
(i). x86_64.rpm -----> 64 bit packaie aiod caio be iiostall tio 64 bit O/SS tioly.
(ii). x86.rpm -----> 32 bit packaie aiod caio be iiostall tio 32 bit tr 64 bit O/SS tioly.
(iii). i 386.rpm -----> 32 bit packaie aiod caio be iiostall tio 32 bit tr 64 bit O/SS tioly.
(i ). i 486.rpm -----> " "
( ). i 586.rpm -----> " "
( i). i 686.rpm -----> 64 bit packaie aiod caio be iiostall tio 64 bit O/SS tioly.
( ii). iotarch.rpm -----> iot-architectgure aiod caio be iiostall tio either 32 bit tr 64 bit O/SS.
7. What is the syntax of rpm command with full options?

Ratnakar Page 90
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# rpm <tpttios><packaie ioame>


The tpttios are -i -----> iiostall
- -----> erbtse
-h -----> prtiress iio hash ctdes ( iio % ).
-qi -----> qguery iioftrmattio abtgut the packaie
-ql -----> list all packaie related fles.
-qd ----> qguery abtgut the dtcgumeiot tf the packaie
-qc -----> displays the ctiofigurattio fles ftr that packaie
-qa -----> qguery tio all iiostalled packaies
-V -----> (capital V). tt erify the packaie ftr repair that packaie
-R -----> list all depeiodeiot packaies
--ftrce -----> iiostall the packaie ftrcefgully
--iotdeps -----> iiostall the packaie withtgut depeiodeiocy (dt iott check the
depeiodeiocies).
--last -----> all iiostalled packaies with date aiod tme
Other useful rpm commands :
# rpm -i h<packaie ioame> (tt iiostall the packaie).
# rpm -qa (tt list all iiostalled packaies).
# rpm -qa <packaie ioame> (tt check whether the packaie is iiostalled
tr iott).
# rpm -qa |wc -l (tt ctguiot htw maioy packaies already
iiostalled).
# rpm -qa --last | less (tt check last iiostalled packaies).
# rpmqguery -qa (tt list all the iiostalled packaies).
# rpm -qa |irep -i <packaie ioame> (tt check the specifed packaie is iiostalled
tr iott).
# rpm -i h --test <packaie ioame> (tt check the packaie ctiosisteiocy).
* If the iiostallattio statgus shtws 100% theio the packaie is iio ittd ctiodittio tr ctiosisteiot. gut
while shtwiioi
the hash prtiress if it shtws aioy errtr theio the packaie is iio iioctiosisteiot state.
# rpm -i h fioier* (tt iiostall the fioier packaie).
# rpm -qa fioier (tt check whether the packaie is iiostalled
tr iott).
# fioier <guser ioame> (tt check whether the iiostalled packaie is
wtrkiioi tr iott).
# rpm -e <packaie ioame> (tt erase tr remt e tr guioiiostall the
packaie).
# rpm -e <packaie ioame> (tt remt e the packaie iio erbtse mtde).

Ratnakar Page 91
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# rpm --test -i h (tt test the packaie beftre iiostalliioi ie.


whether the
packaie is sguitable tr iott).
# rpm -qi <packaie ioame> (tt see the details tr iioftrmattio tio the
iiostalled packaie).
# rpm -ql <packaie ioame> (tt list all packaie related fles).
# rpm -qlc <packaie ioame> (tt list all the ctiofigurattio fles tf that
packaie).
# rpm -qd <packaie ioame> (tt list all the dtcgumeiot fles tf that
packaie).
# rpm -i h <packaie ioame> --ftrce (tt iiostall the packaie ftrcefgully).
# rpm -qR <packaie ioame> (tt list the depeiodeiocies tf that packaie).
# rpm -qip <packaie fgull ioame> (tt display the packaie iioftrmattio beftre
iiostallattio).
# which <ctmmaiod ioame> (tt display the ltcattio tf that ctmmaiod).
# rpm -qf <ltcattio tf the ctmmaiod> (tt check the packaie ioame ftr that
ctmmaiod).
# rpm -V <packaie ioame> (tt erify that packaie ie. 100% packaie is
there tr iott if aioy fles missed iio that
packaie thtse are displayed as a list).
# rpm -i h <packaie ioame> --replacepkis (tt replace the missed fles iio that packaie).
# rpm -qp --chaioielti <packaie ioame> (displays all the chaioied ltis like lat tme
wheio the packaie
is iiostalled .....etc. ).
# rpm -qp --scripts <packaie ioame> (tt see the packaie iiostallattio scripts).
# rpm -K <packaie fgull ioame> (tt see the packaie key).
# rpm -U h <packaie ioame> (tt gupdate the packaie).
* Update is t er write the tld ersitio tf the packaie. If aioy prtblems iio ioew packaie we
caioiott stl e thtse issgues. St the better tioe is iiostall that packaie as a fresh tioe (iott gupdate
tpttio)..
* Update will lttk frst the packaie is a ailable iio that system tr iott. If it is a ailable it will
gupdate that packaie ttherwise it will iiostall as fresh packaie.
# rpm -qRp <packaie ioame> (tt check the depeiodeiocy packaies tf that packaie
beftre iiostall).
# rpm -i h <packaie ioame> --iotdeps (tt iiostall the packaie withtgut depeiodeiot
packaies).
8. What is yum and explain the yum?
ygum staiods ftr yelltw dti gupdater mtdifed. ygum is a packaie maioaiemeiot applicattio ftr
ctmpguters rguioioiioi tio Liiogux O/SS.ygum is a staiodard methtd tf maioaiiioi the iiostallattio aiod
remt al tf stfware. It is frtm RHEL - 5 tiowards. Packaies are dtwioltaded frtm ctllecttios

Ratnakar Page 92
[Pick the date] [LINUX NOTES FOR LEVEL 2]

called reptsittries which may be tioliioe tio a ioetwtrk aiod tr tio iiostallattio media. ygum is a
frtiot eiod tttl ftr rpm. It is gused tt restl e the depeiodeiocy which caioiott be dtioe by rpm. The
ygum ctmmaiod has access the reptsittry where the packaies are a ailable aiod caio iiostall
gupdate/Sgupirade remt e aiod qguery the packaies aguttmatcally.
9. What are the important files that are related to yum?
/etc/yum.conf -----> is the ygum ctiofigurattio fle.
/etc/yum.repos.d -----> is the directtry which ctiotaiios the ygum reptsittry ctiofigurattio fle.
/etc/yum.repos.d/xxxxx.repo ------> is the ygum reptsittry ctiofigurattio fle.
/var/lib/yum -----> is the directtry which ctiotaiios the ygum databases.
/var/log/yum.log -----> is the fle which sttres the ygum lti messaies.
10. How setup the yum server?
(i). Iiosert the RHEL DVD ittt that directtry aiod iiostall the sfpd packaie by # rpm -ivh
vsfpd*
(ii). Gttt /var/fp/pub directtry aiod create rhel6 directtry by # mkdir rhel6
(iii). Gttt DVD mtguioted directtry aiod ctpy all the DVD ctioteiot iiott /var/fp/pub/rhel
directtry by
# cp -rvpf /media/DVD/ /var/fp/pub/rhel6
(i ). Restart the sfpd ser ice by # service vsfpd restart ctmmaiod.
( ). Theio eioable the sfpd ser ice by # chkconfig vsfpd on ctmmaiod.
( i). Gttt /etc/yum.repos.d directtry aiod create tioe ygum reptsittry fle by # vim linux.repo
ctmmaiod.
( ii). Iio the abt e fle the ctioteiots are as beltw
[liiogux] (Liiogux rept id).
ioame=ygum rept ser er (ygum ser er ioame).
basegurl=fle:/S/S/S ar/Sfp/Spgub/Srhel6 tr basegurl=fp:/S/S<IP address tf the
system>/Spgub/Srhel6
ipicheck=0 (0 meaios while iiostalliioi it will iott ask aioy
siiioatgure keys tf ygum packaies If it is 1 theio it will ask the siiioatgure
keys while iiostalliioi the packaies).
+98gu eioabled=1 (if mgultple reptsittries are there
theio eioable this tioly).
(sa e aiod exit this fle).
( iii). # yum clean all (tt cleaio the tld tioe gupdate the ioew
reptsittry).
(ix).# yum repolist (it displays iot. tf packaies iio that
reptsittry).
11. How to setup the yum client?
(i). Gttt /etc/yum.repos.d directtry aiod create the reptsittry fle by # vim linux.repo
(ii). Type the eiotries as beltw
[liiogux] (Liiogux rept id).

Ratnakar Page 93
[Pick the date] [LINUX NOTES FOR LEVEL 2]

ioame=ygum rept clieiot (ygum rept clieiot).


basegurl=fp tr http:/S/S<IP address tf the ser er>/Spgub/Srhel6
ipicheck=0 (0 meaios while iiostalliioi it will iott ask aioy
siiioatgure keys tf ygum packaies If it is 1 theio it will ask the siiioatgure
keys while iiostalliioi the packaies).
eioabled=1 (if mgultple reptsittries are there theio eioable this tioly).
(sa e aiod exit).
(iii). # yum clean all (tt cleaio the tld tioe gupdate the ioew reptsittry).
(i ).# yum repolist (it displays iot. tf packaies iio that
reptsittry).
12. How to configure the yum repository to deny some packages to be installed?
(i). Tt ctiofigure the ygum tttl the ygum ctiofigurattio fle is /etc/yum.conf
(ii). Tt deioy stme packaies tpeio the ygum ctiofigurattio fle by # vim /etc/yum.conf
ctmmaiod.
(iii). Gtttlast liioe aiod type as exclude=*(all) kernel* fp* theio sa e aiod exit this fle.
(i ). Theio kernel* aiod fp* packaies will be deioied wheio we tryiioi tt iiostall thtse packaies.
13. How to change the yum repository default location?
(i). Opeio ygum ctiofigurattio fle by # vim /etc/yum.conf ctmmaiod.
(ii). Gttt last liioe aiod type as repository=<yum repository new location with full path> theio
sa e aiod exit this fle.
(iii). Theio the ygum reptsittry ioew ltcattio will be chaioied frtm tld tioe ioew tioe.
14. How to change the yum log file default location?
(i). Opeio the ygum ctiofigurattio fle by # vim /etc/yum.conf ctmmaiod.
(ii). Gttt last liioe aiod type as log=<yum log file new location with full path> theio sa e aiod
exit this fle.
(iii). Theio the defagult lti ltcattio is chaioied frtm /var/log/yum.log fle tt ioew ltcattio.
15. How to configure the yum to restrict the architecture (64 bit or 32 bit) etc.,?
(i). Opeio the ygum ctiofigurattio fle by # vim /etc/yum.conf ctmmaiod.
(ii). Gttt last liioe aiod type as exactarch=1 theio sa e aiod exit this fle.
(iii). 1 meaios frst it iiostalls 64 bit packaies aiod if it is 0 theio 32 bit packaies will be iiostalled.
(i ).Opeio the ygum ctiofigurattio fle by # vim /etc/yum.conf ctmmaiod.
( ). Gttt last liioe aiod type as cachedir=<download new location> theio sa e aiod exit this
fle.
( i). Theio wheioe er we iiostall the packaies the dtwioltaded ltcattio will be the ioew ltcattio.
( ii). Opeio the ygum ctiofigurattio fle by # vim /etc/yum.conf ctmmaiod.
( iii). Gttt last liioe aiod type as assumeyes=1 theio sa e aiod exit this fle.
(ix). Wheioe er we iiostall aioy packaie gusiioi ygum theio iot ioeed tt meiottio -y tpttio if
assumeyes=1 aiod if assumeyes=0 theio we ha e tt meiottio -y tpttio wheio we iiostall
the packaie.

Ratnakar Page 94
[Pick the date] [LINUX NOTES FOR LEVEL 2]

16. What is O/S patch and how to add those patches on production servers or how to upgrade
the kernel?
(i). O/SS patch is iotthiioi bgut gupdate the ioew kerioel. Ntrmally O/SS patch is stfware that
ctiotaiios stme prtirams tt fx the bguis iio O/SS ie. iio kerioel.
(ii). If tgur ser er is reiistered aiod ctiofigured iio RedHat ioetwtrk theio we will iet the
iioftrmattio abtgut that gupdated kerioel s iioftrmattio aiod theio dtwioltad that kerioel
gupdattios.
(iii). E ery O/SS patch is sgupplied with a dtcgumeiot abtgut pre-reqguisites tt apply that patch.
(i ). Check the pre-reqguisites space reqguiremeiots aiod tthers. if all are tk
( ). Theio we take the bgusiioess apprt al aiod make CRQ's (Chaioie reqguests)..
( i). Theio the prtject maioaier will iioitate the mail thread ie. seiodiioi the mail tr messaies tt
aritgus teams wht are dealiioi with that ser er.
( ii). We iet the resptiose frtm difeereiot teams which are iio tl iioi iio this prtcess.
(a). Ftr example MBtioittriioi team tt iiiotre alerts frtm that ser er if the system haiois tr
rebttted.
(b). D A team if database sttpped tr crashed tr system failed.
(c). Applicattio team if the applicattio efeects while patchiioi.
( iii). If the ser er is iio clguster theio mt e the ser ice irtgup aiod restgurces tt aiotther systems
maiogually called switch t er.
(ix). Iioftrm the Applicattio team tt sttp the applicattio aiod database team tt sttp the
database.
(x). If the ser er is iio clguster there is iot ioeed tf rebttt (iot dtwio tme). else dtwio tme ioeeded
tt rebttt.
(xi). Check the rttt disk is iio iotrmal fle system tr VxVMB.
(xii). If mirrtr disk is there split the mirrtr disk frtm triiiioal disk aiod bttt iio siioile guser mtde
aiod add the patch by # rpm -ivh <patch name> ctmmaiod.
(xiii). Theio rebttt the system aiod wtio't attach the mirrtr disk tt a tid aioy guioexpected
sitguattios tr prtblems aiod pgut that ser er guioder test guptt 1week tr 10 days depeiodiioi
tio the ctmpaioy's ptlicy.
(xi ). Afer the test peritd if there is iot prtblems raised theio attach the system iio li e mtde aiod
alst with mirrtr disk tt syioc the data tt gupdate the system.
(x ). Theio we iioftrm the Applicattio Database MBtioittriioi aiod tther teams wht are dealiioi
with that ser er tt test applicattio database mtioittriioi aiod tthers see the statgus.
(x i). Theio fioally cltse the issgue tr CRQ.
17. Afer installation of package or patch if the package or patch is removed then what will
happened?
(i). If kerioel patch is remt ed theio the system will haioi aiod ftr tthers there is iot efeect.
(ii). If packaie is remt ed theio the applicattio that beltiois tt that remt ed packaie will efeect.
18. Afer applying the patch need to reboot the system or not?
(i). If the patch is kerioel patch tr clgustered patch theio tioly the system rebttt is reqguired.

Ratnakar Page 95
[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). If the patch is iotrmal patch theio there is iot ioeed tf the rebttt reqguired.
19. If the package is not installing. How to troubleshoot?
(i). Check the packaie pre-reqguisites tt iiostall the packaie.
(ii). If pre-reqguisites are iott matched with tgur system theio the packaie will iott be iiostalled i.e.
O/SS ctmpatbility tt iiostall that packaie.
(iii). If there is iot sgufcieiot space iio the system the packaie will iott be iiostalled.
(i ). If the packaie is iott prtperly dtwioltaded theio the packaie will iott be iiostalled.
20. If the patch is not applied successfully what will you do?
(i). Check whether the patch is iiostalled prtperly tr iott by # rpm -qa <patch name>
ctmmaiod.
(ii). Check the /var/log/yum.log fle tt erify tr see why the patch is iott sguccessfgully iiostalled.
(iii). If aioy ptssible tt restl ed thtse issgues restl e aiod remt e that patch with # rpm -e
<patch name> ctmmaiod.
(i ). If aioy rebttts reqguired tt efeect theio rebttt the system.
( ). Aiaiio add that patch by # rpm -ivh <patch name> ctmmaiod.
( i). Theio check the patch by # rpm -qa <patch name> ctmmaiod
Other useful yum commands :
# ygum reptiioft (tt list all the iioftrmattio tio all the
reptsittries).
# aygum reptiioft <rept id> (tt list all the iioftrmattio tio specifed
reptsittry).
# ygum iiostall <packaie ioame> -y (tt dtwioltad aiod iiostall the packaie aiod y
meaios yes).
# ygum iiostall <packaie ioame> -d (tt dtwioltad the packaie).
# ygum erase tr remt e <packaie ioame> -y (tt remt e tr guioiiostall the packaie aiod y
meaios yes).
# ygum list iiostalled (tt display the list tf all iiostalled packaies).
# ygum list a ailable (tt list all the a ailable packaies tt be
iiostalled).
# ygum list all | less (tt list all the iiostalled aiod iott iiostalled
packaies).
# ygum search <packaie ioame> (tt search a partcgular packaie is a ailable
tr iott).
# ygum iioft <packaie ioame> (tt display the iioftrmattio tio that packaie).
# ygum gupdate <packaie ioame> (if the gupdate ersitio tf the specifed
packaie is a ailable
theio gupdate that packaie).
# ygum gupdate all (tt gupdate all the packaies iotthiioi bgut whtle system
will be gupdated).

Ratnakar Page 96
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# ygum dtwioirade <packaie ioame>(tt re ert back ie. it back tt pre itgus ersitio tf that
packaie if ioew
ersitio is iott wtrkiioi prtperly).
# ygum histtry (tt display the ygum histtry).
# ygum histtry iioft < id > (tt display the iioftrmattio tf that histtry
id).
# ygum histtry guiodt < id > (tt remt e that histtry id).
# ygum histtry guiodt < id > (tt redt the abt e remt ed histtry id).
# ygum irtguplist (tt display the list tf irtgup packaies).
# ygum irtgupiiostall <packaie ioame> (tt iiostall the irtgup packaie).
# ygum iiostall@<irtgup packaie ioame> (tt iiostall the irtgup packaie iio aiotther
way).
# ygum irtgupiioft <irtgup packaie ioame> (tt display the irtgup packaie iioftrmattio).
# ygum irtguplist hiddeio (tt list all the irtgup packaies ioames
iioclgudiioi iiostalled tr iott
iiostalled aiod hiddeio irtgup packaies).
# ygum-ctiofi-maioaier disablerept=<rept id> (tt disable the ygum reptsittry. St we
caioiott iiostall aioy

packaie frtm the reptsittry).


# ygum cleaio all (tt clear the histtry if we disable the reptsittry id theio we ha e tt cleaio
the histtry theio tioly
it will disable the reptsittry).
# ygumdtwioltader <packaie ioame> (tt dtwioltad the packaie frtm the
reptsittry aiod the
dtwioltaded ltcattio is the preseiot wtrkiioi directtry).
# maio ygum.ctiof (tt see the maiogual paies tio ygum
ctiofigurattio fle).
# ygum-ctiofi-maioaier --add-rept=http:/S/Sctioteiot.example.ctm/Srhel7.0/Sx86_64/Sd d
(theio the ygum reptsittry will be created aguttmatcally with .rept
fle alst. Aiod this wtrks tioly iio RHEL - 7).
# sgubscripttio-maioaier reiister --guserioame=<guser ioame> --passwtrd=<passwtrd> (tt
reiister tgur prtdguct with RHN--Redhat Netwtrk. The guser ioame aiod passwtrds will be
prt ided by the Redhat wheio we pgurchase the stfware).
# sgubscripttio-maioaier guioreiister --guserioame=<guser ioame> --passwtrd=<passwtrd> (tt
guioreiister tgur prtdguct with RHN--Redhat Netwtrk. The guser ioame aiod passwtrds will be
prt ided by the Redhat wheio we pgurchase the stfware).

Ratnakar Page 97
[Pick the date] [LINUX NOTES FOR LEVEL 2]

11. Backup and Restore

1. What is backup and what is purpose of the backup?


Ctpyiioi fles frtm ltcal disk tt aioy remt able media is called backgup.
Iio iioftrmattio techiotltiy a backup tr the prtcess tf backing up is makiioi ctpies tf data
which may be gused tt resttre the triiiioal afer aio e eiot tf data ltss. ackgup has twt distioct
pgurptses.
The primary pgurptse is tt rect er data afer its ltss dgue tt delettio tr ctrrgupttio. Data ltss is
ery ctmmtio iio IT iiodgustry.
The sectiod pgurptse tf backgup is tt rect er data frtm aio earlier tme.
ackgup is the mtst imptrtaiot jtb tf a system admiioistrattr as a system admiio it is tgur dguty tt
take backgup tf the data e ery day. MBtst ctmpaioies ha e itioe tgut tf the market becaguse tf
pttr backgup plaioioiioi tr ptlicy.
2. What is recovery or restore?
Ctpyiioi fles frtm aioy remt able media tt ltcal disk is called rect ery tr resttre. ackgup will
be helped iio hardware failgure tr stfware failgure tr system crashed.
3. What are the backup tools available in the IT industry?
Platform Backup Tools
Wiiodtws iotbackgup
Liiogux tar cpit dd dgump resttre
3rd party Veritas ioetbackgup Amaioda aiod Ti tli
4. What is tar and Explain it or how to take a backup using tar?
Archi iioi meaios ctllecttio tf fles aiod directtries aiod tt make a siioile fle iotthiioi bgut
ctmpressitio. tar meaios tape archi iioi. It is aio archi e fle. y gusiioi tar ctmmaiod we caio take a
backgup tf fles aiod directtries. It caioiott sgupptrt fle systems backgup aiod alst iott sgupptrt ftr
larie fles mtre thaio 80G . tar will iott skip aioy siioile fle iioclgudiioi bad bltcks alst.
Full syntax of tar :

Ratnakar Page 98
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# tar <tpttios><destioattio fle ioame with path><stgurce fle tr directtry with path>
The tpttios are -c -----> create
- -----> erbtse
-f -----> fle ioame
-t -----> listioi
-t ----> ltioi listioi
-x -----> extract
-w ---->iioteract e
-C -----> specifc ltcattio (Capital C).
-gu -----> gupdate meaios addiioi ioew ctioteiots tt the existioi tar fle
--gupdate -----> " "
--delete -----> deletes the ctioteiots frtm the tar fle
-p ----> preser e the tld permissitios tf the fles/Sdirecttries wheio
extractioi the tar fle
-s ----> isip (iguio sip). ctmpressitio
-j ----> bsip2 (bguio sip). ctmpressitio
-J ----> xs ctmpressitio (frtm RHEL - 7).

Examples:
# tar -c f /Srttt/Setc.tar /Setc/S* (tt ctpy all the fles aiod directtries frtm /Setc aiod
make a siioile fle
aiod place iio the /Srttt/Setc.tar fle).
# tar -t f /Srttt/Setc/Star (tt ltioi listioi the ctioteiots tf the /Srttt/Setc.tar
fle).
# tar -x f /Srttt/Setc.tar -C /Srttt1/S (tt extract aiod ctpy the fles iio /Srttt1/S ltcattio).
# tar -xf /Srttt/Setc.tar (tt list the ctioteiots tf the tar fle).
# tar -f /Srttt/Setc.tar --gupdate tr -gu <fle ioame tr directtry> (tt add the ioew
ctioteiots tt the existioi
tar fle).
# tar -f /Srttt/Setc.tar --delete<fle ioame tr directtry> (tt delete the fle frtm the
tar).
# tar -gu /Srttt/Setc.tar /S ar (tt add the /S ar ctioteiots iiott the /Srttt/Setc.tar
fle).
# tar -c f mytar.tar /S --xattrs (tt archi e the ctioteiots altioi with SELiiogux aiod
ACL permissitios).
# dgu -h /Srttt/Setc.tar (tt see the sise tf the tar ctmpressed fle).
5. What are the compressing & uncompressing tools available for tar and explain them?
Compressing Tools Uncompressing Tools
# isip (.is). # iguiosip

Ratnakar Page 99
[Pick the date] [LINUX NOTES FOR LEVEL 2]

# bsip2 (.bs2). # bguiosip2


# xs (RHEL - 7). # guioxs
# isip <tar fle ioame> (tt ctmpress the sise tf the tar fle aiod the tgutpgut
fle is .tar.is).
# iguiosip < .is ctmpressed fle ioame> (tt guioctmpress the ctmpressed tar fle aiod the
tgutpgut is .tar tioly).
# bsip2 <tar fle ioame> (tt ctmpress the sise tf the tar fle aiod the tgutpgut is
.tar.bs2).
# bguiosip2 < .bs2 ctmpressed fle ioame> (tt guioctmpress the ctmpressed fle aiod the tgutpgut
is .tar tioly).
6. What is scp, rsyncand how to use it?
scp meaios secgure ctpy. ie. ssh + cp = scp which is gused tt ctpy the fles/Sdirecttries iiott
remtte system.
scp will ctpy fles/Sdirecttries iiott remtte system bliiodly ie. if the fle already exits it will t er
write that fle.
St scp will take mtre tme tt ctpy wheio ctmpared tt # rsyioc tttl.
# scp <fle ioame><guser ioame>@ <IP address tf the remtte system>:<ltcattio tt be ctpied>
# scp aioactioda* rttt@192.168.1.1:/Srttt (tt ctpy aioactioda fle iiott /Srttt tf the
remtte system).
# scp -r /Setc/S rttt@192.168.1.1:/Srajgu (tt ctpy /Setc/S directtry iiott /Srajgu tf
remtte system).
#scp -a /Srajgu rttt@192.168.1.1:/Srttt (tt ctpy /Srajgu iiott /Srttt tf the remtte
system).
# scp -r rttt@192.168.1.1 :/Setc /Shtme (tt ctpy /Setc tf the remtte system
iiott /Shtme tf the
ltcal system).
rsyioc is alst gused tt ctpy fles/Sdirecttries iiott remtte systems. rsyioc tttl will ctmpare the
ioew fles tr directtries aiod ctpy tioly the chaioied tr mtdifed ctioteiots tf the fles iiott remtte
system. St it takes less tme tt ctpy wheio ctmpared tt # scp tttl.
# rsyioc -a rttt@192.168.1.1:/Setc /Shtme (tt ctpy /Setc directtry chaioied ctioteiots
iiott /Shtme).
rsyioc tpttios are -a -----> all (ctpy the fle with all permissitios except SELiiogux aiod ACL
permissitios).
-aA -----> syiochrtioise ACL permissitios
-aAx ----> syiochrtioise ACL aiod SELiiogux permissitios alst.
7. What is cpio and how to take a backup and restore using cpio?
cpit meaios ctpy iiopgut aiod tgutpgut. It sgupptrts aioy sise tf the fle system. It skips the bad
bltcks alst.
Syntax of cpio with full options :

Ratnakar Page 100


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# ls <stgurce fle ioame> |cpit <tpttios>><destioattio fle ioame> (tt take a backgup tf the
stgurce directtry aiod sttred the
backgup iiott destioattio directtry).
The tpttios are -t -----> tt list the cpit ctioteiots
-i -----> tt resttre the cpit backgup
- -----> tt display tio the screeio ie. erbtse
-t -----> tt take a backgup
Examples :
# ls | cpit -t > /Stpt/Srttt.cpit (tt take a backgup tf rttt directtry aiod
sttred iio /Stpt ).
# cpit -i < /Stpt/Srttt.cpit (tt resttre the backgup).
# ls /Setc | cpit -t > /Stpt/Setc.cpit (tt take a backgup tf the /Setc directtry aiod
sttred iio /Stpt).
# cd /Setc (it tt that /Setc directtry).
# rm -rf * (tt remt e all the ctioteiots frtm /Setc).
# cpit -i < /Stpt/Setc.cpit (tt resttre the /Setc ctioteiots frtm the
cpit backgup).
8. What is dd and how to take a backup and restore using dd?
dd meaios disk tt disk backgup. Usiioi dd ctmmaiod we caio take a backgup tf the data frtm
tioe disk tt aiotther disk. It ctpies the data iio byte tt byte. It caio take a backgup tf the disk
iioclgudiioi bad bltcks.
# dd if = <disk 1> tf = <disk 2> (tt take a backgup frtm disk 1 aiod sttres iio
disk 2).
# dd if = /Sde /Ssert tf = /Srttt/Srajgu bs = 1MB ctguiot = 2048 (tt create aio empty fle with
2G sise).
# dd if = /Sde /Ssda tf = /Srttt/Smbr.bak bs = 1 ctguiot = 512 (tt take the backgup tf
/Sde /Ssda MBaster
ttt Rectrd).
# dd if = /Srttt/Smbr.bak tf = /Sde /Ssdb (tt resttre the MB R frtm backgup tt sectiod
disk /Sde /Ssdb).
# dd if = /Sde /Ssda1 tf = /Sde /Ssdb1 (tt take a backgup tf the eiotre /Sde /Ssda1
disk partttio).
# dd if = /Sde /Ssdb1 tf = /Sde /Ssda1 (tt resttre the /Sde /Ssda1 ctioteiots frtm
the abt e backgup).
# dd if = /Sde /Ssda tf = /Sde /Ssdb (tt take a backgup tf the eiotre /Sde /Ssda
disk iiott /Sde /Ssdb).
# dd if = /Sde /Scdrtm tf = /Srttt/Srhel6.ist (tt create a ISO imaie fle tf the CD/SDVD).
9. What is dump and how to take a backup and restore using dump and restore?
dgump is a ctmmaiod gused tt take a backgup tf fle systems tioly. We caioiott take a backgup tf
fles aiod directtries. We caioiott take a backgup tf disk tt disk backgup. It is iott rectmmeioded tt

Ratnakar Page 101


[Pick the date] [LINUX NOTES FOR LEVEL 2]

take a backgup tio mtguioted fle systems. St guiomtguiot the fle system aiod theio take a backgup is
rectmmeioded. y defagult dgump is iott a ailable iio the system. st frst iiostall the dump
packaie aiod theio execgute the dgump ctmmaiods.
# ygum iiostall dgump* -y (tt iiostall the dgump packaie).
The syntax for dump :
# dgump <tpttios><destioattio fle ioame><stgurce fle ioame>(tt take a backgup tf the fle
systems).
The tpttios are -0----->fgull backgup
-(1 - 9). -----> iiocremeiotal backgups
-gu -----> gupdate the /Setc/Sdgumpdates fle afer sguccessfgul dgump
- -----> erbtse
-f ----->make the backgup iio a fle
-e -----> exclgude iiotde iogumber while backiioi gup
# dgump -0gu f /Stpt/Sfgull.dgump /Sctss (tt take a fgull backgup tf the /Sctss fle system aiod
ctpied it iio /Stpt).
# dgump -1gu f /Stpt/Sfgull.dgump /Sctss (tt take a backgup mtdifed fles frtm the last fgull
backgup iotthiioi
bgut iiocremeiotal backgup).
# dgump -2gu f /Stpt/Sfgull.dgump /Sctss (tt take a backgup mtdifed fles frtm the last
iiocremeiotal le el -1
backgup).
The syntax for restore :
# resttre <tpttios><dgump backgup fle> (tt resttre the backgup ctioteiots if that data is ltst).
The tpttios are -f -----> gused tt specify the dgump tr backgup fle
-C -----> gused tt ctmpare the dgump fle with triiiioal fle
- -----> erbtse
-e -----> exclgude the iiotde iogumber
-i -----> resttre iio iioteract e mtde
The commands in interactive mode are,
resttre> ls -----> list the fles aiod directtries iio the backgup fle
resttre> add ----> add the fles frtm dgump fle tt cgurreiot wtrkiioi directtry
resttre> cd -----> chaioie the directtry
resttre> pwd ---> displays the preseiot wtrkiioi directtry
resttre> extract ----> extract the fles frtm the dgump fle
resttre> qguit ---> tt qguit frtm the iioteract e mtde
# resttre -t /Stpt/Sfgull.dgump (tt list the dgump fle ctioteiots).
# resttre -rf /Stpt/Sfgull.dgump (tt resttre the dgump fle ctioteiots).
10. How many types of backup available?
There are maiioly three types tf backgups a ailable.
(i). Fgull backgup (Eiotre fle system backgup).

Ratnakar Page 102


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). Iiocremeiotal backgup (backgup frtm the last fgull backgup tr iiocremeiotal backgup).
(iii). Cgumgulat e tr difeereiotal backgup (backgup frtm last fgull backgup tr cgumgulat e backgup).
11. What is the diference between incremental and diferential backup?
Incremental backup :
Takiioi a backgup frtm the last fgull backgup tr last iiocremeiotal backgup
Diferential backup :
Takiioi a backgup frtm last fgull backgup tr last cgumgulat e tr difeereiotal backgup
12. Which file will update when backing up with dump command?
/etc/dumpdates fle will be gupdated wheio backiioi gup with dgump ctmmaiod.
13. What are the dump devices?
(i). Tape dri es
(ii). Disks (ltcal disks).
(iii). Lguios (ioetwtrk disks).
14. What is snap shot?
(i). The ptiiot - iio - tme ctpy tf the fle system is called the sioap shtt.
(ii). It prt ides tioliioe backgup stlguttio tf the fle system.
(iii). We caio take a backgup while the fle system is mtguioted aiod it is iio mgult-guser mtde.
(i ). It tccgupied tioly as mguch disk space as the fle system ie. beiioi captgured.
( ). We caio alst create backgup delete qguery temptrary (read-tioly). sioap shtts gusiioi fssnap
ctmmaiod.
15. What are the diferences between tar and cpio commands?
(i). y tar we caio take backgup guptt 80G sise tf fle systems bgut gusiioi cpit there is iot limit.
(ii). Iio tar the backgup is iio archi e ftrmat ie. iio ctmpressed state bgut iio cpit there is iot
ctmpressitio.
(iii). Iio btth the types tioly the whtle backgup is ptssible.
16. How to take a backup on production servers?
(i). Ntrmally iio backgup eio irtiomeiot we ha e 3 ser ers.
(a). MBaster ser er (prtdgucttio ser ers -- 1 tr 2 iot's)..
(b). MBedia ser er (backgup ser er -- 1 tr 2 iot's)..
(c). Clieiot ser er (Ntrmal system).
(ii). ackgups caio be takeio iio types.
(a). Applicattio ackgup (Ntrmally applicattio gusers will take these types tf backgups).
(b). File system ackgup (O/SS backgup System Admiioistrattrs will take these types tf
backgups).
(c). Database ackgup (D A gusers will take these types tf backgups).
(iii). Ntrmally backgup is aguttmated thrtguih stme backgup tttls like Veritas Net backgup I MB
Ti tli aiod Aguttsys.
(i ). Usiioi crtio tttl alst we caio take backgup. gut crtio will iott iioftrm the failed backgup. The
tther tttls will iioftrm by seiodiioi messaies like why the backgup is failed wheio aiod where it
is failed ..etc.

Ratnakar Page 103


[Pick the date] [LINUX NOTES FOR LEVEL 2]

( ). Oio prtdgucttio ser ers the backgup will ftlltw the prtcedgure
(a). MBaster ser er deptrt frtm prtdgucttio.
(b). Imptrt the master ser er tio MBedia ser er.
(c). Theio MBaster ser er will jtiio with the MBedia ser er.
(d). Syioc the data with the MBaster ser er.
(e). Take a backgup frtm MBaster ser er aiod sttre the ctpy tio MBedia ser er.
(f). Split the MBaster ser er frtm MBedia ser er.
(i). Deptrt the MBaster ser er frtm MBedia ser er.
(h). Imptrt the MBaster ser er tio prtdgucttio.
(i). Jtiio the MBaster ser er with prtdgucttio.
17. What is your company's backup policy?
(i). y dgump ctmmaiod we caio take backgups tio disks tapes aiod takes fgull iiocremeiotal aiod
difeereiotal tr cgumgulat e backgups.
(ii). le el 0 -- Fgull backgup (mtiothly tioce).
le el 3 -- Perftrmed tio e ery MBtioday (Iiocremeiotal frtm last fgull tr last
iiocremeiotal backgup).
le el 4 -- Perftrmed tio e ery Tguesday (Iiocremeiotal frtm last le el 3 backgup).
le el 5 -- Perftrmed tio e ery Wedioesday (Iiocremeiotal frtm last le el 4 backgup).
le el 6 -- Perftrmed tio e ery Thgursday (Iiocremeiotal frtm last le el 5 backgup).
le el 7 -- Perftrmed tio e ery Friday (Iiocremeiotal frtm last le el 6 backgup).
le el 8 -- Perftrmed tio e ery Satgurday (Iiocremeiotal frtm last le el 7 backgup).
le el 2 -- Perftrmed tio e ery Sguioday (difeereiotal tr cgumgulat e backgup frtm
last fgull backgup
ie. frtm MBtioday tt Satgurday).
18. What is the information is stored in /etc/dumpdates file?
/Setc/Sdgumpdates fle rectrds the backgup iioftrmattio if -gu tpttio is gused with dgump
ctmmaiod tt take a backgup. Iio this fle each liioe tells the fle system that was backed gup last
le el tf backgup the date day aiod tme tf the backgup.

12. Managing Installed Services

Ratnakar Page 104


[Pick the date] [LINUX NOTES FOR LEVEL 2]

1. What is service or deamon?


Ser ice tr deamtio is prtiram that stats at backirtguiod aiod ctiotiogutgusly rguio iio the
backirtguiod. The ser ice tr deamtio is ready ftr iiopgut tr mtioittr the chaioies iio tgur ctmpguter
aiod resptiod tt them. Ftr example the Apache ser er has a deamtio called htpd that listeios
tio ptrt iot. 80 tio tgur ctmpguter aiod wheio it recei es a reqguest ftr a paie it seiods the
apprtpriate data back tt the clieiot machiioe.
Example : apache samba NFS FTP ....etc.
2. What are the commands used to control the services?
service :
This ctiotrtls the startioi aiod sttppiioi the ser ices dguriioi sessitio aiod these setiois will iott be
sa ed. We caio start the Apache ser ice iio this way bgut it will iott start tio btttioi tme. Usiioi
this methtd the ser ice will ctiotiogue tt rguio tio guptt ioext bttt bgut frtm ioext bttt the ser ice
will iott be started aguttmatcally.
chkconfig :
This ctiotrtls which ser ices are set tt start at bttt tme. These setiois will be sa ed aiod
applied at ioext bttt. Chaioiiioi these setiois will iott start the ser ice immediately aiod it will
jgust fai them tt be started frtm the ioext bttt.
3. What are the diferences between RHEL -6 and RHEL-7 services?
RHEL -6 RHEL -7
(a). The pareiot prtcess ie. the startioi (a). The pareiot prtcess ie. the startioi
prtcess is prtcess is
initd aiod it's prtcess id (pid). is 1. systemd aiod it's prtcess id (pid). is 1.
(b). There twt ctmmaiods ftr startioi the (b). Here tioly tioe ctmmaiod is gused tt
ser ices . start the
They are called # service aiod # chkconfig ser ice. That is # systemctl
(c). # service ctmmaiod is gused tt start tr
sttp the (c). # systemctl is the ctmmaiod tt start
ser ices temptrarily aiod # chkconfig is tr sttp
gused the ser ices temptrarily tr ioext btttioi
tt start tr sttp the ser ices at ioext btttioi tme.
tme.
(d). /usr/lib/systemd/system is the
(d). /etc/init.d is the ltcattio ftr all the
ltcattio ftr
ser ices.
all the ser ices.
(e). # systemctl
(e). # ser ice <ser ice ioame>
<start/Ssttp/Srestart/Sreltad/S
<start/Ssttp/Srestart/Sreltad/Sstatgus >
statgus ><ser ice ioame>

4. What are the diferences between initd and systemd deamons?


Initd systemd
(a). It is the startioi prtcess iio RHEL - 4 5 aiod 6. (a). It is startioi prtcess iio RHEL - 7.
(b). It's prtcess id (pid). is 1. (b). It's prtcess id (pid). is 1.

Ratnakar Page 105


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(c). It will take mtre tme tt the system aiod (c). It will take less tme tt start the system aiod
ser ices. ser ices wheio ctmpared tt RHEL - 6.
(d). It will start the ser ices tioe by tioe. (d). It will start the ser ices parallel iott tioe by tioe.
(e). All the liiogux ser ices are eiods with letter
(e). All the liiogux ser ices are eiods with letter d.
d.ser ice
Example : sshd httpd crtiod ...etc.
Example : sshd.ser ice httpd.ser ice ...etc.

5. How to make the computer to boot fasterly?


MBaioy ser ices are reqguired tt rguio all the tme htwe er maioy caio be tgurioed tfe ftr btth
secgurity reastios as rguioioiioi guioioecessary ser ices tpeios mtre dttrs iiott tgur ctmpguter bgut alst
ftr perftrmaioce reastios. It may take mguch difeereioce bgut tgur ctmpguter shtguld bttt sliihtly
faster with less ser ices it has tt start tio bttt.
St tioe tf the techioiqgue tt start the system fast aiod maiiotaiio tt imprt e secgurity is tgurio tfe the
guioioeeded ser ices.
6. What are masking and unmasking the services?
MBaskiioi the ser ices meaios hidiioi the ser ices aiod guiomaskiioi the ser ices meaios guiohidiioi
the ser ices. The maskiioi aiod guiomaskiioi are the ioew ctmmaiods iio RHEL - 7. If aioy twt similar
ser ices (ftr example iotp aiod chrtioy). are there iio a system we caioiott start the twt ser ices
at a tme. Iio these sceioarits we it ftr mask aiod guiomask ctmmaiods.
# systemctl mask sshd (tt hide the sshd ser ice temptrarily ie. we caioiott
start the ser ices
wheio we mask aioy ser ice).
# systemctl guiomask sshd (tt guiohide the sshd ser ice ie. we caio start the
ser ice aiaiio).
* we caio alst guse RHEL - 6 ctmmaiods like as # ser ice aiod # chkctiofi bgut these twt
ctmmaiods will
iioterioally call the # systemctl ctmmaiods tioly. St iio RHEL - 7 # systemctl ctmmaiod is the
rectmmeioded
tioe.
# systemctl --failed --type=ser ice (tt check all the failed ser ices).
# systemctl --failed --type=prtcess (tt check all the failed prtcesses).
* Iio RHEL - 6 ser ice ioames eiods with 'd' tioly bgut iio RHEL - 7 the ser ice ioames eiods with
d.ser ice aiod these
are all text fles tioly. St iio RHEL - 7 we caio tpeio aiod see all the system ser ices aiod read their
ctioteiots.
# ps (tt see the act e prtcess iio the system).
# ttp (It will shtw a dyioamic real-tme iew tf a rguioioiioi system. ie. a sgummary
tf prtcesses tr threads
cgurreiotly maioaied by the Liiogux kerioel).

Ratnakar Page 106


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# kill (It seiods the specifed siiioal tt the specifed prtcess tr prtcess irtgup).
# pkill (It will seiod the specifed siiioal tt each prtcess iiostead tf listioi them tio
staiodard tgutpgut).
# pstree (tt shtw all the rguioioiioi prtcesses as a tree strguctgure. The tree is rttted
either pid tr iioit).
# ioice (tt rguio a prtiram with mtdifed schedguliioi pritrity ie. it rguios the prtcess
with aio
adjgustable ioiceioess).
# reioice (tt alter the schedguliioi pritrity tf tioe tr mtre rguioioiioi prtcesses).
# pirep (tt list the prtcess id's which matches with the pirep arigumeiot).
RHEL - 6 commands :
# ser ice <ser ice ioame> statgus (tt check the statgus tf the ser ice).
# ser ice <ser ice ioame> start (tt start the ser ice).
# ser ice <ser ice ioame> sttp (tt sttp the ser ice).
# ser ice <ser ice ioame> reltad (tt reltad the ser ice).
# ser ice <ser ice ioame> restart (tt restart the ser ice).
* These abt e ctmmaiods will chaioie the ser ice statguses temptrarily. St if we waiot tt chaioie
statguses tf the
prtcess aguttmatcally frtm ioext bttt tiowards we ha e tt eioable thtse ser ices as ii eio beltw.
# chkctiofi --list (tt check the a ailability tf the ser ices iio
difeereiot rguio le els).
# chkctiofi --list <ser ice ioame> (tt check the a ailability tf the ser ice iio
difeereiot rguio le els).
# chkctiofi <ser ice ioame> tio (tt make the ser ice a ailable afer restart).
# chkctiofi <ser ice ioame> tfe (tt make the ser ice guioa ailable afer ioext
bttt).
# chkctiofi --le el <1-6><ser ice ioame><tio/Stfe>(tt make the ser ice a ailable tr
guioa ailable tio the
partcgular rguio le el).
# chkctiofi --le el 5 sfpd tio (tt make the sfpd ser ice a ailable tio rguio le el 5).
# chkctiofi --le el 345 sfpd tio (tt make the sfpd ser ice a ailable tio rguio le els
3 4 aiod 5).
RHEL - 7 commands :
# systemctl statgus <ser ice ioame> (tt check the statgus tf the ser ice).
# systemctl start <ser ice ioame> (tt start the ser ice).
# systemctl sttp <ser ice ioame> (tt sttp the ser ice).
# systemctl reltad <ser ice ioame> (tt reltad the ser ice).
# systemctl restart <ser ice ioame> (tt restart the ser ice).
* These abt e ctmmaiods will chaioie the ser ice statguses temptrarily. St if we waiot tt chaioie
statguses tf the

Ratnakar Page 107


[Pick the date] [LINUX NOTES FOR LEVEL 2]

prtcess aguttmatcally frtm ioext bttt tiowards we ha e tt eioable thtse ser ices as ii eio
beltw.
# systemctl eioable <ser ice ioame> (tt make the ser ice a ailable at ioext bttt).
# systemctl disable <ser ice ioame> (tt make the ser ice guioa ailable at ioext bttt).
# irep <striioi ioame><fle ioame> (tt display the specifed striioi iio that fle).
# irep -io <striioi ioame><fle ioame> (tt display the striioi with liioe iot's).
# irep -e <striioi ioame 1> -e <striioi 2><fle ioame> (tt display 2 tr mgultple striiois iio
that fle).
# irep -t <striioi ioame><fle ioame> (tt display tioly that striioi iio that fle iott whtle the
text tf that fle).
# irep - <striioi ioame><fle ioame> (tt display all the striiois except the specifed tioe).
# irep ^ this ctss (tt display the liioe which is startioi with the
specifed striioi).

13. Managing Process

1. What is process and explain it?

Ratnakar Page 108


[Pick the date] [LINUX NOTES FOR LEVEL 2]

A prtcess is a set tf iiostrgucttios which execgutes iio the memtry. It is created iio the memtry
wheio a prtiram tr ctmmaiod is execguted. E ery prtcess is ideiotfed by a guioiqgue iot. ie. PID
(Prtcess ID).. Se eral prtcesses are started at bttt tme aiod which are rguioioiioi at backirtguiod
called deamtios. The Liiogux kerioel is gused tt ctmmguioicate with the prtcesses by their prtcess
ID's (PID's).. Deamtio is a prtcess rguioioiioi iio the backirtguiod. These are haiodled by the system
aiod prtcess are haiodled by the gusers.
The frst prtcess iio RHEL - 6 is initd aiod it starts at bttt tme. It's prtcess ID is 1 where as iio
RHEL - 7 the frst prtcess is systemd aiod it starts at bttt tme. Tt maioaie tr tt see the
prtcesses there are twt ctmmaiods.
(i). # ps aiod (ii). # ttp
# ps :
It is jgust a sioap shtt tf the cgurreiot statgus tf the prtcesses. It ii es tioly tioe termiioal
iioftrmattio iott all the termiioals iioftrmattio.
# top :
Usiioi ttp ctmmaiod we caio mtioittr the prtcesses ctiotiogutgusly. y defagult e ery 3 sectiods
it will refresh the data.
2. How many process are run generally on Linux and explain them?
There are ieioerally three types tf prtcesses that rguio tio Liiogux. They are
(i). Iioteract e Prtcesses
(ii). System Prtcess tr deamtio
(iii). Aguttmatc tr batch.
Interactive Processes :
Iioteract e prtcesses are thtse prtcesses that are iio tked by a guser aiod caio iioteract with the
guser. Ftr example # i tr # im are the iioteract e prtcesses. Iioteract e prtcesses may be
rguio iio ftreirtguiod tr backirtguiod. The ftreirtguiod prtcess is the prtcess that we are cgurreiotly
iioteractioi with aiod is gusiioi the termiioal as its stdiio (staiodard iiopgut). aiod stdtgut (staiodard
tgutpgut).. The backirtguiod prtcess is iott iioteractioi with the guser aiod caio be iio tioe tf twt
states ie. pagused tr rguioioiioi.
System Processes or deamons :
Deamtio is refer tt prtcesses that are rguioioiioi tio the ctmpguter aiod prt ides ser ices bgut dt
iott iioteract with the ctiostle. MBtst ser er stfware is implemeioted as a deamtio. Ftr example
Apache samba sshd are the deamtios. Aioy prtcess caio bectme a deamtio as ltioi as it is rguio iio
the backirtguiod aiod dtes iott iioteract with the guser.
Automatic processes :
Aguttmatc prtcesses are iott ctioioected tt a termiioal aiod these are qguegued iiott a spttler area
where they wait tt be execguted tio a FIFO (First Iio - First Ogut). basis. Sguch tasks caio be
execguted gusiioi tioe tf twt criteria.
At certaiio date aiod tme : dtioe gusiioi the "at" ctmmaiod.

Ratnakar Page 109


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Wheio the tttal system ltad is ltw eiotguih tt accept extra jtbs : dtioe gusiioi the " cron "
ctmmaiod. y defagult tasks are pgut iio a qguegue where they wait tt be execguted guiotl the system
ltad is ltwer thaio 0.8 aiod crtio jtb prtcessiioi is alst gused ftr tptmisiioi system perftrmaioce.
3. What is parent process?
The prtcess which starts tr creates aiotther prtcess is called the pareiot prtcess. E ery
prtcess will be ha iioi a pareiot prtcess except iioitd prtcess. The iioitd prtcess is the pareiot
prtcess tt all the remaiioiioi prtcesses iio
Liiogux system becaguse it is the frst prtcess which iets started by the kerioel at the tme tf
btttioi aiod it's PID
is 1. Oioly afer iioitd prtcess iets started the remaiioiioi prtcesses are called by it aiod heioce it
is resptiosible ftr all the remaiioiioi prtcesses iio the system. The pareiot prtcess is ideiotfed by
PPID (pareiot prtcess ID)..
4. What is child process?
A prtcess which started tr created by the pareiot prtcess is called child prtcess aiod it is
ideiotfed by PID.
Useful # ps commands :
# ps -a (it displays all the termiioals prtcesses iioftrmattio).
# ps -agu (it displays all the termiioals prtcesses iioftrmattio with guser
ioames).
# ps -agux (it displays all the termiioals prtcesses iioftrmattio iioclgudiioi
backirtguiod
prtcesses with guser ioames).
* ? (qguesttio mark). if it is appeared at tty ctlgumio it iiodicates that is a backirtguiod prtcess.
# ps -ef (it displays the tttal prtcesses iioftrmattio with pareiot
prtcess ID (PPID).).
# ps -P <prtcess id> (it displays the prtcess ioame if we kiotw the prtcess ID
(pid).).
# pidtf<prtcess ioame> (tt see the prtcess ID tf the specifed prtcess).
# pidtf iioitd (tt see the prtcess ID tf the iioitd prtcess).
# pstree (tt display the pareiot aiod child prtcesses strguctgure iio tree
ftrmat).
# ps -gu <guser ioame> (tt display all the prtcesses tf the specifed guser).
# ps -gu rajgu (tt display all the prtcesses tf the guser rajgu).
# ps -G <irtgup ioame> (tt display all the prtcesses that are rguioioiioi by a partcgular
irtgup).
# ps -t pid ctmm %mem %cpgu (tt display prtcess id ctmmaiod %memtry aiod
%cpgu gutlisattio
iotthiioi bgut flteriioi the tgutpgut).

Ratnakar Page 110


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# ps -At pid ctmm %mem %cpgu (tt display the same iioftrmattio as abt e bgut
iioclgudiioi stme mtre
iioftrmattio).
# ps -t pid ctmm %mem %cpgu |strt -k <iot.> -r |head -io 10 (tt display which prtcess is
gutlisiioimtre
memtry tr cpgu iio re erse trder where -k meaios feld <iot.> meaios feld iot. aiod -r re erse
trder).
# ps -t pid ctmm %mem %cpgu |strt -k 3 -r |head -io 10 (tt display the prtcess
which tccgupies mtre
memtry aiod cpgu gutlisattio iio re erse trder).
# ps -agux |irep freftx (tt check whether the freftx is
rguioioiioi tr iott).
# pirep -U <guser ioame> (tt display all the prtcess ID's
tioly ftr that guser).
* Tt ctmmguioicate with the prtcesses # kill aiod # pkill ctmmaiods are gused.
# kill -----> It will kill the prtcesses gusiioi PID's.
# pkill -----> It will kill the prtcesses gusiioi prtcess ioames.
* We caio alst ii e stme siiioals while gusiioi the abt e ctmmaiods aiod we iet the siiioals
iioftrmattio by
# kill -l ctmmaiod. This ctmmaiod will list all the siiioals with iot's aiod there are 64 siiioals tt
pass.
5. What is signal in Process management?
Siiioals are a way tf seiodiioi simple messaies tt prtcesses. MBtst tf these messaies are already
defioed aiod htwe er siiioals caio tioly be prtcessed wheio the prtcess is iio guser mtde. E ery
siiioal has a guioiqgue siiioal ioame. Each siiioal ioame is a macrt which staiods ftr a ptsit e iioteier.
Siiioals caio be ieioerated by the prtcess itself tr they caio be seiot frtm tioe prtcess tt aiotther.
A ariety tf siiioals caio be ieioerated tr deli ered aiod they ha e maioy guses ftr prtirammers.
6. What are the important signals in process management?
1. SIGHUP -----> tt reltad (read the ctiofigurattio aiod ltad).
2. SIGINT -----> tt iioterrgupt frtm the keybtard (iotthiioi bgut Ctrl + c).
3. SIGQUIT -----> tt qguit the prtcess frtm keybtard (iotthiioi bgut Ctrl + l).
9. SIGKILL -----> tt kill the prtcess ftrcefgully (iotthiioi bgut guiobltckable).
15.SIGTERMB -----> wait ftr ctmpletioi the prtcess aiod theio termiioate (termiioate iracefgully).
18.SIGCONT -----> tt ctiotiogue tr resgume the prtcess if it is sttpped
19.SIGSTOP -----> tt termiioate the prtcess (If it is iott sttpped the prtcess we caioiott
ctiotiogue tr resgume that
prtcess by Ctrl + c tr Ctrl + s).
20.SIGHTSTP ----> tt sttp the prtcess (iotthiioi bgut Ctrl + s).
* gut the mtst ctmmtioly gused siiioals are 1 9 15 aiod 20.
* The defagult siiioal is 15 (iracefgully). wheio we iott specifed aioy siiioal.

Ratnakar Page 111


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# kill - <siiioal><prtcess ID> (tt kill the specifed prtcess gusiioi kill siiioal).
# kill -9 1291 (tt kill the prtcess which has the PID as
1291).
* If we iott specifed the siiioal iot. theio the defagult siiioal 15 will efeect.
# kill 1291 (tt kill the prtcess 1291 with defagult siiioal).
# pkill -gu <guser ioame> (tt kill all the prtcesses tf the specifed
guser).
# pkill -gu rajgu (tt kill all the prtcesses tf the guser rajgu).
# pkill -9 freftx (tt kill the freftx prtcess).
7. How many process states are there?
There are six prtcess states aiod they are
(i). Rguioioiioi prtcess (the prtcess which is iio rguioioiioi state aiod is iiodicated by " r " )..
(ii). Sleepiioi prtcess (the prtcess which is iio sleepiioi state aiod is iiodicated by " s " ).
(iii). Waitioi prtcess (the prtcess which is iio waitioi state aiod is iiodicated by " w " )..
(i ). Sttppiioi prtcess (the prtcess which is iio sttppiioi state aiod is iiodicated by " T " )..
( ). Orphaio prtcess (the prtcess which is rguioioiioi withtgut pareiot prtcess aiod is iiodicated by
" o " )..
( i). Ztmbie prtcess (the prtcess which is rguioioiioi withtgut child prtcess aiod is iiodicated by " Z
" )..
8. What is Orphan process?
The prtcesses which are rguioioiioi withtgut pareiot prtcesses are called Orphaio prtcesses.
Stmetmes pareiot prtcess cltsed withtgut kiotwiioi the child prtcesses. gut the child prtcesses
are rguioioiioi at that tme. These child prtcesses are called Orphaio prtcesses.
9. What is Zombie process?
Wheio we start pareiot prtcess it will start stme child prtcesses. Afer stme tme the child
prtcesses will died becaguse tf iott kiotwiioi the pareiot prtcesses. These pareiot prtcesses
(which are rguioioiioi withtgut child prtcesses). are called Zambie prtcesses. These are alst
called as defaguioct prtcesses.
10. How to set the priority for a process?
Prtcesses pritrity meaios maioaiiioi prtcesstr tme. The prtcesstr tr CPU will perftrm
mgultple tasks at the same tme. Stmetmes we caio ha e eiotguih rttm tt take tio mgultple
prtjects aiod stmetmes we caio tioly ftcgus tio tioe thiioi at a tme. Other tmes stmethiioi
imptrtaiot ptps gup aiod we waiot tt de tte all tf tgur eioeriy iiott stl iioi that prtblem while
pgutioi less imptrtaiot tasks tio the back bgurioer.
Iio Liiogux we caio set iguideliioes ftr the CPU tt ftlltw wheio it is lttkiioi at all the tasks it has tt
dt. These iguideliioes are called niceness tr nice value. The Liiogux ioiceioess scale ites frtm
-20 to 19. The ltwer the iogumber the mtre pritrity that task iets. If the ioiceioess algue is hiiher
iogumber like 19 the task will be set tt the ltwest pritrity aiod the CPU will prtcess it wheioe er it
iets a chaioce. The defagult ioice algue is 0 (zero)..

Ratnakar Page 112


[Pick the date] [LINUX NOTES FOR LEVEL 2]

y gusiioi this scale we caio alltcate tgur CPU restgurces mtre apprtpriately. Ltwer pritrity
prtirams that are iott imptrtaiot caio be set tt a hiiher ioice algue while the hiiher pritrity
prtirams like deamtios aiod ser ices caio be set tt recei e mtre tf the CPU's ftcgus. We caio
e eio ii e a specifc guser a ltwer ioice algue ftr all his/Sher prtcesses st we caio limit their ability
tt sltw dtwio the ctmpguter's ctre ser ices.
There are twt tpttios tt redguce/Siiocrease the algue tf a prtcess. We caio either dt it gusiioi the
nice tr renice ctmmaiods.
Examples :
# ioice -io <ioice algue raioie frtm -20 tt 19><ctmmaiod> (tt set a pritrity tt a prtcess
beftre startioi it).
# ioice -io 5 cat > rajgu (tt set the medigum pritrity tt
cat ctmmaiod).
# ps -elf (tt check the ioice algue ftr that
ctmmaiod).
* Tt reschedgule the ioice algue tf existioi prtcess frst check the PID tf that prtcess by # ps
-elf ctmmaiod
aiod theio chaioie the ioiceioess tf that ctmmaiod by # renice <nice value (-20 to 19)>< PID >
ctmmaiod.
# reioice 10 1560 (tt reschedgule the PID
1560).
11. What is top command and what it shows?
top is a ctmmaiod tt see the prtcesses states aiod statguses iioftrmattio ctiotiogutgusly guiotl we
qguit by pressiioi " q ". y defagult ttp ctmmaiod will refresh the data ftr e ery 3 sectiods.
Wheio we ioeed tt see the rguioioiioi prtcesses tio tgur Liiogux iio real tme the ttp ctmmaiod will
be ery gusefgul. esides the rguioioiioi prtcesses the ttp ctmmaiod alst displays tther
iioftrmattio like free memtry btth physical aiod swap.
The frst liioe shtws the cgurreiot tme "up 1 day" shtws htw ltioi the system has beeio gup ftr
"3 user" htw maioy gusers ltiiio "load average : 0.01, 0.00, 0.23" the ltad a eraie tf the
system 1, 5 and 15 minutes.
The sectiod liioe shtws the iot tf prtcesses aiod their cgurreiot states.
The third liioe shtws CPU gutlisattio details like % tf the gusers prtcesses % tf the system
prtcesses % tf a ailable CPU aiod % tf CPU waitioi tme ftr I/SO (iiopgut aiod tgutpgut)..
The ftgurth aiod ffh liioes shtws the tttal physical memtry iio the system gused physical
memtry free physical memtry bgufeered physical memtry the tttal swap memtry iio the
system gused swap memtry free swap memtry aiod cached swap memtry ... etc.
Frtm sixth liioe tiowards the felds are as ftlltws.
PID Prtcess ID
USER Owioer tf the prtcess ie. which guser execguted that prtcess
PR Dyioamic Pritrity
NI Nice algue alst kiotwio as base algue

Ratnakar Page 113


[Pick the date] [LINUX NOTES FOR LEVEL 2]

VIRT Virtgual sise tf the task iioclgudes the sise tf prtcesses execgutable biioary
RES The sise tf RAMB cgurreiotly ctiosgumed by the task aiod iott iioclguded the
swap ptrttio
SHR Shared memtry area by twt tr mtre tasks
S Task Statgus
% CPU The % tf CPU tme dedicated tt rguio the task aiod it is dyioamically
chaioied
% MEM The % tf memtry cgurreiotly ctiosgumed by the task
TIME+ The tttal CPU tme the task has beeio gused siioce it started. + siiio meaios
it is displayed with hguiodredth tf a sectiod iraiogularity. y
defagult TIMBE/STIMBE+ dtes iott acctguiot the CPU tme gused
by the task's dead childreio
COMMAND Shtwiioi prtiram ioame tr prtcess ioame.
* While rguioioiioi the ttp ctmmaiod jgust press the ftlltwiioi keys wtks aiod the tgutpgut will be
sttred iio real tme.
1 -----> 2iod CPU iioftrmattio Shif + > -----> Paie gup
h ----->Help Shif + < -----> Paie dtwio
Eioter -----> Refresh immediately io -----> Ngumber tf tasks
k -----> Kill the prtcess gu -----> guser prtcesses
MB -----> Strt by memtry gusaie P -----> Strt by CPU gusaie
T -----> Strt by cgumgulat e tme s -----> Ctltr display
r -----> Tt reschedgule the pritrity by reioice d -----> Chaioie the delay tme
(refresh tme).
b -----> Hiihliiht the rguioioiioi prtcess W -----> Write the iioftrmattio iio
/root/.toprc fle
q -----> qguit the ttp ctmmaiod
The status of the processes :
r -----> Rguioioiioi prtcess s -----> Sleepiioi prtcess
s -----> Ztmbie prtcess T -----> Sttpped prtcess
D -----> Uioiioterrgupted sleepiioi prtcess R< -----> Hiih pritrity
N > ----> Ltw pritrity t -----> Orphaio prtcess
+ -----> Ftreirtguiod prtcess ? -----> ackirtguiod prtcess
# reioice -io 10 5453 (tt chaioie the specifed rguioioiioi prtcess
pritrity tio liioe).
# ioice -io -15 freftx (tt start the freftx prtcess with pritrity
le el -15).
12. How to solve the issue if the CPU utilization is 99% ?
(i). First check which prtcess aiod wht execguted that prtcess is ctiosgumiioi mtre CPU gutlisattio
tr memtry gutlisattio by execgutioi # top ctmmaiod.

Ratnakar Page 114


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). Theio iioftrm tt thtse gusers wht execguted that prtcess thtguih mail messaie tr raisiioi the
tcket.
(iii). If thtse gusers are iott a ailable tr iott resptiodiioi tt tgur mail theio we ha e tt chaioie the
pritrity tf that prtcess gusiioi # renice ctmmaiod.
(i ). eftre chaioiiioi the prtcess pritrity le el we ha e tt iet tr take apprt al frtm tgur team
lead tr prtject maioaier.
13. How to check the wwn no. of lun?
(i). First iiostall sysutils packaie tt execgute the ctmmaiods tt kiotw the wwio iogumber by
execgutioi ctmmaiod
# yum install sysutils -y
(ii). # systool -c fs_host -v |grep "port-name" (tt check the wwio iogumber).
14. How to remove the page caches and other caches?
# sysioc echt 2 > /Sprtc/Ssys/S m/Sdrtp_caches (tt remt e the paie caches).
# sysioc echt 3 > /Sprtc/Ssys/S m/Sdrtp_caches (tt remt e all types tf caches like
deiot cache
paie caches aiod tthers).
15. What is "sosreport" and how to generate it?
Sosreport is a ctmmaiod iio liiogux (RHEL / CentOS). which ctllects system configuration aiod
diaiiotstc iioftrmattio tf ytgur liiogux btx like rguioioiioi kerioel ersitio ltaded mtdgules aiod
system aiod ser ice ctiofigurattio fles. This ctmmaiod alst rguios exterioal prtirams tt ctllect
fgurther iioftrmattio aiod sttres this tgutpgut iio the resgultioi archi e.
Stsreptrt is reqguired wheio ytgu ha e tpeio a case with redhat ftr techioical sgupptrt. Redhat
sgupptrt Eioiiioeers will reqguire stsreptrt tf ytgur ser er ftr trtgubleshtttioi pgurptse.
Tt rguio stsreptrt sos packaie shtguld be iiostalled. Sts packaie is part tf defagult iiostallattio iio
mtst tf liiogux. If ftr aioy reastio this packaie is iot iiostalled theio guse beltw ygum ctmmaiod tt
iiostall sos package :
# ygum iiostall sts -y
Generate the sosreport :
Opeio the termiioal aiod type stsreptrt ctmmaiod :
# stsreptrt
This ctmmaiod will iotrmally ctmplete withiio a few minutes. Depeiodiioi tio ltcal ctiofigurattio
aiod the tpttios specifed iio stme cases the ctmmaiod may take ltioier tt fioish. Oioce
ctmpleted stsreptrt will ieioerate a ctmpressed a fle guioder /tmp ftlder. Difeereiot ersitios guse
difeereiot ctmpressitio schemes (gz, bz2, or xz).. The fle shtguld be prt ided tt Redhat sgupptrt
represeiotat e (iotrmally as aio attachmeiot tt aio tpeio case)..
Note: stsreptrt reqguires rttt permissitios tt rguio.
Diferent Options used in sosreport command :
The stsreptrt ctmmaiod has a modular structure aiod alltws the guser tt eioable aiod disable
mtdgules aiod specify mtdgule tpttios ia the ctmmaiod liioe. Tt list available modules (plgui-iios).
guse the ftlltwiioi ctmmaiod:

Ratnakar Page 115


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# stsreptrt -l
Tt turn of a mtdgule iioclgude it iio a ctmma-separated list tf mtdgules passed tt the -io/S–skip-
plguiiios tpttio. Ftr iiostaioce tt disable btth the k maiod amd mtdgules:
# stsreptrt -io k m amd
Iiodi idgual mtdgules may prt ide addittioal tpttios that may be specifed ia the -k option. Ftr
example tio Red Hat Eioterprise Liiogux 5 iiostallattios the sts rpm mtdgule ctllects "rpm -Va"
tgutpgut by defagult. As this may be time-consuming the beha itgur may be disabled ia:
# stsreptrt -k rpm.rpm a=tfe
16. What is the command to see the complete information on virtual memory?
# mstat is the ctmmaiod tt the ctmplete iioftrmattio tio irtgual memtry like iot tf
prtcesses memtry gusaie paiiioi memtry bltck I/SO (iiopgut /Stgutpgut). traps disk aiod
CPU act ity.
# mstat 2 10 (It will ii e the reptrt ftr e ery 2 sectiods guptt 10 tmes).
The felds are r -----> htw maioy waitioi prtcesses
b -----> htw maioy prtcesses are bgusy
swapd -----> htw mguch irtgual memtry gused
free -----> htw mguch memtry is freely a ailable
bgufeer -----> htw mguch temptrary memtry gusiioi
cachiioi -----> htw mguch cachiioi stll gusiioi
swapiio -----> htw mguch data traiosferred frtm RAMB tt swap
swaptgut ---> htw mguch data traiosferred frtm swap tt RAMB
bi -----> htw mguch bltck iiopgut
bt -----> htw mguch bltck tgutpgut
system iio ---> the iot. tf iioterrgupts
system cs ---> the iot. tf ctiotexts chaioied
# mstat -a (tt see the act e aiod iioact e prtcesses).
# mstat -d (tt see the statstcs tf the disk gused).
# cat /Sprtc/Smemiioft (tt see the preseiot memtry iioftrmattio).
17. What is the command to see the I/O statistics?
# itstat (tt see the Iiopgut aiod Ogutpgut statstcs iio the Liiogux system).
* This ctmmaiod is gused tt mtioittriioi the system iiopgut aiod tgutpgut statstcs aiod prtcesses
traiosfer rate.
* It is alst gused tt mtioittr htw maioy kilt bytes read per sectiod aiod htw maioy kilt bytes
read aiod write shtws CPU ltad a eraie statstcs siioce the last rebttt iio frst liioe
aiod mtst cgurreiot data is shtwio iio the sectiod liioe.
18. How many CPUs are there in the system?
# cat /proc/cpuinfo ctmmaiod will shtw iot. tf CPUs iot. tf ctres iot. tf threads iot. tf
stckets aiod the CPU architectgure ...etc. iioftrmattio.
# nproc ctmmaiod will ii e the iot. tf CPUs preseiot iio the system.

Ratnakar Page 116


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# lscpu ctmmaiod will ii e the iioftrmattio the architectgure tf the CPU (x86_64 tr x86_32).
iot. tf ctres iot. tf threads iot. tf stckets cache memtry sises (L 1 L 2 L 3 ...etc). CPU
speed aiod the eiodtr tf the CPU.
19. How to send the processor into offline?
# ls -l /sys/devices/system/cpu is the ctmmaiod tt see the iot. tf prtcesstrs preseiot iio the
system.
# echo 0 > /sys/devices/system/cpu/cpu4/online is the ctmmaiod tt seiod the CPU4 iiott
tffliioe.
# grep "processor" /proc/cpuinfo tr # cat /sys/devices/system/cpu/offline are the
ctmmaiod tt see the prtcesstr statgus whether tffliioe.
20. How to send the processor into online?
# ls -l /sys/devices/system/cpu is the ctmmaiod tt see the iot. tf prtcesstrs preseiot iio the
system.
# echo 1 > /sys/devices/system/cpu/cpu4/online is the ctmmaiod tt seiod the CPU4 iiott
tffliioe.
# grep "processor" /proc/cpuinfo tr # cat /sys/devices/system/cpu/online are the
ctmmaiod tt see the prtcesstr statgus whether tioliioe.
21. How to clear /var and /tmp directories?
(i). Ctpy all the eiotries tf thtse directtries iiott a separate ltcattios.
(ii). Redirect the iogull algues iio /S ar aiod /Stmp directtries by execgutioi the beltw ctmmaiods.
# cat /Sde /Siogull > /S ar (tt iogullifyiioi the /S ar directtry).
# cat /Sde /Siogull > /Stmp(tt iogullifyiioi the /Stmp directtry).
22. How to troubleshoot if df -k is giving error?
(i). First check which fle system is ii iioi errtr by # df -k ctmmaiod theio see whether aioy fles
are tpeioed tr iott. If tpeioed theio cltse thtse fles by iioftrmiioi thtse teams which are
gusiioi that fle system.
(ii). Uiomtguiot that fle system by takiioi apprt al frtm hiiher aguthtrites aiod rguio fsck tio that fle
system theio iotrmally it will be stl ed if we rguio fsck ctmmaiod.
(iii).If iott stl ed e eio thtguih we rguio fsck theio delete tr remt e that fle system recreate
that fle system mtguiot that fle system aiod resttre the data frtm receiot backgup.
23. What are the diferences between a deamon and a process?
(i). Deamtio is a ser ice tt prt ide stme ser ices tt the gusers where as a prtcess is tt dt stme
partcgular tasks.
(ii). We caio eioable tr disable the deamtio bgut we caioiott disable tr eioable the prtcess.
(iii).We caio dt start tr sttp the deamtio bgut we caioiott start tr sttp the prtcess. We tioly
kill the prtcess.
(i ). We caio eioable tr disable tt start the deamtios at bttt tme as per tgur reqguiremeiot ie. tio
demaiod is ptssible bgut it is iott ptssible if is a prtcess.
( ). Deamtio is a backirtguiod prtcess where as prtcess is a ftreirtguiod prtcess.
24. What is command to check the load average?

Ratnakar Page 117


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# uptime is the ctmmaiod tt check the system ltad preseiot tme frtm htw maioy htgurs the
system is rguioioiioi aiod ltad a eraie.
* The ltad a eraie shtws three felds. The 1st feld shtws the ltad a eraie frtm 1 miiogute
2iod feld shtws the ltad a eraie frtm 5 miiogutes aiod 3rd feld shtws the ltad
a eraie frtm 15 miiogutes.
25. How to assign or shif the process to the particular CPU?
(i). First iiostall util-linux packaie by # yum install util-linux -y ctmmaiod.
(ii). Check the specifed prtcess is assiiioed tt which prtcesstr ie. which CPU by # taskset -p
<pid> ctmmaiod.
(iii). Theio shif the prtcess tt aiotther a ailable CPU by # taskset -cp <cpu -list><pid>
ctmmaiod.
Examples:
# taskset -p 2125 (tt check which prtcesstr is assiiioed tt that
prtcess ID).
# taskset -cp 0 4 2125 (tt shif the prtcess tt the CPUs 0 aiod 4).
# taskset 0 freftx (tt assiiio the freftx prtcess tt the CPU 0).
26. How to limit the CPU usage of a linux process?
(a). First iiostall the cpulimit packaie by # yum install cpulimit -y ctmmaiod.
* This packaie is iott a ailable iio iotrmal Liiogux packaies aiod it is a ailable iio EPEL (Extra
Packaies ftr Eioterprise Liiogux).. St frst we ha e tt eioable the EPEL reptsittry
iio tgur system by ftlltwiioi steps.
(i). # ygum iiostall epel-release -y (tt iiostall the epel-release packaie
iio RHEL - 7).
(ii). # rpm -U h http:/S/Smirrtrs.kerioel.tri/Sfedtra-epel/S6/Si386/Sepel-release-6-8.iotarch.rpm
(tt iiostall the
EPEL packaie iio RHEL - 6).
(ii). # rpm -U h http:/S/Smirrtrs.kerioel.tri/Sfedtra-epel/S5/Si386/Sepel-release-5-4.iotarch.rpm
(tt iiostall the
EPEL packaie iio RHEL - 5).
(iii). # rpm --imptrt /Setc/Spki/Srpm-ipi/SRPMB-GPG-KEY-EPEL-5 (tt imptrt the ipi key if it
ask wheio execgutioi
the abt e ctmmaiod iio RHEL - 5).
(i ). # rpm --imptrt /Setc/Spki/Srpm-ipi/SRPMB-GPG-KEY-EPEL-6 (tt imptrt the ipi key if it
ask wheio
execgutioi the abt e ctmmaiod iio RHEL - 6).
( ). # rpm --imptrt /Setc/Spki/Srpm-ipi/SRPMB-GPG-KEY-EPEL-7 (tt imptrt the ipi key if it
ask wheio
execgutioi the abt e ctmmaiod iio RHEL - 7).
( i). # ygum reptlist (tt check EPEL reptlist).

Ratnakar Page 118


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(b). # cpgulimit -p <PID> -l 10 (tt see the CPU gusaie tf that prtcess aiod limit the
CPU gusaie tt
10%).
(c). # cpgulimit -e /Sgusr/Sltcal/Sbiio/Smyprti -l 20 (tt limit the CPU gusaie tf this ctmmaiod tt
20%).
27. How to capture the network trafc?
# tcpdump is the ctmmaiod tt captgure aiod aioalyse the ioetwtrk trafc. y gusiioi this ctmmaiod
we caio alst trtgubleshttt the ioetwtrk prtblems.
Examples :
# tcpdgump (tt captgure aiod aioalyse the ioetwtrk trafc).
# tcpdgump -i eth0 (tt captgure the ioetwtrk trafc frtm eth0 ctiotiogutgusly aiod
Ctrl + c tt exit).
# tcpdgump -c 30 -i eth0 (tt captgure the ioetwtrk trafc frtm eth0 guptt
30 packets tioly).
# tcpdgump -w /Srttt/Stcp.pcap -i eth0 (tt captgure the ioetwtrk trafc frtm eth0
aiod write that iio
/Srttt/Stcp.pcap fle).
# tcpdgump -t t t -r /Srttt/Stcp.pcap (tt read the ctioteiots tf the
abt e captgured fle).
# tcpdgump -i eth0 ptrt 22 (tt captgure the ioetwtrk trafc frtm
eth0 tf ssh trafc).
# tcpdgump -i eth0 dst 172.25.0.11 aiod ptrt 22 (tt captgure the ioetwtrk trafc frtm
172.25.0.11
system tf ssh trafc).
28. What is SAR utility and how to use it?
SAR staiods ftr System Act ity Reptrt. Usiioi SAR we caio check the iioftrmattio tf CPU
gusaie memtry swap I/SO disk I/SO ioetwtrkiioi aiod paiiioi. We caio iet the iioftrmattio
tf the preseiot statgus aiod ptst statgus (histtry gusiioi the data). guptt last 7 days becaguse
HISTORY=7 is there iio the ctiofigurattio fle. The lti messaies are sttred iio /var/log/sa/sa1,
/var/log/sa/sa2, /var/log/sa/sa3 ....etc. (where 1 2 3 ....etc. are dates).. The SAR
ctiofigurattio is sttred iio /etc/sysconfig/sysstat fle. Iio this fle the HISTORY=7 defagult
tpttio will be there. St we caio chaioie the defagult 7 days tt tgur reqguired algue.

eftre gusiioi the SAR gutlity frst we shtguld iiostall the SAR gutlity packaie by # yum install
sysstat* -y ctmmaiod.
Examples :
# sar 2 10 (It will ii e the system reptrt ftr e ery 2 sectiods
guptt 10 tmes).
# sar -p 2 10 (tt see the CPU gutlisattio ftr e ery 2 sectiods
guptt 10 tmes).

Ratnakar Page 119


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# sar -p ALL -f /S ar/Slti/Ssa/Ssa25 (tt check the CPU gutlisattio tio 25th day tf the
cgurreiot mtioth).
# sar -p ALL -f /S ar/Slti/Ssa/Ssa10 -s 07:00:00 -e 15:00:00 (tt check the CPU gutlisattio
tio 10th day tf the cgurreiot mtioth frtm 7:00 tt 15:00 hrs. where -s
meaios start tme -e eiod tme).
# sar -r 2 10 (tt see the memtry gutlisattio ftr e ery 2 sectiods
guptt 10 tmes).
# sar -r -f /S ar/Slti/Ssa/Ssa14 (tt check the memtry gutlisattio tio 14th day tf the
cgurreiot mtioth).
# sar -r -f /S ar/Slti/Ssa/Ssa10 -s 07:00:00 -e 15:00:00 (tt check the memtry gutlisattio
tio 10th day tf the cgurreiot mtioth frtm 7:00 tt 15:00 hrs. where -s
meaios start tme -e eiod tme).
# sar -S 2 10 (tt see the swap gutlisattio ftr e ery 2 sectiods
guptt 10 tmes).
# sar -S -f /S ar/Slti/Ssa/Ssa25 (tt check the swap gutlisattio tio 25th day tf the
cgurreiot mtioth).
# sar -S -f /S ar/Slti/Ssa/Ssa10 -s 07:00:00 -e 15:00:00 (tt check the swap gutlisattio tio
10th day tf the cgurreiot mtioth frtm 7:00 tt 15:00 hrs. where -s
meaios start tme -e eiod tme).
# sar -q 2 10 (tt see the ltad a eraie ftr e ery 2 sectiods
guptt 10 tmes).
# sar -q -f /S ar/Slti/Ssa/Ssa14 (tt check the ltad a eraie tio 14th day tf the
cgurreiot mtioth).
# sar -q -f /S ar/Slti/Ssa/Ssa10 -s 07:00:00 -e 15:00:00 (tt check the ltad a eraie tio
10th day tf the cgurreiot mtioth frtm 7:00 tt 15:00 hrs.
where -s meaios start tme -e eiod tme).
# sar - 2 10 (tt see the paiiioi iioftrmattio ftr e ery 2 sectiods
guptt 10 tmes).
# sar -d 2 10 (tt see the disk gusaie ftr e ery 2 sectiods
guptt 10 tmes).
# sar -m 2 10 (tt see the ptwer maioaiemeiot ftr e ery 2 sectiods
guptt 10 tmes).
# sar -b 2 10 (tt see the disk iiopgut aiod tgutpgut statstcs ftr e ery 2 sectiods
guptt 10 tmes).
29. What are the port no. for diferent services?
The Port no. list :
FTP (Ftr data traiosfer). 20 HTTP 80
FTP (Ftr ctioioecttio). 21 POP3 110
SSH 22 NTP 123

Ratnakar Page 120


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Telioet 23 LDAP 389


Seiod MBail tr Ptstix 25 Lti Ser er 514
DNS 53 HTTPS 443
DHCP (Ftr Ser er). 67 LDAPS (LDAP + SSL). 636
DHCP (Ftr Clieiot). 68 NFS 2049
TFTP (Tri ial File traiosfer). 69 Sqguid 3128
Samba shared ioame erifcattio 137 Samba Data Traiosfer 138
Samba Ctioioecttio Establishmeiot 138 Samba Agutheiotcattio 445
MBySQL 3306 ISCSI 3260

* Piioi is iott gused aioy ptrt iogumber. It is gused ICMBP (Iioterioet Ctiotrtl MBessaie Prtttctl).
tioly.
Other useful commands :
# guptme (tt see frtm htw ltioi the system is rguioioiioi aiod alst ii es the ltad a eraie
reptrt).
* The ltad a eraie is ha iioi 3 felds. 1 - preseiot statgus 2 - 5 miiogutes back aiod 3 - 15
miiogutes back.
# itstat 5 2 (tt mtioittr the iiopgut aiod tgutpgut statstcs ftr e ery 5 sectiods
guptt 10 tmes).
# ioprtc (tt check htw maioy prtcesstrs (CPUs). are
there iio the system).
# ttp 1 (tt see the iot. prtcesstrs (CPUs). are there
iio the system).
# iptraf (tt mtioittr the TCP tr ioetwtrk trafc statstcs iio
iraphical mtde).
* eftre gusiioi this ctmmaiod iiostall the iptraf packaie by # yum install iptraf* -y
ctmmaiod.
# ifraf -ioi -f eth0 (tt see the IP trafc statstcs iio
iraphical mtde).
# lscpgu (tt see the iot. tf CPUs preseiot iio
the system).
# lsgusb (tt see the iot. tf US de ices preseiot iio
the system).
# lsblk (tt see all the partttios tr bltck de ices
iioftrmattio).
# cat /Setc/Sredhat-release (tt see the RHEL
ersitio tf system).
# dmidectde (tt see the ctmplete hardware iioftrmattio
tf the system).

Ratnakar Page 121


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# dmidectde -t memtry (tt see the memtry iioftrmattio tf


the system).
# dmidectde -t bits (tt see the system's bits
iioftrmattio).
# dmidectde -t system (tt see the
system's iioftrmattio).
# dmidectde -t prtcesstr tt see the prtcesstr's (CPU's). iioftrmattio
tf the system).
# dmidectde -t 1 (tt check the System's Serial
Nt. iioftrmattio).
# dmidectde -t 4 (tt see the prtcesstr's
(CPU's). iioftrmattio).
# dmidectde -t 16 (tt check the MBax. RAMB capacity
tf the system).
# dmidectde -t 17 (tt check htw mguch RAMB the
system is gusiioi).
# pidstat (tt mtioittriioi the iiodi idgual tasks cgurreiotly beiioi maioaied by
the Liiogux kerioel).
# iofsitstat (tt mtioittr the NFS iiopgut aiod
tgutpgut statstcs).
# cifsitstat (tt mtioittr the Samba iiopgut aiod
tgutpgut statstcs).
# stat <fle ioame tr directtry ioame> (tt see the statstcs tf the fle tr
directtry).
# striiois <ctmmaiod ioame> (tt read the biioary laioiguaie tf
the ctmmaiod).
# fiod /S -iotguser -t -iotirtgup (tt see the fles which are iot beltiois tt aioy guser
aiod aioy irtgup).
# systemctl -t help (tt see the list tf systemd tbjects
that are a ailable).
# systemctl -l help (tt see the list
tf guioit ioames).
# systemctl list-depeiodeiocies <ser ice ioame> (tt see the depeiodeiot ser ices iio
a tree maioioer).
# sleep <sectiods>& (tt rguio the sleep prtcesses
at backirtguiod).
# jtbs (tt see the backirtguiod jtbs which were
seiot by the guser).
# fi % < Jtb ID > (tt iet back the backirtguiod jtb tt
ftreirtguiod jtb).

Ratnakar Page 122


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# Ctrl + s (tt
sttp the prtcess).
# bi % < Jtb ID > (tt restart the prtcess aiaiio
at backirtguiod).
* Wheio there are sttpped jtbs aiod waiot tt exit frtm the termiioal theio a warioiioi messaie
will be displayed. If we try aiaiio tt exit frtm the termiioal theio the sttpped tr
sguspeioded jtbs will be killed aguttmatcally.

14. FTP (File Transfer Protocol) Server

1 What is FTP?
FTP staiods ftr File Traiosfer Prtttctl gused tt traiosfer fles frtm tioe htst tt aiotther htst t er
a TCP-based ioetwtrk.
2. How fp works?
FTP is bguilt tio clieiot-ser er architectgure aiod gutlises separate ctiotrtl aiod data ctioioecttio
betweeio the clieiot aiod ser er. FTP gusers may agutheiotcate themsel es gusiioi a clear-text
siiio-iio prtttctl bgut caio ctioioect aiotioymtgusly if the ser er is ctiofigured tt alltw it.
Usgually the FTP ser er which sttres fles tt be traiosferred guses twt ptrts ftr the traiosferriioi
pgurptse. Oioe ptrt ftr ctmmaiods aiod aiotther ptrt ftr seiodiioi aiod recei iioi data. Reqguestioi
frtm clieiot ctmpguters are recei ed at the ptrt 21 tf ser er. ie. it is exclgusi ely reser ed ftr
seiodiioi ctmmaiods thereftre it is called the Ctmmaiod Ptrt.
Oioce aio iioctmiioi reqguest is recei ed the data reqguested tr gupltaded by the clieiot ctmpguter is
traiosferred thrtguih a separate ptrt 22 aiod referred as Data Ptrt. At this ptiiot depeiodiioi tio
the Act e tr Passi e mtde tf the FTP ctioioecttio the ptrt iogumber gused ftr the Data Traiosfer
Varies.
3. What is Active FTP?
Iio Act e FTP ctioioecttio the ctioioecttio is iioitated by the Clieiot aiod the data ctioioecttio is
iioitated by the Ser er. Aiod as the ser er act ely establishes the data ctioioecttio with the
clieiot heioce it is called the Act e FTP. Here the clieiot tpeios gup a ptrt hiiher thaio 1024 aiod it

Ratnakar Page 123


[Pick the date] [LINUX NOTES FOR LEVEL 2]

ctioioects tt the ser er thrtguih ptrt 21. Theio the ser er tpeios its ptrt 20 tt establish a data
ctioioecttio.
4. What is Passive FTP?
Iio Passi e FTP ctioioecttio btth ctmmaiod aiod data ctioioecttios are established by the clieiot.
Iio this the ser er acts as eiotrely passi e that's why it is called the Passi e FTP. Here the ser er
listeios ftr iioctmiioi reqguested ctioioecttios frtm clieiot thrtguih ptrt 21 aiod the clieiot alst
iioitates the data ctioioecttio at ptrt 20.
5. What is the main diference between the Active FTP and Passive FTP?
The maiio difeereioce betweeio the Act e FTP aiod the Passi e FTP is based tio wht iioitates the
data ctioioecttio betweeio the ser er aiod the clieiot. If the data ctioioecttio is iioitated by the
ser er that is called Act e FTP aiod if the data ctioioecttio is iioitated by the clieiot that is
called Passi e FTP.
6. What is the profile for FTP server?
(i). It is gused ftr gupltadiioi aiod dtwioltadiioi the fles aiod directtries caioiott be dtwioltaded.
(ii). The FTP ser er packaieis vsfpd.
(iii). The FTP clieiot packaies are fp aiod lfp.
(i ).The FTP ser er deamtio is vsfpd (Very Secgure FTP deamtio).
( ). The FTP scriptioi fle is /etc/initd/vsfpd
( i).Ptrt iogumbers 20 ftr data ctioioecttio aiod 21 ftr FTP ctmmaiod ctioioecttio.
( ii). The dtcgumeiot rttt ftr FTP is /var/fp
( iii). The FTP htme directtry is /var/fp
(ix). The FTP ctiofigurattio fles are
(a). /Setc/S sfpd/S sfpd.ctiof
(b). /Setc/S sfpd/Sguser_list
(c). /Setc/S sfpd/Sfpguser
(d). /Setc/Spam.d/S sfpd
7. How to configure the FTP server?
(i). Iiostall the FTP packaie by # yum install vsfpd* -y ctmmaiod.
(ii). Gttt FTP dtcgumeiot rttt directtry aiod create stme fles by # cd /var/fp/pub
# touch f(1..10}
(iii). Restart the FTP ser ice tr deamtio by # service vsfpd restart ctmmaiod iio RHEL - 6.
# systemctl restart vsfpd ctmmaiod iio RHEL - 7.
(i ). MBake the FTP ser ice tr deamtio eioable e eio afer rebttt the ser er by
# chkconfig vsfpd on ctmmaiod iio RHEL - 6 aiod # systemctl enable vsfpd ctmmaiod
iio RHEL - 7.
( ). Add the FTP ser ice tt the IP tables (RHEL - 6). aiod Firewalld (RHEL - 7)..
RHEL - 6 :
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --deport 21 -j ACCEPT
# iptables -A OUTPUT -m state --state NEW -m tcp -p tcp --deport 21 -j
ACCEPT

Ratnakar Page 124


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# iptables -A INPUT -m state --state NEW -m tcp -p tcp --deport 20 -j ACCEPT


# iptables -A OUTPUT -m state --state NEW -m tcp -p tcp --deport 20 -j
ACCEPT
RHEL - 7 :
# firewall-cmd --permanent -add-service=fp ctmmaiod iio RHEL - 7.
# firewall-cmd --complete-reload ctmmaiod iio RHEL - 7.
8. How to configure the FTP client and how to connect the fp server?
(i). Gt tt the clieiot machiioe aiod iiostall the FTP aiod Lfp packaies.
# yum install fp* lfp* -y
(ii). Ctioioect the FTP ser er frtm clieiot.
# fp <FTP server IP address or server host name>
Example : # fp 172.25.9.11 tr fp:/S/Sser er.example.ctm
Userioame : fp
Passwtrd : <press eioter key>
fp > ls (tt see the fles iio the FTP dtcgumeiot rttt directtry).
(iii).We caio alst ctioioect the FTP ser er thrtguih brtwser.
(i). Opeio the web brtwser aiod type iio address bar as
fp:/S/S172.25.9.11 tr fp:/S/Sser er.example.ctm
9. How to configure the Secure FTP server?
(i). Opeio the FTP ctiofigurattio fle by # vim /etc/vsfpd/vsfpd.conf ctmmaiod.
(ii). Gt tt liioe iot : 12 aiod type as ananymous_enable=no (sa e aiod exit the fle).
* aioaioymtgus_eioable=yes (by defagult).
It meaios aioybtdy caio ltiiio tt the FTP ser er withtgut aioy guserioame aiod passwtrd.
If aioaioymtgus_eioable=iot theio we mgust prt ide the guserioame aiod passwtrds wheio it
prtmpts.
(iii). Restart the fp deamtio by # service vsfpd restart ctmmaiod iio RHEL - 6 tr
# systemctl restart vsfpd ctmmaiod iio RHEL - 7.
(i ). Assiiio the FTP guser passwtrd by # passwd fp (type aiod retype the fp guser
passwtrd).
( ). Gt tt clieiot side aiod ctioioect the FTP ser er by # fp 172.25.9.11 ctmmaiod.
10. How to configure the FTP server to upload the files feature?
(i). Opeio the FTP ctiofigurattio fle by # vim /etc/vsfpd/vdfpd.conf ctmmaiod.
(ii). Gt tt liioe iot : 19 aiod type as writable_enable=yes
(iii). Gt tt liioe iot : 29 aiod type as anon_upload_enable=yes (sa e aiod exit the
fle).
(i ). MBake the uploaddirecttry iio /var/fp/pub directtry by # mkdir /var/fp/pub/upload
( ). Chaioie the irtgup tf the gupltad directtry as fp by # chgrp fp upload ctmmaiod.
( i). Chaioie the permissitios tf the gupltad directtry by # chmod 775 upload ctmmaiod.
( ii). Tt permaioeiotly add the fp ser ice tt SELiiogux ptlicy by

Ratnakar Page 125


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# getsebool -a | grep fp (tt check the SELiiogux ttleaios ftr


FTP ser ice).
# setsebool -p allow_fpd_anon_write on
# chcon -t public_content_rw_t upload (tt add read-write ctiotext tf the
gupltad directtry).
# setsebool -p fp --full-access=1 ctmmaiod tr # setenforce=0 ctmmaiod tt
disable the SELiiogux.
( iii). Restart the fp deamtio by # service vsfpd restart ctmmaiod iio RHEL - 6 tr
# systemctl restart vsfpd ctmmaiod iio RHEL - 7.
11. How to deny the particular system to use the FTP server?
(i). Opeio the /etc/hosts.deny fle aiod pgut aio eiotry tf system which tioe tt deioy the fp
ser ice.
# vim /etc/hosts.deny (ittt last liioe aiod type as beltw).
vsfpd : 172.25.9.10 (tt deioy 172.25.9.10 system).
vsfpd : ALL (tt deioy all the systems).
vsfpd : ALL EXCEPT *.example.com (tt deioy all the systems except example.ctm
dtmaiio systems).
(sa e aiod exit the fle).
(ii). Restart the fp deamtio by # service vsfpd restart ctmmaiod iio RHEL - 6 tr
# systemctl restart vsfpd ctmmaiod iio RHEL - 7.
* Ntw 172.25.9.10 system will iott access the FTP ser ices.
* If we pgut aio eiotry iio /etc/hosts.allow fle as ALLOW ALL EXCEPT 172.25.5.10 theio
except 172.25.5.10 system all the systems caio a ail the FTP ser ice.
12. How to change the ownership of the uploaded file in FTP?
If we gupltad tr dtwioltad aioy fles the fles twioer aiod irtgup are fp tioly. We caio chaioie
the twioership tf the gupltaded tr dtwioltaded fles as ftlltws.
(i). Opeio the FTP ctiofigurattio fle by # vim /etc/vsfpd/vsfpd.conf ctmmaiod.
(ii). Gt tt liioe iot : 48 aiod type as chown_upload=yes
(iii). Gt tt liioe iot : 49 aiod type as chown_username=<user name>
(i ). We caio display the baioioer wheio we ctioioect the FTP ser er by guioctmmeiot tio liioe iot : 86
aiod type as fp_banner=" Welcome to Hyderabad "
( ). We caio limit the FTP maximgum ctioioecttios at a tme tt 5 by pgut aio eiotry iio
ctiofigurattio fle as
max_clients=5 (sa e aiod exit the fle).
( ). Restart the fp deamtio by # service vsfpd restart ctmmaiod iio RHEL - 6 tr
# systemctl restart vsfpd ctmmaiod iio RHEL - 7.
13. How to deny specific users to access the fp services?
(i). Opeio the FTP gusers fle by # vim /etc/vsfpd/fpusers ctmmaiod.
(ii). Eioter the guser ioames whtm tt deioy FTP ser ices. Ftr example as ftlltws
rttt

Ratnakar Page 126


[Pick the date] [LINUX NOTES FOR LEVEL 2]

rajgu
jguioiogu (sa e aiod exit the fle).
(iii). Restart the fp deamtio by # service vsfpd restart ctmmaiod iio RHEL - 6 tr
# systemctl restart vsfpd ctmmaiod iio RHEL - 7.
14. What is LFTP and how to configure LFTP?
LFTP is alst gused tt gupltad tr dtwioltad the fles. gut by gusiioi LFTP we caio ltiiio tt the FTP
ser er withtgut passwtrd becaguse It will iott ask aioy passwtrds. Tt guse LFTP we ha e tt iiostall
the LFTP packaie tio ser er.
(i). Iiostall the LFTP packaie by # yum install lfp* -y ctmmaiod.
(ii). Restart the lfp deamtio by # service lfpd restart ctmmaiod iio RHEL - 6 tr
# systemctl restart lfpd ctmmaiod iio RHEL - 7.
(iii). Gt tt clieiot system aiod access the LFTP ser er by
# lfp 172.25.9.11 (tt ctioioect the LFTP ser er).
lfp> cd pgub (tt mt e tt the pgub directtry).
lfp> iet f1 (tt dtwioltad the f1 fle).
lfp> miet f2 f3 f4 f5 (tt dtwioltad the f2 f3 f4 aiod f5 mgultple fles at a tme).
lfp> pgut f9 (tt gupltad the f9 fle).
lfp> mpgut f10 f11 f12 (tt gupltad the f10 f11 f12 mgultple fles at a tme).
lfp> qguit (tt qguit the fp ser er).
* Iio LFTP " Tab " key wtrks as gusgual bgut iio FTP " Tab " will iott wtrk.
15. How to allow the root user to access the FTP server?
y defagult rttt guser is bltcked tt access the FTP ser er. Tt alltw the rttt guser tt access the
FTP ser er ftlltw the beltw steps.
(i). Opeio the /etc/vsfpd/user_list fle by # vim /etc/vsfpd/user_list ctmmaiod.
(ii). Gt tt rttt guser liioe aiod ctmmeiot tio that liioe. Ftr example # root (sa e aiod
exit the fle).
(iii). Opeio the /etc/vsfpd/fpuser fle by # vim /etc/vsfpd/fpuser ctmmaiod.
(i ). Gt tt rttt guser liioe aiod ctmmeiot tio that liioe. Ftr example # root (sa e aiod
exit the fle).
( ). Restart the fp deamtio by # service vsfpd restart ctmmaiod iio RHEL - 6 tr
# systemctl restart vsfpd ctmmaiod iio RHEL - 7.
* E eio thtguih we chaioied the abt e the rttt guser caioiott access the FTP ser er becaguse
the htme directtry ctiotext is iott added. we caio stl e this as ftlltws.
( i). # getsebool -a | grep fp (tt check the SELiiogux ttleaio tf the rttt
htme directtry).
( ii). # setsebool -p fp_home_dir on (tt chaioie the ttleaio tf the rttt
htme directtry).
* Ntw it tt clieiot system aiod try tt ltiiio the FTP ser er as rttt guser. Here we caio access the
FTP ser er.
16. What are the diference between FTP and LFTP servers?

Ratnakar Page 127


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i).The guser ioame aiod passwtrd are reqguired tt access the FTP ser er bgut LFTP dtes iott
reqguires passwtrds.
(ii). Iio fp>prtmpt the " Tab " key will iott wtrk bgut iio lfp> prtmpt the " Tab " key will
wtrk as gusgual.
Other useful FTP Commands :
# fp 172.25.9.11 (tt access the FTP ser er prt ide FTP guser ioame
aiod passwtrd).
fp > ls (tt see all the fles aiod directtries iio FTP
rttt directtry).
fp > !ls (tt see the ltcal iotthiioi preseiot wtrkiioi
directtry fles).
fp > pwd (tt see the FTP preseiot wtrkiioi directtry).
fp > !pwd (tt see the ltcal fle system's preseiot
wtrkiioi directtry).
fp > iet <fle ioame> (tt dtwioltad the specifed fle).
fp > miet <fle 1><fle 2><fle3> (tt dtwioltad mgultple fles at a tme).
fp > cd /S ar/Sfp/Spgub/Sgupltad (tt mt e tt gupltad directtry).
fp > pgut <fle ioame> (tt gupltad the specifed fle iiott the FTP
gupltad directtry).
fp > lcd /Srttt/SDtwioltads (tt chaioie tt the ltcal /Srttt/SDtwioltad
directtry).
fp > help (tt iet the help abtgut FTP ctmmaiods).
fp > bye tr qguit (tt qguit tr exit frtm the FTP ser er).
# lfp 172.25.9.11 (tt access the LFTP ser er withtgut askiioi
aioy passwtrds).

15. NFS (Network File System) Server and Autofs

1. What is NFS? Explain it.


NFS staiods ftr Netwtrk File system aiod it is way tt share the ltcal hard dri e fles betweeio
machiioes which are NFS ctmpatble. That meaios we share the fles betweeio Liiogux aiod Uioix
machiioes bgut iott betweeio Liiogux aiod wiiodtws systems. NFS is gused gupd prtttctl.
Ntrmally the NFS ser er exptrts tioe tr mtre directtries tt the clieiot system aiod the clieiot
system mtguiot tioe tr mtre tf the shared directtries called mtguiot ptiiots. Afer the NFS is
mtguioted all I/SO tperattios are writteio back tt the ser er aiod all the clieiots iottce the
chaioie. A maiogual refresh is iott ioeeded becaguse the clieiot access the remtte fle systems
same as ltcal fle system becaguse access dtes iott reqguires the IP address guser ioame aiod
passwtrd. Htwe er we caio prt ide the secgurity gusiioi the kerberts secgurity.
2. What are the disadvantages of NFS?

Ratnakar Page 128


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i). NFS dtes iott sgupptrt crtss plat ftrms. ie. it will iott sgupptrt the shariioi the fles betweeio
Liiogux aiod Wiiodtws systems.
(ii). NFS dtes iott sgupptrt eiocrypttio tf the data aiod it sgupptrts tioly plaiio text ftrmat.
(iii). NFS dtes iott sgupptrt TCP Wrappers ie. NFS dtes iott sgupptrt /etc/hosts.allow and
/etc/hosts.deny becaguse there is iot libwrap.so mtdgule is iott ltaded with NFS ser ice.
(i ). NFS dtes iott sgupptrt agutheiotcattio. St tt t erctme this prtblem kerberts secgurity
system is gused.
3. What is the profile of NFS?
Packaie : iofs*
Ser ices : iofs (iio RHEL - 6).
iofs-ser er iofs-secgure-ser er (iofs with kerberts). (btth ftr
NFS ser er).
iofs-secgure (ftr NFS clieiot). (these three ser ices are iio
RHEL - 7).
Script : /Setc/Siioit.d/Siofs
Ptrt iogumbers : 2049 (ftr NFS ser er). aiod beltw 1024 (ftr NFS clieiot).
Ctiofigurattio Files : /Setc/Sexptrts aiod /Setc/Ssysctiofi/Siofs
Other Imptrtaiot Files : /S ar/Slib/Siofs/Setab aiod /S ar/Slib/Siofs/Srmtab
Versitios : NFS - 3 (defagult iio RHEL - 5). bgut it sgupptrts NFS - 4
NFS - 4 (defagult iio RHEL - 6). bgut It alst sgupptrts NFS - 3
NFS - 4 (defagult iio RHEL - 7). bgut it alst sgupptrts NFS - 3
Prtttctl : gudp prtttctl
4. What are the background deamons for NFS and explain them?
There are 6 backirtguiod deamtios ftr NFS.
(i). rpc . mountd :
This deamtio is resptiosible ftr execgutioi mtguiot aiod guiomtguiot reqguests by the clieiot.
(ii). rpc . nfsd :
This deamtio resptiods tt clieiots reqguests ftr fle access.
(iii). rpc . rquotad :
This deamtio is resptiosible ftr eioabliioi qguttas tio NFS shared de ices.
(i ). rpc . statd :
This deamtio is gused tt see the statstcs abtgut NFS ser er frtm NFS clieiot wheio
execgutioi the ctmmaiods # netstat or # nfsstat (tt see the I/SO statstcs tf NFS).

( ). rpc . lockd :
This deamtio maioaies fle ltcks aiod releases iiocase tf clieiot disctioioected.
( i). rpc . idmapd :
This deamtio is resptiosible ftr mappiioi guser id aiod irtgup id ttwards themsel es.
5. What are the diference between NFS 3 and NFS 4?

Ratnakar Page 129


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Iio NFS 3 there is iot secgurity tt prttect the data bgut iio NFS 4 there is a kerberts secgurity tt
prttect the data.
Iio NFS 3 there is iot ACL permissitios tio the shared directtry bgut iio NFS 4 there is aio ACL
permissitios tio the shared directtry.
6. In how many ways we can mount the NFS shared directory?
Iio trder tt access the NFS shared data we ha e tt mtguiot that shared directtry tio ltcal mtguiot
ptiiot. The mtguiotioi caio be direct mtguiot (maiogual mtguiot). aiod iiodirect mtguiot (agutt mtguiot)..
Direct mount :
First create the ltcal mtguiot ptiiot aiod theio mtguiot that shared NFS directtry tio tgur ltcal
systems mtguiot ptiiot by # mount <server host name or IP address> : <shared directory
with full path><mount point> ctmmaiod. gut this is temptrary mtguiot aiod we caio mtguiot it
permaioeiotly by pgut aio eiotry iio /etc/fstab fle.
Example :
# mtguiot 172.25.9.11:/Sprtdguct /Smiot/Siofs (tt mtguiot the directtry /Sprtdguct tio /Siofs
mtguiot ptiiot temptrarily).
# im /Setc/Sfstab (tpeio this fle aiod pgut aio eiotry tf mtguiot ptiiot tt
mtguiot permaioeiotly).
172.25.9.11:/Sprtdguct /Smiot/Siofs iofs defagults 0 0 (sa e aiod
exit this fle).
Indirect mount :
This methtd is gused tt mtguiot the NFS share by gusiioi the Aguttfs ser ice. Aguttfs guses the
aguttmtguiot daemtio tt maioaie tgur mtguiot ptiiots by tioly mtguiotioi them dyioamically wheio
they are accessed.
Aguttfs ctiosgults the master map ctiofigurattio fle /etc/auto.master tt determiioe which mtguiot
ptiiots are defioed. It theio starts aio aguttmtguiot prtcess with the apprtpriate parameters ftr
each mtguiot ptiiot. Each liioe iio the master map defioes a mtguiot ptiiot aiod a separate map fle that
defioes the fle systems tt be mtguioted guioder this mtguiot ptiiot. Ftr example
the /etc/auto.misc fle miiht defioe mtguiot ptiiots iio the /mnt directtry this relattioship
wtguld be defioed iio the /etc/auto.master fle.
Each eiotry iio auto.master has three felds. The frst feld is the mtguiot ptiiot. The sectiod feld is
the ltcattio tf the map fle aiod the third feld is tpttioal. The third feld caio ctiotaiio iioftrmattio
sguch as a tmetgut algue.
Ftr example tt mtguiot the directtry /product tio the remtte machiioe server9.example.com at
the mtguiot ptiiot /mnt/nfs tio ytgur machiioe add the ftlltwiioi liioe tt auto.master:
/mnt /etc/auto.misc --timeout 60
Next add the ftlltwiioi liioe tt /etc/auto.misc:
nfs -rw server9.example.com:/product
The frst feld iio /etc/auto.misc is the ioame tf the /mnt sgubdirecttry. This sgubdirecttry is
created dyioamically by aguttmtguiot. It shtguld iott actgually exist tio the clieiot machiioe. The sectiod

Ratnakar Page 130


[Pick the date] [LINUX NOTES FOR LEVEL 2]

feld ctiotaiios mtguiot tpttios sguch asrw ftr read aiod write access. The third feld is the ltcattio
tf the NFS exptrt iioclgudiioi the htstioame aiod directtry.
The directtry /Smiot mgust be exits tio the ltcal fle system. There shtguld be iot sgub directtries tio
the ltcal fle system.
Tt start the aguttfs ser ice at a shell prtmpt type the ftlltwiioi ctmmaiod:
# servive autofs restart
Tt iew the act e mtguiot ptiiots type the ftlltwiioi ctmmaiod at a shell prtmpt:
# service autofs status
If ytgu mtdify the /etc/auto.master ctiofigurattio fle while aguttfs is rguioioiioi ytgu mgust tell the
aguttmtguiot daemtio(s). tt reltad by typiioi the ftlltwiioi ctmmaiod at a shell prtmpt:
# service autofs reload
7. How to configure NFS server?
(i). First iiostall the NFS packaie by # yum install nfs* -y ctmmaiod.
(ii). Create the NFS shared directtry tio ser er system by # mkdir /public ctmmaiod.
(iii). MBtdify the permissitios tf the /Spgublic directtry by # chmod 777 /public ctmmaiod.
(These permissitios may
be chaioied depeiod tio it's reqguiremeiot).
(i ). MBtdify the SELiiogux ctiotext tf the /Spgublic directtry if SELiiogux is eioabled by execgutioi the
beltw ctmmaiod. # chcon -t public_content_t /public
( ). create stme fles iio the /Spgublic directtry by # touch f{1..10} ctmmaiod.
( i). Opeio the fle NFS ctiofigurattio fle aiod pgut aio eiotry tf the NFS shared iioftrmattio by #
vim /etc/exports ctmmaiod aiod type as aio eiotry like <shared directory name> <to whom
to export the shared directory> (<permissions>, sync)
Ftr example
# im /Setc/Sexptrts
/Spgublic *.example.ctm (rt/Srw syioc). (sa e
aiod exit the fle).
* Where *.example.ctm meaios the shared directtry caio be exptrted tt all the systems
tf the example.ctm dtmaiio.
* Permissitios like rt (read tioly). tr rw (read & write). aiod syioc meaios the data will
always be syioced.
/Spgublic deskttp9.example.ctm (rw syioc). (tt exptrt the /Spgublic tt deskttp 5
system tioly).
/Spgublic *.example.ctm (rt syioc). (exptrt tt the eiotre example.ctm
dtmaiio with read tioly).
/Spgublic 172.25.0.0/S24 (rw syioc). (exptrt tt 172.25.0.0 ioetwtrk tioly with
read aiod write).
/Spgublic ser er [ 0 - 20 ].example.ctm (rw syioc). (exptrt tt ser er0 tt
ser er20 iio
example.ctm dtmaiio with read aiod write).

Ratnakar Page 131


[Pick the date] [LINUX NOTES FOR LEVEL 2]

/Spgublic 172.25.0.10 (rw syioc). (exptrt tt 172.25.0.10 ioetwtrk tioly with


read aiod write).
Common Mount permission options :

rw read/Swrite permissitios
rt read-tioly permissitios
iiosecgure Alltws the guse tf ptrts t er 1024
Specifes that all chaioies mgust be writteio tt disk beftre a
syioc
ctmmaiod ctmpletes
iot_wdelay Ftrces the writioi tf chaioies immediately
rttt_sqguash Pre eiots rttt gusers

( ii). Exptrt the abt e shared directtry tt the defioed clieiot systems by # exportfs -rv
ctmmaiod.
( iii). Restart the NFS ser ices by ftlltwiioi the ctmmaiods iio RHEL - 6 aiod RHEL - 7.
# service rpcbind restart (tt restart the rpcbiiod
ser ice iio RHEL - 6).
# service nfs restart (tt restart the NFS
ser ice iio RHEL - 6).
# systemctl restart nfs-server (tt restart the NFS ser ice iio
RHEL - 7).
(ix). MBake the NFS ser ice permaioeiotly bttt at ioext bttt tme tiowards as ftlltws.
# chkconfig rpcbind on (tt tio the rpcbiiod
ser ice iio RHEL - 6).
# chkconfig nfs on (tt tio the iofs
ser ice iio RHEL - 6).
# systemctl enable nfs-server (tt eioable the iofs-
ser er iio RHEL - 7).
(x). Exptrt the NFS shared directtry as ftlltws.
# exportfs -rv
(xi). Eioable the NFS ser ice tt the IP tables aiod Firewall iio RHEL - 6 aiod RHEL - 7 as ftlltws.
In RHEL - 6 :
(i). # setgup
(a). Select Firewall Ctiofigurattio.
(b). Select Cgusttmise ( MBake sgure frewall tpttio remaiio selected )..
(c). Select NFS4 ( by pressiioi spacebar tioce )..
(d). Select Ftrward aiod press Eioter.
(e). Select eth0 aiod Select Cltse bgutttio aiod press Eioter.
(f). Select tk aiod press Eioter.

Ratnakar Page 132


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i). Select Yes aiod press Eioter.


(h). Select Qguit aiod press Eioter.
(ii). Ntw tpeio/etc/sysconfig/iptables fle aiod add the ftlltwiioi rgules guioder the rgule ftr ptrt
2049 aiod sa e fle.
-A INPUT -m state --state NEW -m gudp -p gudp --dptrt 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dptrt 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dptrt 32803 -j ACCEPT
-A INPUT -m state --state NEW -m gudp -p gudp --dptrt 32769 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dptrt 892 -j ACCEPT
-A INPUT -m state --state NEW -m gudp -p gudp --dptrt 892 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dptrt 875 -j ACCEPT
-A INPUT -m state --state NEW -m gudp -p gudp --dptrt 875 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dptrt 662 -j ACCEPT
-A INPUT -m state --state NEW -m gudp -p gudp --dptrt 662 -j ACCEPT
(iii). Restart the IP tables ser ice by # service iptables restart ctmmaiod.
(i ). MBake the IP tables ser ice as permaioeiot frtm ioext bttt tiowards as ftlltws.
# chkctiofi iptables tio
The following commands could be helpful for troubleshooting :

# mountstats Shows information about mounted NFS shares


# nfsstat Shows statistics of exported resources
# nfsiostat Shows statistics of NFS mounted shares

In RHEL - 7 :
# frewall-cmd --permaioeiot -add-ser ice=iofs (tt eioable the iofs ser ice
at frewall).
# frewall-cmd --permaioeiot -add-ser ice=mtguiotd (tt eioable the mtguiotd
ser ice at frewall).
# frewall-cmd --permaioeiot -add-ser ice=rpc-biiod (tt eioable the rpc-biiod
ser ice at frewall).
# frewall-cmd --ctmplete-reltad (tt reltad the frewall).
8. What are requirements for NFS client?
(i). NFS ser er IP address tr htstioame.
(ii). Check the NFS shared ioame.
(iii). Create the ltcal mtguiot ptiiot.
(i ). MBtguiot the NFS shared ioame tio the ltcal mtguiot ptiiot.
( ). Gt tt mtguiot ptiiot (ltcal mtguiot ptiiot). aiod access the NFS shared data.
9. How to access the NFS shared directory from the client?
(i). Oio Clieiot system iiostall the nfs-utils packaie by # yum install nfs-utils* -y
ctmmaiod.

Ratnakar Page 133


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). Check the exptrted NFS shared directtry by # showmount -e <IP address or
hostname of the server>
Example : # shtwmtguiot -e 172.25.9.11 tr # shtwmtguiot -e ser er9.example.ctm
(iii).Create tioe mtguiot ptiiot tt mtguiot the NFS shared directtry by # mkdir /<mount point>
ctmmaiod.
Example : # mkdir /Smiot/Siofs
(i ). MBtguiot the NFS shared directtry tio the abt e created mtguiot ptiiot.
# mount <IP address or server hostname> : <NFS shared directory><mount point>
Example : # mtguiot 172.25.9.11:/Spgublic /Smiot/Siofs tr
# mtguiot ser er9.example.ctm:/Spgublic /Smiot/Siofs
* These are temptrary mtguiot tioly. ie. If the system is rebttted these are guiomtguioted
aguttmatcally aiod we ha e tt mtguiot aiaiio afer the system is rebttted.
( ). St if we waiot tt mtguiot it permaioeiotly theio tpeio /etc/fstab fle aiod pgut aio eiotry tf the
mtguiot ptiiot.
# vim /etc/fstab (tt tpeio the fle).
<IP address or server hostname> : <shared name><mount point><file system> defaults
0 0
Example : 172.25.9.11:/Spgublic /Smiot/Siofs iofs defagults 0 0 ( tr ).
ser er9.example.ctm:/Spgublic /Smiot/Siofs iofs defagults 0 0 (sa e
aiod exit the fle).
( i). MBtguiot all the mtguiot ptiiots as meiottioed iio the abt e /Setc/Sfstab fle by # mount -a
ctmmaiod.
( ii). # df -hT ctmmaiod is gused tt check all the mtguioted partttios with fle system types.
10. Why root user cannot create the files in the NFS shared directory and how to make him to
create the files?
The rttt guser iotrmally has all the permissitios bgut iio NFS rttt guser is alst bectmes as a
iotrmal guser. St the rttt guser ha iioi iot permissitios tt create the fles tio the NFS shared
directtry.
The rttt guser bectmes as nfsnobodyguser aiod irtgup alst nfsnobody dgue tt root_squash
permissitio is there by defagult. St if we waiot tt make the rttt guser tt create fle tio the NFS
shared directtry theio it tt ser er side aiod tpeio the /etc/exports fle aiod type as beltw
<shared name> <domain name or systems names>(permissions, sync, no_root_squash)
Example : /public *.example.com(rw, sync, no_root_squash) (sa e
aiod exit the fle).
# exptrts -r (tt exptrt the shared directtry).
# ser ice iofs restart (tt restart the NFS ser ice iio RHEL - 6).
# systemctl restart iofs-ser er (tt restart the NFS ser ice iio RHEL - 7).
11. What are the disadvantages of the direct or manual mounting?
(i). MBaiogual mtguiotioi meaios we ha e tt mtguiot maiogually st it creates st maioy prtblems. Ftr
example if NFS ser ice is iott a ailable theio # df -hT ctmmaiod will haioi.

Ratnakar Page 134


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). If the NFS ser er is dtwio while btttioi the clieiot the clieiot will iott bttt becaguse it
searches ftr NFS mtguiot ptiiot as aio eiotry iio /etc/fstab fle.
(iii). Aiotther disad aiotaie tf maiogual mtguiotioi is it ctiosgumes mtre memtry aiod CPU
restgurces tio the clieiot system.
St tt t erctme the abt e prtblems iotrmally iiodirect tr aguttmtguiot is gused gusiioi Aguttfs
tttl.
12. What is secure NFS server and explain it?
Secgure NFS ser er meaios NFS server with Kerberos security. It is gused tt prttect the NFS
exptrts. Kerbebtrs is a agutheiotcattio tttl tt prttect the NFS ser er shares. It guses the krb5p
methtd tt prttect by agutheiotcattio mechaioism aiod eiocrypt the data while ctmmguioicattio.
Ftr this tioe key fle is reqguired aiod this shtguld be sttred iio each aiod e ery clieiot which are
accessiioi the iofs secgure directtry. Theio tioly Kerberts secgurity will be a ailable. This key fle
shtguld be sttred iio /Setc/Skrb5.keytab fle. Ftr example the ftlltwiioi ctmmaiod will dtwioltad
aiod sttre the keytab.
# wiet http:/S/Sclassrttm.example.ctm/Spgub/Skeytabs/Sser er9.keytab -O /Setc/Skrb5.keytab
(where O is capital).
13. How to configure the secure NFS server?
(i). Iiostall the NFS packaie.
# yum install nfs* -y
(ii). Create a directtry tt share thrtguih NFS ser er.
# mkdir /securenfs
(iii).MBtdify the permissitios tf shared directtry.
# chmod 777 /securenfs
(i ).Chaioie the SELiiogux ctiotext tf the directtry if the SELiiogux is eioabled.
# chcon -t public_content_t /securenfs
( ). Opeio the NFS ctiofigurattio fle aiod pgut aio eiotry tf the shared directtry.
# vim /etc/exports
/Ssecgureiofs *.example.ctm(rw sec=krb5p). (sa e
aiod exit the fle).
( i).Dtwioltad the keytab aiod sttre it iio /etc/krb5.keytb fle.
# wget htp://classroom.example.com/pub/keytabs/server9.keytab -O
/etc/krb5.keytab
( ii).Exptrt the shared the directtry.
# exportfs -rv
( iii). Restart aiod eioable the NFS ser ices iio RHEL - 6 aiod RHEL - 7.
# service nfs restart (restart the NFS
ser ice iio RHEL - 6).
# service nfs-secure-server restart (restart the secgure NFS ser ice iio
RHEL - 6).

Ratnakar Page 135


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# chkconfig nfs on (eioable the NFS


ser ice iio RHEL - 6).
# systemctl restart nfs-server (restart the NFS
ser ice iio RHEL - 7).
# systemctl restart nfs-secure-server (restart the secgure NFS ser ice iio
RHEL - 7).
(ix). Eioable the IPtables tr frewall tt alltw NFS ser iceiio RHEL - 6 aiod RHEL - 7 as ftlltws.
In RHEL - 6 :
(i). # setgup
(a). Select Firewall Ctiofigurattio.
(b). Select Cgusttmise ( MBake sgure frewall tpttio remaiio selected )..
(c). Select NFS4 ( by pressiioi spacebar tioce )..
(d). Select Ftrward aiod press Eioter.
(e). Select eth0 aiod Select Cltse bgutttio aiod press Eioter.
(f). Select tk aiod press Eioter.
(i). Select Yes aiod press Eioter.
(h). Select Qguit aiod press Eioter.
(ii). Ntw tpeio /etc/sysconfig/iptables fle aiod add the ftlltwiioi rgules guioder the rgule ftr
ptrt 2049 aiod sa e fle.
-A INPUT -m state --state NEW -m gudp -p gudp --dptrt 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dptrt 111 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dptrt 32803 -j ACCEPT
-A INPUT -m state --state NEW -m gudp -p gudp --dptrt 32769 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dptrt 892 -j ACCEPT
-A INPUT -m state --state NEW -m gudp -p gudp --dptrt 892 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dptrt 875 -j ACCEPT
-A INPUT -m state --state NEW -m gudp -p gudp --dptrt 875 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dptrt 662 -j ACCEPT
-A INPUT -m state --state NEW -m gudp -p gudp --dptrt 662 -j ACCEPT
(iii). Restart the IP tables ser ice by # service iptables restart ctmmaiod.
(i ). MBake the IP tables ser ice as permaioeiot frtm ioext bttt tiowards as ftlltws.
# chkctiofi iptables tio
In RHEL - 7 :
# frewall-cmd --permaioeiot -add-ser ice=iofs (tt eioable the iofs ser ice
at frewall).
# frewall-cmd --permaioeiot -add-ser ice=mtguiotd (tt eioable the mtguiotd
ser ice at frewall).
# frewall-cmd --permaioeiot -add-ser ice=rpc-biiod (tt eioable the rpc-biiod
ser ice at frewall).
# frewall-cmd --ctmplete-reltad (tt reltad the frewall).

Ratnakar Page 136


[Pick the date] [LINUX NOTES FOR LEVEL 2]

14. How to access the secure NFS server on client side?


(i). Iiostall the iofs-gutls packaie.
# yum install nfs-utils* -y
(ii). Dtwioltad the same keytab aiod sttre it iio /etc/krb5.keytab fle.
# wget htp://classroom.example.com/pub/keytabs/desktop9.keytab -O
/etc/krb5.keytab
(iii). Check the shared NFS directtry.
# showmount -e server9.example.com
(i ). Restart the secgure NFS ser ice tio clieiot side.
# service nfs-secure restart (restart the secgure NFS clieiot
ser ice iio RHEL - 6).
# systemctl restart nfs-secure (restart the secgure NFS clieiot
ser ice iio RHEL - 7).
( ). Create the mtguiot ptiiot tio clieiot system.
# mkdir /mnt/nfssecure
( i). MBtguiot the NFS shared directtry tio the ltcal mtguiot ptiiot temptrarily.
# mount server9.example.com:/securenfs /mnt/nfssecure
( ii). Opeio /Setc/Sfstab fle aiod pgut aio eiotry tf the NFS shared mtguiotioi details tt mtguiot it
permaioeiotly.
# vim /etc/fstab
ser er9.example.ctm:/Ssecgureiofs /Smiot/Siofssecgure iofs defagults sec=krb5p 0 0
(sa e aiod exit the fle).
( iii). MBtguiot all the fle systems which are ha iioi the eiotries tf the /etc/fstab fle.
# mount -a
(ix). Check all the mtguioted fle systems with fle system type tio clieiot system.
# df -hT
15. How to mention the NFS version while configuring?
(i). Opeio /etc/sysconfig/nfs fle by # vim /etc/sysconfig/nfs ctmmaiod.
(ii). Gt tt liioe iot. 13 aiod edit the liioe as beltw
RPCNFSDARGS=" - 4.2 "
(iii). Sa e aiod exit this fle.

16. How to add the LDAP user shared directory and how the LDAP user access that directory on
client?
(i). Create a sgub-directtry iio /Ssecgureiofs directtry.
# mkdir /securenfs/secure
(ii). Chaioie the twioership tf the abt e sgub directtry tt LDAP guser.
# chown ldapuser9 /securenfs/secure
(iii). Assiiio the fgull permissitios tio that directtry tt LDAP guser.
# setfacl -m u : ldapuser9 : rwx /securenfs/secure

Ratnakar Page 137


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i ). Chaioie the SELiiogux ctiotext tf that directtry if SELiiogux is eioabled.


# chcon -t public_content_t /securenfs/secure
( ). Re-exptrt the secgure NFS shared directtry.
# exportfs -rv
( i). Restart the NFS ser ices.
# service nfs restart (restart the NFS
ser ice Iio RHEL - 6).
# service nfs-secure-server restart (restart the secgure NFS
ser ice Iio RHEL - 6).
# systemctl restart nfs (restart the NFS ser ice Iio
RHEL - 7).
# systemctl restart nfs-secure (restart the secgure NFS
ser ice Iio RHEL - 7).
On Client side :
(i). Ltiiio as LDAP guser tio ltcal system thrtguih ssh.
# ssh ldapuser9@localhost (type yes aiod press Eioter if it
asks (yes/Siot).).
(ii). Type the passwtrd as kerberos if it asks the LDAP guser passwtrd.
(iii). Gt tt that secgure NFS shared mtguiot ptiiot aiod access the ctioteiots.
$ cd /mnt/nfssecure (tt access
the mtguiot ptiiot).
$ ls (tt see the
ctioteiots iio that).
$ cd secure (tt access
the sgub directtry).
$ ls (tt see the
ctioteiots iio that).
$ exit (tt exit tr ltitgut
frtm ssh).
17. What are the advantages of NFS?
(i). NFS alltws mgultple ctmpguters caio guse same fles becaguse all the gusers tio the ioetwtrk tr
dtmaiio caio access the same data.
(ii). NFS redguces the sttraie ctsts by shariioi applicattios tio ctmpguters iiostead tf alltcatioi
ltcal disk space ftr each guser applicattio.
(iii). NFS prt ides data ctiosisteiocy aiod reliability becaguse all gusers caio read same set tf fles.
(i ). NFS sgupptrts hetertieioetgus eio irtiomeiots which are ctmpatble tt NFS.
( ). NFS redguces System Admiioistrattio t erhead.
18. Remote user cannot mount the NFS shared directory. How to resolve this?
(i). First check the guser beltiois tt the same dtmaiio as the NFS shared tr iott. ie. the guser's
system dtmaiio aiod NFS shared system dtmaiio shtguld ctmmguioicate.

Ratnakar Page 138


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). Check the guser's system is piioiiioi tr iott.


(iii). Check the guser's ioame is preseiot iott preseiot tr disabled tt access the NFS ser er.
(i ). Check the mtguioted fle system is shared tr iott.
( ). Check all the NFS ser er aiod clieiot deamtios are rguioioiioi tr iott.
( i). Check all the ioetwtrk ctioioecttios are prtperly established tr iott.
( ii). Check whether the NFS ser ice is rguioioiioi tr iott iio ser er's cgurreiot rguio le el.
( iii). Check whether the NFS ser er is rguioioiioi tr hguioi tr shgutdtwio.
(ix). Check btth NFS ser er aiod NFS clieiot systems ioetwtrk rtguters ioetwtrk ctioioecttios
aiod IP addresses.
(x). Check the mtguiot ptiiot is ctrrect tr iott paths are ctrrect tr iott aiod fles are there tr
iott.
(xi). Check the NFS shared directtry aiod mtguiot ptiiot details are ctrrect tr iott iio
/Setc/Sfstab fle.
(xii). Check the keytabs are dtwioltaded aiod sttred prtperly iio /etc/krb5.keytab fle tio btth
NFS ser er aiod clieiot.
(xii). Fiioally check whether the NFS ptrt iot. 2049 is rguioioiioi tr iott aiod make sgure that the IP
tables tr frewall shtguld iott bltck the NFS ser ice.
19. NFS server and NFS client configurations are OK, but at client it is not showing anything.
How to resolve?
(i). The rpcbiiod may be failed.
(ii). The ser er is iott resptiodiioi.
(iii). NFS clieiot may be failed at rebttt.
(i ). The NFS ser ice is iott resptiodiioi.
( ). The deamtios tio btth systems may iott be rguioioiioi.
( i). Netwtrk may be failed tio btth ser er aiod clieiot tr aioy tioe system.
( ii). MBay be ser er aiod clieiot are iott iio the same dtmaiio tr iott piioiiioi.
( iii). The ser er may be iio hguioi tr shgutdtwio state.
20. What is Autofs ?
Aguttfs is ser ice that caio aguttmatcally mtguiot the shared directtry tio demaiod aiod will
aguttmatcally guiomtguiot the shared directtry if it is iott accessed withiio the specifed tmetgut
peritd. The defagult tmetgut peritd is 5 miiogutes tr we caio specify the tmetgut peritd iio
/etc/auto.master fle.
21. What are the advantages of the Autofs?
(i). Shares are accessed aguttmatcally aiod traiospareiotly wheio a guser tries tt access aioy fles tr
directtries guioder the desiiioated mtguiot ptiiot tf the remtte fle system tt be mtguioted.
(ii). tttioi tme is siiioifcaiotly redguced becaguse iot mtguiotioi is dtioe at bttt tme.
(iii). Netwtrk access aiod efcieiocy are imprt ed by redguciioi the iogumber tf permaioeiotly act e
mtguiot ptiiots.
(i ). Failed mtguiot reqguests caio be redguced by desiiioatioi alterioate ser ers as the stgurce tf a
fle system.

Ratnakar Page 139


[Pick the date] [LINUX NOTES FOR LEVEL 2]

( ). Users dt iott ioeed tt ha e rttt pri ileiestt mtguiot tr guiomtguiot the mtguiot ptiiot.
( i). We caio redguce the CPU aiod memtry gutlisattios becaguse aguttfs will iott mtguiot
permaioeiotly.
( ii). We caio alst redguce hard disk gutlisattio becaguse permaioeiot mtguiot ptiiots tccgupies the
hard disk space.
22. What are the minimum requirements for Autofs?
(i). autofs packaie.
(ii). autofs deamtio.
(iii). Oioe shared directtry.
(i ). Oioe mtguiot ptiiot.
( ). Twt ctiofigurattio fles are
(a). /Setc/Sagutt.master
(b). /Setc/Sagutt.misc
23. How to configure Autofs?
(i). Iiostall the aguttfs packaie by # yum install autofs* -y ctmmaiod.
(ii). Opeio /etc/auto.master fle by # vim /etc/auto.master aiod at last type as beltw.
< Client's local mount point> /etc/auto.misc --timeout=60
Example :
/mnt /etc/auto.misc (sa e aiod
exit this fle).
( * Where tmetgut=60 meaios if the directtry is iott gused ftr 60 sectiods theio the shared
directtry is guiomtguioted aguttmatcally. Aiod the defagult is 5 miiogutes.).
(iii). Opeio /etc/auto.misc fle by # vim /etc/auto.misc aiod types as beltw.
< Client temporary mount point >-<permissions><IP address or hostname of the server> :
<shared
name>
Example :
nfs -ro (tr). -rw classroom.example.com:/public (sa e aiod
exit this fle).
( * where -rt meaios read-tioly aiod -rw meaios read-write).
(i ). Restart the aguttfs ser ice iio RHEL -6 aiod RHEL - 7.
# service autofs restart (restart the aguttfs ser ice
iio RHEL - 6).
# chkconfig autofs on (eioable the aguttfs ser ice at ioext bttt
iio RHEL - 6).
# systemctl restart autofs (restart the aguttfs ser ice
iio RHEL - 7).
# systemctl enable autofs (eioable the aguttfs ser ice at ioext bttt
iio RHEL - 7).

Ratnakar Page 140


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i ). Gttt the Clieiot ltcal mtguiot ptiiot which is eiotered iio /et/auto.master fle by # cd
<mount point> ctmmaiod.
Example :
# cd /Smiot
( ). Gttt the Clieiot temptrary mtguiot ptiiot which is eiotered iio /etc/auto.misc fle as beltw.
# cd /mnt/<temporary mount point>
Example :
# cd iofs
# pwd (the tgutpgut
is /Smiot/Siofs).
24. What is LDAP server?
LDAP (Liihtweiiht Directtry Access Prtttctl). is a stfware prtttctl ftr eioabliioi aioytioe tt
ltcate triaioisattios iiodi idguals aiod tther restgurces sguch as fles aiod de ices iio a ioetwtrk
whether tio the pgublic Iioterioet tr tio a ctrptrate iiotraioet.LDAP is liihter becaguse iio its iioital
ersitio it did iott iioclgude secgurity featgures.
25. What is LDAP client?
LDAP Clieiot is a ioetwtrk guser creattio aiod act ity. LDAP guser meaios ioetwtrk guser. Netwtrk
guser meaios ltiiio the guser thrtguih ioetwtrk. If a guser waiots tt ltiiio tt the remtte system the
LDAP guser shtguld be created aiod ltiiio tt the remtte system thrtguih LDAP acctguiot.
Uptt RHEL -5 ftr this NIS (Netwtrk Iioftrmattio System). is gused. Frtm RHEL - 6 tiowards
LDAP is gusiioi. The maiio featgure tf the LDAP is tt share the gusers iioftrmattio iio ioetwtrk.
26. What are the requirements of LDAP and explain it?
(i). Packaies.
(a). aguthctiofi-itk (tt ctiofigure the LDAP clieiot).
(b). sssd (system secgurity ser ice deamtio).
(ii). LDAP clieiot ctiofigurattio fle is /etc/ldap.conf
(iii). LDAP kerberts ctiofigurattio fle is /etc/krb5.conf
(i ). sssd (systems secgurity ser ice deamtio). deamtio.
( ). LDAP ptrt iot. is 389.
( i). sssd deamtio resptiosibility is retrie iioi aiod cachiioi the agutheiotcattio iioftrmattio.
( ii). The ctiofigurattio fle tf sssd is /etc/sssd/sssd.conf
( iii). Thrtguih NIS the data is traiosferred iio plaiio text ftrmat. St there is iot secgurity. gut LDAP
will traiosfer the data iio eiocrypted ftrmat. St the data will be iio secgured way.
(ix). LDAP is gused by defagult sssd ie. kerberts.
27. What are the requirements for LDAP client?
(i). dc (dtmaiio ctiotrtller).
Example : If the dtmaiio is example.ctm theio dc=example dc=ctm
(ii). ldap server
Example : ldap:/S/Sclassrttm.example.ctm

Ratnakar Page 141


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(iii). Authentication certificate (example-ca.crt) is ltcated iio


htp://classroom.example.com/pub directtry.
28. How to configure the LDAP client?
(i). Create the LDAP guser.
(ii). Ctiofigure the kerberts.
(iii). ctiofigure the NFS aguttmtguiot tt share the LDAP guser's htme directtry.
St LDAP + NFS + sssd is the LDAP system.
* LDAP is gused share the guser ioame aiod passwtrd tt remtte system.
* sssd is gused tt agutheiotcate iio secgured ctmmguioicattio.
* NFS is gused tt share the guser's htme directtry tt remtte system.
Steps :
(i). Iiostall the LDAP + kerberts packaies by the ftlltwiioi ctmmaiods.
# yum groupinstall directory* -y (iiostallattio
iio RHEL - 6).
# yum install authconfig-gtk* sssd* -y (iiostallattio
iio RHEL - 7).
* The LDAP packaies are difeereiot iio RHEL - 6 aiod RHEL - 7 bgut the ctiofigurattio tf
LDAP is same iio btth the ersitios.
(ii). Create the LDAP gusers aiod passwtrds iio the LDAP ser er.
(iii). Ctiofigure the LDAP guser's agutheiotcattio by # system_config_authentication ctmmaiod
iio iraphical guser iioterface.
(i ). The abt e ctmmaiod will display the ctiofigurattio wiiodtw aiod iio that select aiod type the
tpttio as beltw.
User Account Database = LDAP
LDAP search base on = dc=example dc=ctm
LDAP server = ldap:/S/Sclassrttm.example.ctm/S
Enable TLS to encrypt = Click tio Download CA Certificate bgutttio aiod theio
eioter the gurl as
http:/S/Sclassrttm.example.ctm:/Spgub/Sexample-ca.crt
Authentication Method = LDAP Passwtrd (theio click
tio Apply bgutttio).
( ). Check whether the LDAP guser is ctiofigured tr iott by # getent password ldapuser9
ctmmaiod.
29. How to mount the LDAP user's home directory automatically when demand using Autofs
tool?
(i). Iiostall the aguttfs packaie by # yum install autofs* -y ctmmaiod.
(ii). Opeio the /Setc/Sagutt.master fle by # vim /etc/auto.master ctmmaiod aiod type as
beltw.
/home/guests /etc/auto.misc (sa e aiod
exit this fle).

Ratnakar Page 142


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(iii). Opeio the /Setc/Sagutt.misc fle by # vim /etc/auto.misc ctmmaiod aiod type as beltw.
ldapuesr9 -rw classrrom.example.com:/home/guests/ldapuser9 (sa e aiod
exit this fle).
(i ).Restart the aguttfs ser ices.
# service autofs restart (restart the aguttfs ser ice iio RHEL
- 6).
# chkconfig autofs on (eioable the aguttfs ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart autofs (restart the aguttfs ser ice iio RHEL
- 7).
# systemctl enable autofs (eioable the aguttfs ser ice at ioext
bttt iio RHEL - 7).

( ). Check whether the LDAP guser is able tt ltiiio tr iott.


# su - ldapuser9 (tt
switch tt ldapguser9).
$ pwd (tt see the preseiot
wtrkiioi directtry).
* The tgutpgut tf the abt e ctmmaiod is /home/guests/ldapuser9
$ ls (tt see the fles iio LDAP guser's
htme directtry).
$ exit (tt exit tr ltitgut tf
the LDAP guser).

Ratnakar Page 143


[Pick the date] [LINUX NOTES FOR LEVEL 2]

16. Samba Server

1. What is Samba and explain it?


(i). Aio tpeio stgurce implemeiotattio tf the SMB fle shariioi prtttctlthat prt ides fle aiod priiot
ser ices tt SMB /SCIFS clieiots. Samba alltws a iotio-Wiiodtws ser er tt
ctmmguioicate with the same ioetwtrkiioi prtttctl as the Wiiodtws prtdgucts.
(ii). Samba alltws Liiogux ctmpguters tt share fles aiod priioters acrtss a ioetwtrk ctioioecttio by
gusiioi SMB prtttctl. Samba will sgupptrt DFS NFS gufs fle systems tt
share fles aiod directtries. That's why Samba is gused tt share fles aiod directtries
betweeio difeereiot plattrms.
(iii). Samba will sgupptrt priioter shariioi aiod it reqguires agutheiotcattio.
2. What are the diferences between Samba and NFS?
(i). Samba sgupptrts tt all O/SS plattrms whereas NFS will sgupptrt the same plattrms tioly.
(ii). There is a secgurity iio Samba becaguse Samba reqguires agutheiotcattio whereas iio NFS
there is iot secgurity if there is iot kerberts becaguse NFS dtes iott reqguires
agutheiotcattio.
(iii).Samba will sgupptrt priioter shariioi whereas NFS will iott sgupptrt priioter shariioi.
3. What are the diferent file systems for sharing diferent O/S?
(i). Wiiodtws --- Wiiodtws -----> Distribguted File system (DFS).

Ratnakar Page 144


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). Liiogux --- Liiogux -----> Netwtrk File system (NFS).


(iii).Uioix --- Uioix -----> Netwtrk File system (NFS).
(i ).Apple MBAC --- Apple MBACs -----> Apple File shariioi Prtttctl (AFP).
( ). Wiiodtws --- Liiogux -----> Ctmmtio Iioterioet File system (CIFS).
4. What are the requirements or what is the profile of Samba?
(i). Packaies : samba* ftr samba ser er aiod samba-clieiot* ftr samba clieiot
(ii). Deamtios : smbd aiod iombd ftr RHEL - 6 where as smbd is ftr Samba ser er
deamtio aiod
iombd is ftr Netbits ser ice deamtio.
smb aiod iomb ftr RHEL - 7 where as smb is ftr Samba ser er
deamtio aiod iomb
is ftr Netbits ser ice deamtio.
(iii).Scriptioi fles : /Setc/Siioit.d/Ssmb aiod /Setc/Siioit.d/Siomb
(i ). Ptrt iogumber : 137 ---> tt erify the share ioame 138 ---> tt data traiosfer
139 ---> tt ctioioecttio establish aiod 445 ---> ftr agutheiotcattio
( ). Lti fle : /S ar/Slti/Ssamba
( i). Ctiofigurattio : /Setc/Ssamba/Ssmb.ctiof
( ii). File systems : CIFS (Ctmmtio Iioterioet File system).
5. How to configure the Samba server?
(i). Iiostall the samba packaie by # yum install samba* -y ctmmaiod.
(ii). Create a samba shared directtry by # mkdir /samba ctmmaiod.
(iii). MBtdify the permissitios tf the abt e samba shared directtry.
# chmod 777 /samba
(i ). MBtdify the SELiiogux ctiotext tf the samba directtry if SELiiogux is eioabled.
# chcon -t samba_share_t /samba
( ). Create the samba guser aiod assiiio the passwtrd ftr the samba guser.
# useradd raju (tt create
the samba guser).
# smbpasswd -a raju (tt assiiio the samba passwtrd ftr
the guser rajgu).
( i). Assiiio the ACL permissitios (like read write aiod execgute). tt the abt e shared directtry
if it is ioecessary.
# setfacl -m u : <user name> : rwx <samba shared name>
Example : # setacl -m gu:rajgu:rwx /Ssamba
( ii). Opeio the samba ctiofigurattio fle aiod pgut aio eiotries tf the Samba ctiofigurattio.
# vim /etc/samba/smb.conf
Gt tt last liioe aiod ctpy the last 7 liioes aiod paste them at last. Aiod theio mtdify as beltw.
[samba] (this is the samba
shared ioame).

Ratnakar Page 145


[Pick the date] [LINUX NOTES FOR LEVEL 2]

ctmmeiot = pgublic stgufe (this is a ctmmeiot


ftr samba).
path = /Ssamba (share directtry
ioame with fgull path). pgublic = yes
(meaios iot agutheiotcattio).
= iot (meaios reqguires
agutheiotcattio).
writable = yes (iio read-write
mtde).
= iot (iio read tioly mtde).
priiotable = iot (priiotioi is iott
a ailable).
= yes (priiotioi is
a ailable).
write list = rajgu (tt ii e the write
permissitio tt guser rajgu).
= + <irtgup ioame> (tt ii e the write
permissitio tt the irtgup).
alid gusers = rajgu gu2 tr @irtgup 1 @irtgup 2 (tt ii e the agutheiotcattio tt the
gusers tr irtgups).
htsts alltw = IP 1 tr IP 2 tr htst 1 tr htst2 tr <htst ioetwtrk ID> tr <htst ioetwtrk
ID> (tt share the
directtry tt IP 1 tr IP 2 tr htst 1 tr htst2).
wtrk irtgup = <wiiodtws wtrk irtgup ioame> (tt share the directtry tt the
wiiodtws wtrk irtgup).
create mask = 644 (the fles created by samba gusers with
644 permissitio).
directtry mask = 744 tr 755 (the directtries created by samba gusers with 744 tr
755 permissitios).
(sa e aiod exit the ctiofigurattio fle).
( iii). Verify the ctiofigurattio fle ftr syiotax errtrs by # testparm ctmmaiod.
(ix). Restart the samba deamtios iio RHEL - 6 aiod RHEL - 7.
# service smbd nmbd restart (tt restart the samba
ser ices iio RHEL - 6).
# chkconfig smbd nmbd on (tt eioable the samba ser ices at ioext
bttt iio RHEL - 6).
# systemctl restart smb nmb (tt restart the samba
ser ices iio RHEL - 7).
# systemctl enable smb nmb (tt eioable the samba ser ices at ioext
bttt iio RHEL - 7).

Ratnakar Page 146


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(x). Add the samba ser ice tt IP tables aiod Firewall.


# setup (theio select Firewall ctiofigurattio tpttio tt add the ser ice tt IP
tables iio RHEL - 6).
# service iptables restart (tt restart the IP
tables iio RHEL - 6).
# firewall-cmd --permanent --add-service=samba (tt add the samba ser ice tt
frewall iio RHEL - 7). # firewall-cmd --complete-reload
(tt reltad the frewall iio RHEL - 7).
6. How to access the samba share directory at client side?
(i). Iiostall clieiot side samba packaies by # yum install samba-client* cifs-utils -y
ctmmaiod.
(ii). Check the samba shared directtry ioames frtm clieiot side.
# smbclient -L //<host name or IP address of the server> (theio it will ask passwtrd
here dtio't eioter aioy passwtrd
becaguse it dtes iott reqguire aioy passwtrd).
Example :# smbclieiot -L /S/Sser er9.example.ctm tr 172.25.9.11
(iii). ctioioect the samba ser er with guser credeiotals aiod access the samba shared directtry.
# smbclient //<host name or IP address of the server>/<shared directory name> -U
<samba user name>(Where U is Capital Letter aiod we ha e tt
eioter the guser's samba passwtrd).
Example : # smbclieiot /S/Sser er9.example.ctm/Ssamba -U rajgu (theio smb :/S>
prtmpt appears).
smb:/S> ls (tt see the ctioteiots tf the samba
shared directtry).
smb:/S> pwd (tt see the preseiot wtrkiioi
directtry).
smb:/S> ! ls (tt see the clieiot's ltcal directtry
ctioteiots).
smb:/S> iet <fle ioame> (tt dtwioltad the specifed fle frtm
samba ser er).
smb:/S> miet <fle 1><fle 2><fle 3><fle4> ... (tt dtwioltad mgultple fles frtm samba
ser er).
smb:/S> pgut <fle ioame> (tt gupltad the specifed fle tt the
samba ser er).
smb:/S> pgut <fle 1><fle 2><fle 3><fle 4> ... (tt gupltad mgultple fles tt the samba
ser er).
smb:/S> exit (tt exit frtm the samba ser er).
7. How to mount the samba shared directory permanently?
(i). Create the mtguiot ptiiot ftr the samba shared directtry.
# mkdir /mnt/samba

Ratnakar Page 147


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). Pgut aio eiotry tf the mtguiot ptiiot details iio /Setc/Sfstab fle.
# vim /etc/fstab
/S/S<samba ser er htst ioame tr IP address>/S<shared directtry ioame><mtguiot ptiiot> cifs
defagults guserioame=<samba guser ioame>
passwtrd=<guser's samba passwtrd> 0 0
Example : /S/Sser er9.example.ctm/Ssamba /Smiot/Ssamba cifs defagults guserioame=rajgu
passwtrd=<samba passwtrd> 0
0 (sa e aiod exit this fle).
(iii). MBtguiot all the mtguiot ptiiots which are ha iioi eiotries iio /Setc/Sfstab fle.
# mount -a
(i ). Check all the mtguiot ptiiots by # df -hT ctmmaiod.
8. How to mount the samba shared directory using credential file?
(i). Create tioe fle aiod pgut aio eiotries tf the guser ioame aiod passwtrd details.
# vim /root/smbuser
guserioame=rajgu
passwtrd=<guser's samba passwtrd> (sa e
aiod exit the fle).
(ii). Opeio /Setc/Sfstab fle aiod pgut aio eiotries tf the abt e credeiotal details tf guser.
# vim /etc/fstab
/S/Sser er9.example.ctm/Ssamba /Smiot/Ssamba cifs credeiotals=/Srttt/Ssmbguser
mgultguser sec=iotlmssp
0 0
(sa e aiod exit this fle).
9. How to access the samba share directory if it already mounted?
(i). Gt tt Clieiot system aiod switch tt samba guser.
# su - raju
$ cd /mnt/samba
$ ls (permissitio deioied messaie will be
displayed).
$ cifscreds add <host name or IP address of the samba server>(tt add cifs credeiotals
tt the ser er).
$ ls (tt see the ctioteiots tf the samba
shared directtry).
10. How to access the samba server from windows system?
(i). Gttt Wiiodtws system click tio START bgutttio click tio Rguio aiod type as
\\172.25.9.11\samba ctmmaiod.
(ii). Theio prt ide samba guser ioame aiod passwtrd if it prtmpts gus.
(iii). Theio see the ctioteiots tf the samba shared directtry.
Other useful commands :

Ratnakar Page 148


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# smbpasswd -a <guser ioame> (tt add the samba passwtrd tt the


samba guser).
# smbpasswd -d <guser ioame> (tt disable the samba guser's
passwtrd).
# smbpasswd -e <guser ioame> (tt eioable the samba guser's
passwtrd).
# smbpasswd -r <guser ioame> (tt remt e the samba
guser's passwtrd).
# smbpasswd -x <guser ioame> (tt delete the samba guser's
passwtrd).
# smbpasswd -io <guser ioame> (tt set the samba guser's
passwtrd as iogull).
# fiodsmb (tt check htw maioy samba ser ers are rguioioiioi
iio tgur ioetwtrk).
# pdbedit (tt check the a ailable samba gusers wht are
accessiioi cgurreiotly).
# smbstatgus (tt check htw maioy smb clieiots are ctioioected tt the
samba ser er).
# mtguiot -t cifs /S/S<htst ioame tr IP address tf the samba ser er>/S<shared
directttry><mtguiot ptiiot> -t
guser=<guser ioame> (tt mtguiot the samba share directtry tio ltcal mtguiot
ptiiot temptrarily).
Example : # mtguiot -t cifs /S/S172.25.9.11/Ssamba /Smiot/Ssamba -t guser=rajgu

Ratnakar Page 149


[Pick the date] [LINUX NOTES FOR LEVEL 2]

17. NTP (Network Time Protocol) or Chrony

1. What is NTP and Chrony?


NTP staiods ftr Netwtrk Time Prtttctl iio RHEL - 6 aiod Chrtioy is alst a Netwtrk Time Prtttctl
iio RHEL - 7. These are gused tt syiochrtioise the tme tio ytgur Liiogux system with a ceiotralised NTP
tr Chrtioy ser er.A ltcal NTP tr Chrtioy ser er tio the ioetwtrk caio be syiochrtioised with aio
exterioal tmiioi stgurce tt keep all the ser ers iio ytgur triaioisattio iio-syioc with aio accgurate tme.
2. What are the diferences between NTP and Chrony?
NTP Chrony
This is gused iio RHEL - 6. This is gused iio RHEL - 7.
Packaie is ntp or system-config-date. Packaie is chrony.
It's deamtio is ntpd aiod Ptrt iogumber is 123. It's deamtio is chronyd aiod Ptrt iogumber is 123.
We ha e tt iiostall the packaie maiogually. y defagult this packaie is iiostalled.
# chronyc sources -v (tt check chrtioy is
# ntpq -p (tt check iotp is ctiofigured tr iott)..
ctiofigured tr iott)..
Ctiofigurattio fle is /etc/ntp.conf Ctiofigurattio fle is /etc/chrony.conf
Lti fle is /var/log/ntpstat Lti fle is /var/log/chrony

3. How to configure the NTP and Chrony client?


NTP :
(i). Iiostall the iotp packaie by # yum install ntp* -y tr # yum install system-config-date*
-y ctmmaiod.
(ii). tpeio the ctiofigurattio fle by # system-config-date or # vim /etc/ntp.conf
ctmmaiod.
(# system-ctiofi-date ctmmaiod is gused tt ctiofigure the NTP iio iraphical mtde).

Ratnakar Page 150


[Pick the date] [LINUX NOTES FOR LEVEL 2]

* MBake a ctmmeiot tio liioe iogumbers 21 22 aiod 23. Theio it tt liioe iogumber 24 aiod type
as beltw.
server <ntp server host name> (sa e aiod
exit this fle).
Example : ser er classrttm.example.ctm
(iii).Restart the iotpd ser ice by # service ntpd restart ctmmaiod.
(i ). Eioable the iotp ser ice at ioext bttt by # chkconfig ntpd on ctmmaiod.
( ). Check whether the NTP is ctiofigured tr iott by # ntpq -p ctmmaiod.
Chrony :
(i). Chrtioy packaie is iott iiostalled becaguse by defagult it is iiostalled. If it iott iiostalled theio
iiostall the packaie by # yum install chrony* -y ctmmaiod.
(ii). Opeio the chrtioy ctiofigurattio fle by # vim /etc/chrony.conf ctmmaiod.
* MBake a ctmmeiot tio liioe iogumbers 3 4 aiod 5. Theio it tt liioe iogumber 6 aiod type as
beltw.
server <ntp server host name> iburst (sa e aiod
exit this fle).
Example : ser er classrttm.example.ctm ibgurst
(iii).Restart the chrtioy ser ice by # systemctl restart chronyd ctmmaiod.
(i ). Eioable the chrtioy ser ice at ioext bttt by # systemctl enable chronyd ctmmaiod.
( ). Check whether the Chrtioy is ctiofigured tr iott by # chronyc sources -v ctmmaiod.
# timedatectl (tt check whether the clieiot's tme is syiochrtioised tt the
ser er's tme).
# timedatectl list-timezones (tt list the difeereiot tme stioes).
# timedatectl set-time <hh : mm : ss> (tt set the tme).
# timedatectl set-timezone Asia/Kolkata (tt set the tme stioe iio RHEL - 7).
# tzselect Asia/Kolkata (tt set the tme stioe iio RHEL - 6).
18. DNS (Domain Naming System)

1. What is DNS?
DNS staiods ftr Dtmaiio Namiioi System. The DNStraioslates Iioterioet dtmaiio aiod htst ioames
tt IP addresses. DNS aguttmatcally ctio erts the ioames we type iio tgur Web brtwser address
bar tt the IP addresses tf Web ser ers htstioi thtse sites.
DNS implemeiots a distribguted database tt sttre this ioame aiod address iioftrmattio ftr all
pgublic htsts tio the Iioterioet. DNS assgumes IP addresses dt iott chaioie (are statcally assiiioed
rather thaio dyioamically assiiioed)..
2. What is DNS server and how it works?
Iio aioy ioetwtrk the htsts primarily ctmmguioicate betweeio each tther thrtguih IP addresses. Ftr
example if my ctmpguter is dtiioi a ittile search my ctmpguter is actgually ctmmguioicatioi with the
IP address tf tioe tf the web ser ers tf ittile.ctm. Htwe er e eio if the ctmpguter is
efcieiot with iogumbers hgumaios tio the tther haiod wtrk better with ioames. Ftr this reastio the

Ratnakar Page 151


[Pick the date] [LINUX NOTES FOR LEVEL 2]

TCP/SIP prtttctl iioclgudes the Domain Name System (DNS) tt liiok betweeio IPs aiod ctmpguter
ioames i.e. htstioames. The DNS is a distribguted database tf ctmpguters that is resptiosible ftr
restl iioi htstioames aiaiiost IP addresses aiod ice- ersa.
Aioy DNS qguery iio tl es twt parts.
(i). The Resolver: The restl er ftrms gup tr iioitates the qguery. The restl er itself dtes iott rguio as
a prtiram. /etc/resolve.conf is aio example tf a restl er.
(ii). Name Server: The Name Ser er is the ser ice rguioioiioi iio the ser er that resptiods tt the DNS
qguery ieioerated by the restl er i.e. aioswers tt the qguesttio tf the
restl er.
The working DNS :
(i). The clieiot iioitates a qguery tt fiod a dtmaiio example.ctm. The clieiot seiods the qguery tt the
DNS ser er tf the ISP. (The DNS Ser er IP iio the clieiot ctmpguter is set as the IP address tf
the DNS Ser er tf the ISP).
(ii). The DNS Ser er tf the ISP frst checks it's twio cache tt check whether it already kiotws the
aioswer. gut as the aioswer is iott preseiot it ieioerates aiotther qguery. As the Top Level
Domain tf example.ctm is .com st the DNS ser er qgueries the Internet Registration
Authority tt fiod wht is resptiosible ftr example.ctm.
(iii).The Iioterioet Reiistrattio Aguthtrity resptiods tt the ISP by aiosweriioi the qguery.
(i ). Oioce the ISP DNS Ser er kiotws the aguthtritat e ioame ser ers it ctiotacts the aguthtritat e
ioame ser ers tt fiod tgut the IP address ftr www.example.ctm i.e. the IP address tf
htst www iio the domain example.ctm. ( ). example.com resptiods tt the ISP DNS Ser er by
aiosweriioi the qguery aiod prt idiioi the IP address tf the web ser er i.e. www
( i). The ISP DNS Ser er sttres the aioswer iio it's cache ftr fgutgure guse aiod aioswers tt the clieiot
by seiodiioi the IP address tf the www ser er.
( ii). The clieiot may sttre the aioswer tt the DNS qguery iio it's twio cache ftr fgutgure guse. Theio the
clieiot ctmmguioicates directly with the www ser er tf dtmaiio example.com gusiioi
the IP address.
( iii). The www ser er resptiods by seiodiioi the iiodex.html paie.
3. What is the format of the domain name?
Like a physical address iioterioet dtmaiio ioames are hierarchical way. If the Fgully Qgualifed
Dtmaiio Name is www.google.co.in the www is the Htstioame google is the Dtmaiio co
is the Sectiod Le el Dtmaiio aiod in is the Ttp Le el Dtmaiio.
4. What are the files we have to edit to configure the DNS?
There are ftgur fles tt edit tt ctiofigure the DNS. They are /etc/named.conf,
/etc/named.rfc1912.zones, Forward Lookup Zoneaiod Reverse Lookup Zone. DNS prt ides a
ceiotralised database ftr restlguttio. Ztioe
is sttraie databasewhich ctiotaiios all the rectrds.
Forward Lookup Zone is gused tt restl eHostnames tt IP addresses.
Reverse Lookup Zone is gused tt restl e IP addresses tt Hostnames.
5. What are the DNS record and explain them?

Ratnakar Page 152


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i). SOA Record : (Start tf Aguthtrity).


SOA ctiotaiios the ieioeral admiioistrattio aiod ctiotrtl iioftrmattio abtgut the dtmaiio.
(ii). Host A Record :
(a). It is iotthiioi bgut aForward Lookup Zone.
(b). It maps Hostname tt IP address.
(iii).PTR : (Ptiioter Rectrd).
(a). It is iotthiioi bgut a Reverse Lookup Zone.
(b). It maps IP address tt Hostname.
(i ).NS Record : (Name Ser er Rectrd).
It sttres the DNS ser er IP addresses.
( ). MX Record : (MBail Exchaioie Rectrd).
It sttres the rectrds tf the Mail Server IP address.
( i). CNME Record :
It is iotthiioi bgut Htst's Caiotioical ioame alltws addittioal ioames tr aliases tt be gused
ltcate a system.
6. What is the profile of the DNS?
Packaie : bind and caching-name
Script : /etc/init.d/named
Ctiofigurattio fle : /etc/named.conf and /etc/named.rfc1912.zones
Clieiot's ctiofigurattio fle : /etc/resolve.conf
Dtcgumeiot rttt : /var/named/
Lti fle : /var/log/messages
Deamtio : named
Ptrt iogumber : 53
7. How to configure the DNS server?
(i). Iiostall the packaies bind, caching-name ftr RHEL - 6 &bind, cashing-name and unbound
ftr RHEL - 7.
# yum install bind* caching-name* -y (tt iiostall the DNS
packaies ftr RHEL - 6).
# yum install bind* caching-name* unbound* -y (tt iiostall the DNS
packaies ftr RHEL - 7).
(ii). Chaioie the htstioame by addiioi fgully qgualifed dtmaiio ioame aiod make it permaioeiot.
# hostname <fully qualified domain name> (tt chaioie the htstioame iio
RHEL - 6).
# htstioame ser er9.example.ctm (example ftr setioi htstioame
temptrarily iio RHEL - 6).
# hostnamectl set <fully qualified domain name> (tt chaioie the htstioame iio
RHEL - 7).
# htstioamectl set ser er9.example.ctm (example ftr setioi htstioame
temptrarily iio RHEL - 7).

Ratnakar Page 153


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# vim /etc/hosts (tpeio this fle aiod it tt last liioe aiod type as beltw iio
RHEL - 6 tioly).
<IP address> <fully qualified domain name> <hostname>
172.25.9.11 ser er9.example.ctm ser er9 (ftr example tf the abt e
syiotax).
# vim /etc/sysconfig/network (tpeio this fle aiod it tt last liioe aiod type as beltw iio
RHEL - 6 tioly).
HOSTNAME=<fully qualified domain name>
HOSTNAMBE=ser er9.example.ctm (ftr example tf the abt e
syiotax).
(ii). Opeio the DNS maiio ctiofigurattio fle by # vim /etc/named.conf ctmmaiod.
* Gt tt liioe iogumber 11 aiod edit this liioe as beltw.
listeio-tio ptrt 53 { 127.0.0.1 <ser er IP address> }
Example : listeio-tio ptrt 53 {127.0.0.1 172.25.9.11 }
* Gt tt liioe iogumber 17 aiod edit this liioe as beltw.
alltw-qguery { ltcalhtst <Netwtrk ID>/S<ioetmask> }
Example : alltw-qguery {ltcalhtst 172.25.9.0/S24 } (sa e aiod
exit this fle).
(iii). Opeio the DNS stioe refereioce fle by # vim /etc/named.rfc1912.zones ctmmaiod
* Gt tt liioe iogumber 19 aiod ctpy 5 liioes aiod paste them at last tf the fle.
stioe "<dtmaiio ioame>" IN {
type-master
fle "<ftrward lttkgup stioe fle ioame>"
alltw-gupdate { iotioe }
}
Example : stioe "example.ctm" IN {
type-master
fle "ioamed.ftrward"
alltw-gupdate { iotioe }
}
* Gt tt liioe iogumber 31 aiod ctpy 5 liioes aiod paste them at last tf the fle.
stioe "<Three tctets tf the DNS ser er IP address> . iio . addr . arpa" IN {
type-master
fle "<re erse lttkgup stioe fle ioame>"
alltw-gupdate { iotioe }
}
Example : stioe "9.25.172 . iio . addr . arpa" IN {
type-master
fle "ioamed.re erse"
alltw-gupdate { iotioe }

Ratnakar Page 154


[Pick the date] [LINUX NOTES FOR LEVEL 2]

} (sa e aiod
exit this fle).
(i ). Ctpy /var/named/named.localhost fle tt /var/named/named.forward aiod edit as
ftlltws.
# cp -p /var/named/named.localhost /var/named/named.forward
# vim /var/named/named.forward
* Gt tt liioe iogumber 2 aiod edit as ftlltws.
@ IN SOA <DNS ser er fgully qgualifed dtmaiio ioame> . ctm rttt . <dtmaiio
ioame> . {
* Gt tt liioe iogumber 8 aiod edit as ftlltws.
NS <DNS ser er fgully qgualifed dtmaiio ioame> .
A <DNS ser er IP address>
<DNS ser er fgully qgualifed dtmaiio ioame> IN A <DNS ser er IP address>
<Clieiot 1 fgully qgualifed dtmaiio ioame> IN A <Clieiot 1 IP address>
<Clieiot 2 fgully qgualifed dtmaiio ioame> IN A <Clieiot 2 IP address>
<Clieiot 3 fgully qgualifed dtmaiio ioame> IN A <Clieiot 3 IP address>
www IN CNAMBE <DNS ser er fgully qgualifed dtmaiio ioame>
Example : The liioe iogumber 2 shtguld be edited as ftlltws.
@ IN SOA ser er9.example.ctm. rttt.example.ctm. {
The liioe iogumber 8 shtguld be edited as ftlltws.
NS ser er9.example.ctm.
A 172.25.9.11
ser er9.example.ctm. IN A 172.25.9.11
clieiot9.example.ctm. IN A 172.25.9.10
clieiot10.example.ctm. IN A 172.25.9.12
clieiot11.example.ctm. IN A 172.25.9.13
www IN CNAMBE ser er9.example.ctm. (sa e aiod
exit this fle).
( ). Ctpy /var/named/named.empty fle tt /var/named/named.reverse aiod edit as
ftlltws.
# cp -p /var/named/named.empty /var/named/named.reverse
# vim /var/named/named.reverse
* Gt tt liioe iogumber 2 aiod edit as ftlltws.
@ IN SOA <DNS ser er fgully qgualifed dtmaiio ioame> . ctm rttt . <dtmaiio
ioame> . {
* Gt tt liioe iogumber 8 aiod edit as ftlltws.
NS <DNS ser er fgully qgualifed dtmaiio ioame> .
<Last tctet tf the DNS ser er IP address> IN PTR <DNS ser er fgully qgualifed
dtmaiio ioame>

Ratnakar Page 155


[Pick the date] [LINUX NOTES FOR LEVEL 2]

<Last tctet tf the Clieiot 1 IP address> IN PTR <Clieiot 1 fgully qgualifed dtmaiio
ioame>
<Last tctet tf the Clieiot 2 IP address> IN PTR <Clieiot 2 fgully qgualifed dtmaiio
ioame>
<Last tctet tf the Clieiot 3 IP address> IN PTR <Clieiot 3 fgully qgualifed dtmaiio
ioame>
<DNS ser er fgully qgualifed dtmaiio ioame> IN A <DNS ser er IP address>
www IN CNAMBE <DNS ser er fgully qgualifed dtmaiio ioame>
Example : The liioe iogumber 2 shtguld be edited as ftlltws.
@ IN SOA ser er9.example.ctm. rttt.example.ctm. {
The liioe iogumber 8 shtguld be edited as ftlltws.
NS ser er9.example.ctm.
11 IN PTR ser er9.example.ctm.
10 IN PTR clieiot9.example.ctm.
12 IN PTR clieiot10.example.ctm.
13 IN PTR clieiot11.example.ctm.
ser er9.example.ctm. IN A 172.25.9.11
www IN CNAMBE ser er9.example.ctm. (sa e aiod
exit this fle).
( i). Check the DNS ctiofigurattio fles ftr syiotax errtrs.
# ioamed-checkctiof /Setc/Sioamed.ctiof
# ioamed-checkctiof /Setc/Sioamed.rfc1912.stioes
# ioame-checkstioe <dtmaiio ioame><ftrward lttkgup stioe>
Example : # ioamed-checkstioe example.ctm /S ar/Sioamed/Sioamed.ftrward
# ioamed-checkstioe <dtmaiio ioame><re erse lttkgup stioe>
Example : # ioamed-checkstioe example.ctm /S ar/Sioamed/Sioamed.re erse
( ii). Gi e fgull permissitios tt the ftrward aiod re erse lttkgup stioes.
# chmtd 777 /S ar/Sioamed/Sioamed.ftrward
# chmtd 777 /S ar/Sioamed/Sioamed.re erse
( iii). Opeio /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-eth0 aiod eioter the DNS dtmaiio details if
iott preseiot.
# im /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-eth0 (it tt last liioe aiod
type as ftlltws).
DNS 1=example.ctm (sa e aiod
exit this fle).

(ix). Add the DNS ser er IP address iio /Setc/Srestl e.ctiof


# im /Setc/Srestl e.ctiof
search <dtmaiio ioame>
ioamese er <IP address tf the DNS ser er>

Ratnakar Page 156


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Example :
search example.ctm
ioameser er 172.25.9.11 (sa e aiod
exit this fle).
(x). Restart the DNS ser er deamtios.
# ser ice ioamed restart (tt restart the deamtio iio RHEL - 6).
# chkctiofi ioamed tio (tt eioable the deamtio at ioext bttt
tme iio RHEL - 6).
# systemctl restart ioamed guiobtguiod (tt restart the deamtios iio RHEL - 7).
# systemctl eioable ioamed guiobtguiod (tt eioable the deamtios at ioext bttt
tme iio RHEL -7).
(xi). Add the DNS ser ice tt the IP tables aiod Firewall.
# setgup (theio select the Firewall ctiofigurattio tpttio aiod add
DNS iio RHEL - 6).
# ser ice iptables restart (tt restart the IP tables iio RHEL - 6).
# ser ice iptables sa e (tt sa e the IP tables iio RHEL - 6).
# frewall-cmd --permaioeiot --add-ser ice=dios (tt add the DNS ser ice tt frewall
iio RHEL - 7).
# frewall-cmd --ctmplete-reltad (tt reltad the frewall iio RHEL - 7).
(xi). Check whether the DNS is restl iioi tr iott.
# dii <DNS ser er fgully qgualifed ioame> (tt check the restl iioi frtm htstioame
tt IP address).
# dii -x <DNS ser er IP address> (tt check the restl iioi frtm IP address
tt htstioame).
Example : # dii ser er9.example.ctm
# dii -x 172.25.9.11
(xii). Check the restlguttio with piioi test.
# piioi -c3 <DNS ser er fgully qgualifed dtmaiio ioame> (tt check the piioi test
with htstioame).
# piioi -c3 <IP address tf the DNS ser er> (tt check the piioi test
with IP address).
Example :
# piioi -c3 ser er9.example.ctm
# piioi -c3 172.25.9.11
(xiii). Check the restlguttio with htst ctmmaiod.
# htst <htstioame> (tt check the restlguttio
with htstioame).
# htst <IP address> (tt check the restlguttio
with IP address).
Example :

Ratnakar Page 157


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# htst ser er9.example.ctm


# htst 172.25.9.11
(xi ). Check the restlguttio with ioslttkgup ctmmaiod.
# ioslttkgup <htstioame> (tt check the restlguttio
with htstioame).
# ioslttkgup <IP address> (tt check the restlguttio
with IP address).
Example :
# ioslttkgup ser er9.example.ctm
# ioslttkgup 172.25.9.11
8. How to configure the DNS client?
(i). First assiiio the statc IP address tt the clieiot.
(ii). Set the htstioame tt the clieiot.
(iii). Restart the ioetwtrk ser ice by #service network restart ctmmaiod.
(i ).Opeio /Setc/Srestl e.ctiof fle aiod edit as beltw.
# im /Setc/Srestl e.ctiof
search <dtmaiio ioame>
ioameser er <DNS ser er IP address>
Example :
search example.ctm
ioameser er 172.25.9.11 (sa e aiod
exit this fle).
( ). Check whether the DNS is restl iioi tr iott.
# dii <DNS ser er fgully qgualifed ioame> (tt check the restl iioi frtm htstioame
tt IP address).
# dii -x <DNS ser er IP address> (tt check the restl iioi frtm IP address
tt htstioame).
Example : # dii ser er9.example.ctm
# dii -x 172.25.9.11
# dii clieiot9.example.ctm
# dii -x 172.25.9.10
( i). Check the restlguttio with piioi test.
# piioi -c3 <DNS clieiot fgully qgualifed dtmaiio ioame> (tt check the piioi test
with htstioame).
# piioi -c3 <IP address tf the DNS ser er> (tt check the piioi test
with IP address).
Example :
# piioi -c3 clieiot9.example.ctm
# piioi -c3 172.25.9.10
# piioi -c3 ser er9.example.ctm

Ratnakar Page 158


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# piioi -c3 172.25.9.11


( ii). Check the restlguttio with htst ctmmaiod.
# htst <htstioame> (tt check the restlguttio
with htstioame).
# htst <IP address> (tt check the restlguttio
with IP address).
Example :
# htst ser er9.example.ctm
# htst 172.25.9.11
# htst clieiot9.example.ctm
# htst 172.25.9.10
( iii). Check the restlguttio with ioslttkgup ctmmaiod.
# ioslttkgup <htstioame> (tt check the restlguttio
with htstioame).
# ioslttkgup <IP address> (tt check the restlguttio
with IP address).
Example :
# ioslttkgup ser er9.example.ctm
# ioslttkgup 172.25.9.11
# ioslttkgup clieiot9.example.ctm
# ioslttkgup 172.25.9.10
9. How to configure the Secondary DNS server?
(i). Iiostall the packaies bind, caching-name ftr RHEL - 6 &bind, cashing-name and
unbound ftr RHEL - 7.
# yum install bind* caching-name* -y (tt iiostall the DNS
packaies ftr RHEL - 6).
# yum install bind* caching-name* unbound* -y (tt iiostall the DNS
packaies ftr RHEL - 7).
(ii). Chaioie the htstioame by addiioi fgully qgualifed dtmaiio ioame aiod make it permaioeiot.
# hostname <fully qualified domain name> (tt chaioie the htstioame iio
RHEL - 6).
# htstioame ser er6.example.ctm (example ftr setioi htstioame
temptrarily iio RHEL - 6).
# hostnamectl set <fully qualified domain name> (tt chaioie the htstioame iio
RHEL - 7).
# htstioamectl set ser er6.example.ctm (example ftr setioi htstioame
temptrarily iio RHEL - 7).
# vim /etc/hosts (tpeio this fle aiod it tt last liioe aiod type as beltw iio
RHEL - 6 tioly).
<IP address> <fully qualified domain name> <hostname>

Ratnakar Page 159


[Pick the date] [LINUX NOTES FOR LEVEL 2]

172.25.6.11 ser er6.example.ctm ser er6 (ftr example tf the abt e


syiotax).
# vim /etc/sysconfig/network (tpeio this fle aiod it tt last liioe aiod type as beltw iio
RHEL - 6 tioly).
HOSTNAME=<fully qualified domain name>
HOSTNAMBE=ser er6.example.ctm (ftr example tf the abt e
syiotax).
(ii). Opeio the DNS maiio ctiofigurattio fle by # vim /etc/named.conf ctmmaiod.
* Gt tt liioe iogumber 11 aiod edit this liioe as beltw.
listeio-tio ptrt 53 { 127.0.0.1 <ser er IP address> }
Example : listeio-tio ptrt 53 {127.0.0.1 172.25.6.11 }
* Gt tt liioe iogumber 17 aiod edit this liioe as beltw.
alltw-qguery { ltcalhtst <Netwtrk ID>/S<ioetmask> }
Example : alltw-qguery {ltcalhtst 172.25.6.0/S24 } (sa e aiod
exit this fle).
(iii). Opeio the DNS stioe refereioce fle by # vim /etc/named.rfc1912.zones ctmmaiod
* Gt tt liioe iogumber 19 aiod ctpy 5 liioes aiod paste them at last tf the fle.
stioe "<dtmaiio ioame>" IN {
type-sla e
fle "sla es/S<ftrward lttkgup stioe fle ioame>"
master { <Primary DNS ser er IP address }
}
Example : stioe "example.ctm" IN {
type-sla e
fle "sla es/Sioamed.ftrward"
master { 172.25.9.11 }
}
* Gt tt liioe iogumber 31 aiod ctpy 5 liioes aiod paste them at last tf the fle.
stioe "<Three tctets tf the DNS ser er IP address> . iio . addr . arpa" IN {
type-sla e
fle "sla es/S<re erse lttkgup stioe fle ioame>"
master { <Primary DNS ser er IP address }
}
Example : stioe "9.25.172 . iio . addr . arpa" IN {
type-sla e
fle "sla es/Sioamed.re erse"
master { 172.25.9.11 }
} (sa e aiod
exit this fle).

Ratnakar Page 160


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i ). Ctpy /var/named/slaves/named.localhost tt /var/named/slaves/named.forward aiod


edit as ftlltws.
# mkdir /var/named/slaves
# cp -p /var/named/slaves/named.localhost /var/named/slaves/named.forward
# vim /var/named/slaves/named.forward
* Gt tt liioe iogumber 2 aiod edit as ftlltws.
@ IN SOA <sectiodary DNS ser er fgully qgualifed dtmaiio ioame> . ctmrttt .
<dtmaiio ioame> . {
* Gt tt liioe iogumber 8 aiod edit as ftlltws.
NS <DNS ser er fgully qgualifed dtmaiio ioame> .
A <DNS ser er IP address>
<sectiodary DNS ser er fgully qgualifed dtmaiio ioame> IN A <sectiodary DNS ser er
IP address>
<DNS ser er fgully qgualifed dtmaiio ioame> IN A <DNS ser er IP address>
<Clieiot 1 fgully qgualifed dtmaiio ioame> IN A <Clieiot 1 IP address>
<Clieiot 2 fgully qgualifed dtmaiio ioame> IN A <Clieiot 2 IP address>
<Clieiot 3 fgully qgualifed dtmaiio ioame> IN A <Clieiot 3 IP address>
www IN CNAMBE <DNS ser er fgully qgualifed dtmaiio ioame>
Example : The liioe iogumber 2 shtguld be edited as ftlltws.
@ IN SOA ser er6.example.ctm. rttt.example.ctm. {
The liioe iogumber 8 shtguld be edited as ftlltws.
NS ser er6.example.ctm.
A 172.25.6.11
ser er6.example.ctm. IN A 172.25.6.11
ser er9.example.ctm. IN A 172.25.9.11
clieiot9.example.ctm. IN A 172.25.9.10
clieiot10.example.ctm. IN A 172.25.9.12
clieiot11.example.ctm. IN A 172.25.9.13
www IN CNAMBE ser er6.example.ctm. (sa e aiod
exit this fle).
( ). Ctpy /var/named/slaves/named.empty fle tt /var/named/slaves/named.reverse aiod
edit as ftlltws.
# cp -p /var/named/slaves/named.empty /var/named/slaves/named.reverse
# vim /var/named/slaves/named.reverse
* Gt tt liioe iogumber 2 aiod edit as ftlltws.
@ IN SOA <sectiodary DNS ser er fgully qgualifed dtmaiio ioame> . ctmrttt .
<dtmaiio ioame> . {
* Gt tt liioe iogumber 8 aiod edit as ftlltws.
NS <sectiodary DNS ser er fgully qgualifed dtmaiio ioame> .

Ratnakar Page 161


[Pick the date] [LINUX NOTES FOR LEVEL 2]

<Last tctet tf the sectiodary DNS ser er IP address> IN PTR <sectiodary DNS ser er
fgully qgualifed
dtmaiio ioame>
<Last tctet tf the DNS ser er IP address> IN PTR <DNS ser er fgully qgualifed
dtmaiio ioame>
<Last tctet tf the Clieiot 1 IP address> IN PTR <Clieiot 1 fgully qgualifed dtmaiio
ioame>
<Last tctet tf the Clieiot 2 IP address> IN PTR <Clieiot 2 fgully qgualifed dtmaiio
ioame>
<Last tctet tf the Clieiot 3 IP address> IN PTR <Clieiot 3 fgully qgualifed dtmaiio
ioame>
<sectiodary DNS ser er fgully qgualifed dtmaiio ioame> IN A <sectiodary DNS ser er
IP address>
www IN CNAMBE <sectiodary DNS ser er fgully qgualifed dtmaiio ioame>
Example : The liioe iogumber 2 shtguld be edited as ftlltws.
@ IN SOA ser er6.example.ctm. rttt.example.ctm. {
The liioe iogumber 8 shtguld be edited as ftlltws.
NS ser er6.example.ctm.
11 IN PTR ser er6.example.ctm.
11 IN PTR ser er9.example.ctm.
10 IN PTR clieiot9.example.ctm.
12 IN PTR clieiot10.example.ctm.
13 IN PTR clieiot11.example.ctm.
ser er6.example.ctm. IN A 172.25.6.11
www IN CNAMBE ser er6.example.ctm. (sa e aiod
exit this fle).
( i). Check the DNS ctiofigurattio fles ftr syiotax errtrs.
# ioamed-checkctiof /Setc/Sioamed.ctiof
# ioamed-checkctiof /Setc/Sioamed.rfc1912.stioes
# ioame-checkstioe <dtmaiio ioame><ftrward lttkgup stioe>
Example : # ioamed-checkstioe example.ctm /S ar/Sioamed/Ssla es/Sioamed.ftrward
# ioamed-checkstioe <dtmaiio ioame><re erse lttkgup stioe>
Example : # ioamed-checkstioe example.ctm /S ar/Sioamed/Ssla es/Sioamed.re erse
( ii). Gi e fgull permissitios tt the ftrward aiod re erse lttkgup stioes.
# chmtd 777 /S ar/Sioamed/Ssla es/Sioamed.ftrward
# chmtd 777 /S ar/Sioamed/Ssla es/Sioamed.re erse
( iii). Opeio /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-eth0 aiod eioter the DNS dtmaiio details if
iott preseiot.
# im /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-eth0 (it tt last liioe aiod
type as ftlltws).

Ratnakar Page 162


[Pick the date] [LINUX NOTES FOR LEVEL 2]

DNS 1=example.ctm (sa e aiod


exit this fle).
(ix). Add the DNS ser er IP address iio /Setc/Srestl e.ctiof
# im /Setc/Srestl e.ctiof
search <dtmaiio ioame>
ioamese er <IP address tf the DNS ser er>
ioamese er <IP address tf the sectiodary DNS ser er>
Example :
search example.ctm
ioameser er 172.25.9.11
ioameser er 172.25.6.11 (sa e aiod
exit this fle).
(x). Restart the DNS ser er deamtios.
# ser ice ioamed restart (tt restart the deamtio iio RHEL - 6).
# chkctiofi ioamed tio (tt eioable the deamtio at ioext bttt
tme iio RHEL - 6).
# systemctl restart ioamed guiobtguiod (tt restart the deamtios iio RHEL - 7).
# systemctl eioable ioamed guiobtguiod (tt eioable the deamtios at ioext bttt
tme iio RHEL -7).
(xi). Add the DNS ser ice tt the IP tables aiod Firewall.
# setgup (theio select the Firewall ctiofigurattio tpttio aiod add
DNS iio RHEL - 6).
# ser ice iptables restart (tt restart the IP tables iio RHEL - 6).
# ser ice iptables sa e (tt sa e the IP tables iio RHEL - 6).
# frewall-cmd --permaioeiot --add-ser ice=dios (tt add the DNS ser ice tt frewall
iio RHEL - 7).
# frewall-cmd --ctmplete-reltad (tt reltad the frewall iio RHEL - 7).
(xi). Check whether the DNS is restl iioi tr iott.
# dii <DNS ser er fgully qgualifed ioame> (tt check the restl iioi frtm htstioame
tt IP address).
# dii -x <DNS ser er IP address> (tt check the restl iioi frtm IP address
tt htstioame).
Example : # dii ser er6.example.ctm
# dii -x 172.25.6.11
(xii). Check the restlguttio with piioi test.
# piioi -c3 <sectiodary DNS ser er fgully qgualifed dtmaiio ioame>(tt check the piioi test
with htstioame).
# piioi -c3 <IP address tf the sectiodary DNS ser er> (tt check the piioi test with
IP address).
Example :

Ratnakar Page 163


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# piioi -c3 ser er6.example.ctm


# piioi -c3 172.25.6.11
(xiii). Check the restlguttio with htst ctmmaiod.
# htst <htstioame> (tt check the restlguttio
with htstioame).
# htst <IP address> (tt check the restlguttio
with IP address).
Example :
# htst ser er6.example.ctm
# htst 172.25.6.11
(xi ). Check the restlguttio with ioslttkgup ctmmaiod.
# ioslttkgup <htstioame> (tt check the restlguttio
with htstioame).
# ioslttkgup <IP address> (tt check the restlguttio
with IP address).
Example :
# ioslttkgup ser er6.example.ctm
# ioslttkgup 172.25.6.11

Ratnakar Page 164


[Pick the date] [LINUX NOTES FOR LEVEL 2]

19. DHCP (Dynamic Host Configuration Protocol)

1. What is DHCP and explain it?


DHCP staiods ftr Dyioamic Htst Ctiofigurattio Prtttctl. DHCP is a ioetwtrk prtttctl that
eioables the ser er tt assiiio aio IP addresses tt the clieiots iio the ioetwtrk aguttmatcally frtm a
defioed raioie tf IP addresses ie. sctpe ctiofigured ftr a ii eio ioetwtrk.
DHCP alltws a ctmpguter tt jtiio iio aio IP-based ioetwtrk withtgut ha iioi a pre-ctiofigured IP
address. DHCP is a prtttctl that assiiio guioiqgue IP addresses tt de ices theio releases aiod
reioews thtse addresses as de ices lea e aiod rejtiio iio the ioetwtrk.
Iioterioet Ser ice Prt iders (ISPs). gusgually guse DHCP tt help cgusttmers jtiio their ioetwtrks with
miioimgum setgup efetrt reqguired. Likewise htme ioetwtrk eqguipmeiot like brtadbaiod rtguters
tfeers DHCP sgupptrt tt jtiioiioi htme ctmpguters tt Ltcal Area Netwtrks (LANs)..
Iio simple terms DHCP is gused tt assiiio the IP addresses tt the remtte htsts aguttmatcally.
First clieiot reqguests tt the DHCP ser er theio DHCP ser er accepts the clieiot's reqguest aiod
assiiio the ioext a ailable IP address tt the reqguested DHCP clieiot.
2. How the DHCP works?
The prtcess tf reqguestioi the IP address frtm the DHCP clieiots aiod assiiio the IP address by
the DHCP ser er is called "D O R A".
(i). Wheio we switch tio the system with DHCP clieiot the clieiot system seiods the broadcast
request lttkiioi ftr a DHCP ser er tt aioswer. This prtcess is called DISCOVER tr DHCP
DISCOVER.
(ii). The rtguter directs the DISCOVER packet tt the ctrrect DHCP ser er.
(iii). The ser er recei es the DISCOVER packet. ased tio a ailability aiod gusaie ptlicies set tio
the ser er the ser er determiioes aio apprtpriate address (if aioy). tt ii e tt the clieiot. The
ser er theio temptrarily reser es that address ftr the clieiot aiod seiods back tt the clieiot aio
OFFER trDHCP OFFER packet with that address iioftrmattio. The ser er alst ctiofigures the
clieiot's DNS ser ers WINS ser ers NTP ser es aiod stmetmes tther ser ices alst.
(i ). Theio the Clieiot seiods a REQUEST tr DHCP REQUEST packet letioi the ser er kiotw
that it iioteiods tt guse the address.
( ). Theio the ser er seiods aio ACK tr DHCP ACK packet ctioftrmiioi that the clieiot has beeio
ii eio a lease tio the address ftr a ser er specifed peritd tf tme.
3. What is the disadvantage to assign the Static IP address?
Wheio a system guses a statc IP address It meaios that the system is maiogually ctiofigured tt
guse a specifc IP address. Oioe prtblem with statc assiiiomeiot which caio resgult frtm guser errtr

Ratnakar Page 165


[Pick the date] [LINUX NOTES FOR LEVEL 2]

tr iioatteiottio tt detail tccgurs wheio twt systems are ctiofigured with the same IP address.
This creates a ctiofict that resgults iio ltss tf ser ice. Usiioi DHCP tt dyioamically assiiio IP
addresses tt a tid these ctioficts.
4. What is the profile of DHCP?
Packaie : dhcp*
Script fle : /etc/init.d/dhcpd
Ctiofigurattio fle : /etc/dhcp/dhcpd.conf
Deamtio : dhcpd
Ptrt iogumbers : 67 (dhcp server) aiod 68 (dhcp client)
Lti messaies : /var/log/messages

5. How to configure the DHCP server?


(i). Assiiio a statc IP address tt the DHCP ser er.
(ii). Iiostall the DHCP packaie by # yum install dhcp* -y ctmmaiod.
(iii). Opeio the DHCP ctiofigurattio fle by # vim /etc/dhcp/dhcpd.conf ctmmaiod. This fle is
empty aiod we ha e tt ctpy the sample fle frtm /usr/share/doc/dhcp-
4.25/dhcpd.conf.example tt the abt e ltcattio by # cp -p /usr/share/doc/dhcp-
4.25/dhcpd.conf.example /etc/dhcp/dhcpd.conf ctmmaiod.
(i ). Ntw tpeio the abt e DHCP ctiofigurattio fle by # vim /etc/dhcp/dhcpd.conf
ctmmaiod.
* Gt tt liioe iogumber 47 aiod edit that liioe as beltw.
sgubioet <DHCP ser er Netwtrk ID> ioetmask <sgubioetmask tf the this ioetwtrk> {
raioie <startioi IP address><eiodiioi IP address>
defagult-lease-tme 600 (the miioimgum lease tme tt the
clieiot iio sectiods).
max-lease-tme 7200 (he maximgum lease tme tt the
clieiot iio sectiods).
}
Example :
sgubioet 172.25.0.0 ioetmask 255.255.255.0 {
raioie 172.25.9.50 172.25.9.100
defagult-lease-tme 600
max-lease-tme 7200
}
* Gt tt liioe iogumber 51 aiod edit that as beltw.
tpttio rtgutes <DHCP ser er IP address>
tpttio brtadcast-address <DHCP ser er brtadcast address>
Example :
tpttio rtgutes 172.25.9.11

Ratnakar Page 166


[Pick the date] [LINUX NOTES FOR LEVEL 2]

tpttio brtadcast-address 172.25.9.255 (sa e aiod


exit this fle).
( ). Restart the DHCP ser ices iio RHEL - 6 aiod RHEL - 7.
# service dhcpd restart (tt restart the DHCP
ser ice iio RHEL - 6).
# chkconfig dhcpd on (tt eioable the DHCP ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart dhcpd (tt restart the DHCP
ser ice iio RHEL - 7).
# systemctl enable dhcpd (tt eioable the DHCP ser ice at ioext
bttt iio RHEL - 7).
( i). Add the DHCP ser ice tt the IP tables aiod Firewall.
In RHEL - 6:
# iptables -A INPUT -p udp -i eth0 --deport 67 -j ACCEPT
# iptables -A INPUT -p tcp -i eth0 --deport 67 -j ACCEPT
# iptables -A INPUT -p udp -i eth0 --deport 68 -j ACCEPT
# iptables -A INPUT -p tcp -i eth0 --deport 68 -j ACCEPT
# iptables -A OUTPUT -p udp -i eth0 --deport 67 -j ACCEPT
# iptables -A OUTPUT -p tcp -i eth0 --deport 67 -j ACCEPT
# iptables -A OUTPUT -p udp -i eth0 --deport 68 -j ACCEPT
# iptables -A OUTPUT -p tcp -i eth0 --deport 68 -j ACCEPT
In RHEL - 7 :
# firewall-cmd --permanent --add-service=dhcp
# firewall-cmd --complete-reload
( ii). # cat /var/lib/dhcpd/dhcpd.lease (tt see the DHCP lease messaie database tio
DHCP ser er).
6. How to configure the DHCP client?
(i). Chaioie the IP addressiioi frtm statc tt dyioamic if it is ctiofigured as statc.
In RHEL - 6 :
# setgup
Netwtrk Ctiofigurattio -----> Press Eioter -----> De ice Ctiofigurattio -----> Select
eth0 ----->
Press Eioter -----> Select Use DHCP -----> Press Spacebar -----> OK -----> Sa e
----->Sa e & Qguit
-----> Qguit
# ser ice NetwtrkMBaioaier restart
# ser ice ioetwtrk restart
In RHEL - 7:
# iomcli ctioioecttio mtdify "System eth0" ip 4.methtd agutt tr dyioamic
# iomcli ctioioecttio dtwio "System eth0"

Ratnakar Page 167


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# iomcli ctioioecttio gup "System eth0"


# systemctl restart ioetwtrk
(ii). Opeio /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-eth0 fle aiod edit the OOTPROTO liioe.
# im /Setc/Ssysctiofi/Sioetwtrk-scripts/Sifcfi-eth0
* Gt tt OOTPROTO liioe aiod edit that liioe as beltw.
OOTPROTO=dhcp (sa e aiod
exit this fle).
(iii). Get the IP address frtm the DHCP ser er.
# dhclieiot
# ifdtwio eth0
# ifgup eth0
7. How to fix the IP address to the client every time it requests or how to configure the MAC
binding?
The prtcess tf assiiioiioi the same IP address (fxed IP address). tt the DHCP clieiot e ery
tme it bttted is called "MAC binding".
(i). Opeio the fle /Setc/Sdhcp/Sdhcpd.ctiof by # vim /etc/dhcp/dhcpd.conf ctmmaiod.
* Gt tt liioe iogumber 76 aiod 77 aiod edit thtse liioes as beltw.
htst <dhcp clieiot htstioame> {
hardware etherioet <MBAC address tf the Clieiot's NIC card>
fxed addresses<IP address>
}
Example :
htst clieiot 1 {
hardware etherioet 2015:ac18::55
fxed addresses 172.25.9.150
} (sa e aiod
exit this fle).
(ii). Restart the DHCP ser ices iio RHEL - 6 aiod RHEL - 7.
# ser ice dhcpd restart (tt restart the DHCP ser ice iio
RHEL - 6).
# chkctiofi dhcpd tio (tt eioable the DHCP ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart dhcpd (tt restart the DHCP
ser ice iio RHEL - 7).
# systemctl eioable dhcpd (tt eioable the DHCP ser ice at ioext
bttt iio RHEL - 7).
* Theio the abt e MBAC address tf the system will iet the same IP address e ery tme it
bttted.

Ratnakar Page 168


[Pick the date] [LINUX NOTES FOR LEVEL 2]

20. Web Server (Apache)

1. What is Web server and explain it?


A Web ser er is a system that deli ers ctioteiot tr ser ices tt eiod gusers t er the Iioterioet. A Web
ser er ctiosists tf a physical ser er ser er tperatioi system (OS). aiod stfware gused tt facilitate
HTTP ctmmguioicattio.
A ctmpguter that rguios a Web site. Usiioi the HTTP prtttctl the Web ser er deli ers Web paies
tt brtwsers as well as tther data fles tt Web-based applicattios. The Web ser er iioclgudes the
hardware tperatioi system Web ser er stfware TCP/SIP prtttctls aiod site ctioteiot (Web paies
imaies aiod tther fles).. If the Web ser er is gused iioterioally aiod is iott exptsed tt the pgublic it is
aio "iiotraioet ser er" aiod if the Web ser er is gused iio the iioterioet aiod is exptsed tt the
pgublic it is aio Iioterioet ser er.
2. What is Protocol?
A guioiftrm set tf rgules that eioable twt de ices tt ctioioect aiod traiosmit the data tt tioe aiotther.
Prtttctls determiioe htw data are traiosmitted betweeio ctmpgutioi de ices aiod t er
ioetwtrks. They defioe issgues sguch as errtr ctiotrtl aiod data ctmpressitio methtds. The
prtttctl determiioes the ftlltwiioi type tf errtr checkiioi tt be gused data ctmpressitio
methtd (if aioy). htw the seiodiioi de ice will iiodicate that it has fioished a messaie aiod htw
the recei iioi de ice will iiodicate that it has recei ed the messaie. Iioterioet prtttctls iioclgude
TCP/SIP (Traiosmissitio Ctiotrtl Prtttctl /S Iioterioet Prtttctl). HTTP (Hyper Text Traiosfer
Prtttctl). FTP (File Traiosfer Prtttctl). aiod SMBTP (Simple MBail Traiosfer Prtttctl)..
3. How a Web server works?
(i). If the guser types aio URL iio his brtwsers address bar the brtwser will splits that URL iiott a
iogumber tf separate parts iioclgudiioi address path ioame aiod prtttctl.
(ii). A DNS (Dtmaiio Namiioi Ser er). traioslates the dtmaiio ioame the guser has eiotered iiott its
IP address a iogumeric ctmbiioattio that represeiots the site's trgue address tio the
iioterioet.
(iii). The brtwser iotw determiioes which prtttctl (rgules aiod reigulattio which the clieiot machiioe
gused tt ctmmguioicate with ser ers). shtguld be gused. Ftr example FTP (File Traiosfer
Prtttctl). aiod HTTP (Hyper Text Traiosfer Prtttctl)..
(i ). The ser er seiods a GET reqguest tt the Web Ser er tt retrie e the address it has beeio
ii eio. Ftr example wheio a guser types http:/S/Swww.example.ctm/SMByphttt.jpi the
brtwser seiods a GET MByphttt.jpi ctmmaiod tt example.ctm ser er aiod
waits ftr a resptiose. The ser er iotw resptiods tt the brtwser's reqguests. It erifes that
the ii eio address exist fiods the ioecessary fles rguios the apprtpriate scripts exchaioies
cttkies if ioecessary aiod retgurios the resgults back tt the brtwser. If it caioiott ltcate the fle
the ser er seiods aio errtr messaie tt the clieiot.
( ). Theio the brtwser traioslates the data it has beeio ii eio iiott HTMBL aiod displays the resgults
tt the guser.
4. In how many ways can we host the websites?

Ratnakar Page 169


[Pick the date] [LINUX NOTES FOR LEVEL 2]

IP based Web Hosting :


IP based web htstioi is gusedIP address tr htstioame web htstioi.
Name based Web Hosting :
Htstioi the mgultple websites gusiioi siioile IP address.
Port based Web Hosting :
Web htstioi gusiioi aiotther ptrt iogumber ie. tther thaio the defagult ptrt iogumber.
User based Web Hosting :
We caio htst the Web sites gusiioi the guser ioame aiod passwtrd.

5. What is Apache Web Server?


Apache is a tpeio stgurce web ser er. It is mtstly gused web ser er iio the iioterioet. httpd is the
deamtio that speaks the http tr https prtttctls. It is a text based prtttctl ftr seiodiioi aiod
recei iioi the tbjects t er a ioetwtrk ctioioecttio. The http prtttctl is seiot t er the wired
ioetwtrk iio clear text gusiioi defagult ptrt iogumber 80/Stcp. Tt prttect the website we caio guse https
web ser er ftr data eiocrypttio.
6. What is the profile for Web server?
Packaie : htpd
script : /etc/init.d/htpd
Deamtio : htpd
Ctiofigurattio fle : /etc/htpd/conf/htpd.conf (ftr http).
/etc/htpd/conf.d/ssl.conf (ftr https).
Dtcgumeiot Rttt : /var/www/html
Lti fles : /var/log/htpd/access_log
/var/log/htpd/error_log
Ptrt Ngumber : 80/htp and 443/htps
* If we waiot tt ctiofigure the httpd ser er we ha e tt ftlltw the ISET rgules. where I - Iiostall
S - Start
E - Eioable aiod T - Test.
* Tt access the websites gusiioi the CLI mtde e-links, curl tools are gused aiod tt access the
websites gusiioi
the brtwser iio Liiogux Fireftx is gused.
7. How to make the htp web server available to the cleint?
(a). First assiiio the statc IP address aiod htstioame tt the ser er.
(b). Check whether the ser er packaie by # rpm -qa htpd* ctmmaiod.
(c). If iott iiostalled iiostall the web ser er packaie by # yum install htpd* -y ctmmaiod.
(d). Start the web ser er aiod eioable web ser er ser ice at ioext bttt.
# service htpd start (tt start the webser er deamtio iio
RHEL - 6).
# chkconfig htpd on (tt eioable the ser ice at ioext
bttt iio RHEL - 6).

Ratnakar Page 170


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# systemctl restart htpd (tt start the webser er


deamtio iio RHEL - 7).
# systemctl enable htpd (tt eioable the ser ice at ioext
bttt iio RHEL - 7).
(e). Opeio the brtwser aiod access the web ser er dtcgumeiot.
# firefox (tt tpeio the
freftx brtwser).
* Theio iio address bar type as htp://localhost/manual aiod press Eioter key.
8. How to configure the IP based virtual host Web server?
(a). First assiiio the statc IP address aiod htstioame tt the ser er.
(b). Check whether the ser er packaie by # rpm -qa htpd* ctmmaiod.
(c). If iott iiostalled iiostall the web ser er packaie by # yum install htpd* -y ctmmaiod.
(d). Check the ctiofigurattio fle tt ctiofigure the http web ser er by # rpm -qac htpd
ctmmaiod.
(e). If reqguired tpeio the web ser er dtcgumeiot by # rpm -qad htpd ctmmaiod.
(f). Gt tt the ctiofigurattio fle directtry by # cd /etc/htpd/conf.d
(i). Create the ctiofigurattio ftr IP based htstioi.
# vim /etc/htpd/conf.d/ip.conf
<VirtgualHtst <IP address tf the web ser er> : 80>
Ser erAdmiio rttt@<htstioame tf the web ser er>
Ser erName <htstioame tf the web ser er>
DtcgumeiotRttt /S ar/Swww/Shtml
</SVirtgualHtst>

<Directtry "/S ar/Swww/Shtml">


AlltwO erride iotioe
Reqguire All Graioted
</SDirecttry> (sa e aiod
exit this fle).
Example :
# vim /etc/htpd/conf.d/ip.conf (create the
ctiofigurattio fle).
<VirtgualHtst 172.25.9.11:80>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName ser er9.example.ctm
DtcgumeiotRttt /S ar/Swww/Shtml
</SVirtgualHtst>

<Directtry "/S ar/Swww/Shtml">


AlltwO erride iotioe
Reqguire All Graioted

Ratnakar Page 171


[Pick the date] [LINUX NOTES FOR LEVEL 2]

</SDirecttry>
(h). Gt tt dtcgumeiot rttt directtry aiod create the iiodex.html fle.
# cd /var/www/html
# vim index.html
<html>
<H1>
This is IP based Web Htstioi
</SH1>
</Shtml>
(sa e aiod exit this fle).
(i). Restart the web ser er deamtio.
# service htpd start (tt start the webser er
deamtio iio RHEL - 6).
# chkconfig htpd on (tt eioable the ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart htpd (tt start the webser er
deamtio iio RHEL - 7).
# systemctl enable htpd (tt eioable the ser ice at ioext
bttt iio RHEL - 7).
(j). Add the ser ice tt the IP tables aiod frewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ser ice=http
# frewall-cmd --ctmplete-reltad
(k). Gt tt clieiot system tpeio the freftx brtwser aiod type as htp://server9.example.com
iio address bar aiod check the iiodex paie is displayed tr iott.
(l). We caio alst access the website gusiioi elinks CLI tttl.
# yum install elinks* -y (iiostall the
eliioks packaie).
# elinks --dump server9.example.com (access the
iiodex paie).
9. How to configure the name based web hosting?
(a). MBake a directtry ftr irtgual tr ioamed based htstioi.
# mkdir /var/www/virtual
(b). Gt tt the ctiofigurattio fle directtry by # cd /etc/htpd/conf.d
(c). Create the ctiofigurattio ftr ioame based htstioi.
# vim /etc/htpd/conf.d/virtual.conf

Ratnakar Page 172


[Pick the date] [LINUX NOTES FOR LEVEL 2]

<VirtgualHtst <IP address tf the web ser er> : 80>


Ser erAdmiio rttt@<htstioame tf the web ser er>
Ser erName < irtgual htstioame tf the web ser er>
DtcgumeiotRttt /S ar/Swww/S irtgual
</SVirtgualHtst>

<Directtry "/S ar/Swww/S irtgual">


AlltwO erride iotioe
Reqguire All Graioted
</SDirecttry> (sa e aiod
exit this fle).
Example :
# vim /etc/htpd/conf.d/virtual.conf (create the
ctiofigurattio fle).
<VirtgualHtst 172.25.9.11:80>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName www9.example.ctm
DtcgumeiotRttt /S ar/Swww/S irtgual
</SVirtgualHtst>

<Directtry "/S ar/Swww/S irtgual">


AlltwO erride iotioe
Reqguire All Graioted
</SDirecttry>
(d). Gt tt ioamed based irtgual directtry aiod create the iiodex.html fle.
# cd /var/www/virtual
# vim index.html
<html>
<H1>
This is Name based Web Htstioi
</SH1>
</Shtml>
(sa e aiod exit this fle).
(e). Restart the web ser er deamtio.
# service htpd start (tt start the webser er
deamtio iio RHEL - 6).
# chkconfig htpd on (tt eioable the ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart htpd (tt start the webser er
deamtio iio RHEL - 7).
# systemctl enable htpd (tt eioable the ser ice at ioext
bttt iio RHEL - 7).

Ratnakar Page 173


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(f). Add the ser ice tt the IP tables aiod frewall.


In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ser ice=http
# frewall-cmd --ctmplete-reltad
(i).Gt tt clieiot system tpeio the freftx brtwser aiod type as htp://www9.example.com iio
address bar aiod check the iiodex paie is displayed tr iott.
(h). We caio alst access the website gusiioi elinks CLI tttl.
# yum install elinks* -y (iiostall the
eliioks packaie).
# elinks --dump www9.example.com (access the iiodex
paie).
10. How to configure the port based web hosting?
(a). MBake a directtry ftr ptrt based htstioi.
# mkdir /var/www/port
(b). Gt tt the ctiofigurattio fle directtry by # cd /etc/htpd/conf.d
(c). Create the ctiofigurattio ftr ptrt based htstioi.
# vim /etc/htpd/conf.d/port.conf
<VirtgualHtst <IP address tf the web ser er> : 8999>
Ser erAdmiio rttt@<htstioame tf the web ser er>
Ser erName <ptrt based htstioame tf the web ser er>
DtcgumeiotRttt /S ar/Swww/Sptrt
</SVirtgualHtst>

<Directtry "/S ar/Swww/Sptrt">


AlltwO erride iotioe
Reqguire All Graioted
</SDirecttry> (sa e aiod
exit this fle).
Example :
# vim /etc/htpd/conf.d/virtual.conf (create the
ctiofigurattio fle).
<VirtgualHtst 172.25.9.11:8999>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName ptrt9.example.ctm
DtcgumeiotRttt /S ar/Swww/Sptrt

Ratnakar Page 174


[Pick the date] [LINUX NOTES FOR LEVEL 2]

</SVirtgualHtst>

<Directtry "/S ar/Swww/Sptrt">


AlltwO erride iotioe
Reqguire All Graioted
</SDirecttry>
(d). Gt tt ptrt based irtgual directtry aiod create the iiodex.html fle.
# cd /var/www/port
# vim index.html
<html>
<H1>
This is Ptrt based Web Htstioi
</SH1>
</Shtml>
(sa e aiod exit this fle).
(e). Geioerally ptrt based web htstioi reqguires DNS ser er. St we caio stl e this prtblem by
the ftlltwiioi way.
Ftr that tpeio the /etc/hosts fle eioter the ser er ioame aiod IP addresses tio btth ser er
aiod clieiot.
# vim /etc/hosts
172.25.9.11 ptrt5.example.ctm (sa e aiod
exit this fle).
(f). y defagult the web ser er rguios tio ptrt iogumber 80. If we waiot tt ctiofigure tio defereiot ptrt
iogumber we ha e tt add the ptrt iogumber iio the maiio ctiofigurattio fle.
# vim /etc/htpd/conf/htpd.conf
* Gt tt Listen : 80 liioe aiod tpeio ioew liioe beltw this liioe aiod type as
Listen : 8999 (sa e aiod
exit this fle).
(i). y defagult SELiiogux will alltw 80 aiod 8080 ptrt iogumbers tioly ftr webser er. If we guse
difeereiot ptrt iogumbers tther thaio 80 tr 8080 theio execgute the ftlltwiioi
ctmmaiod.
# semanage port -a -t htp_port_t -p tcp 8999
(h). Restart the web ser er deamtio.
# service htpd start (tt start the webser er
deamtio iio RHEL - 6).
# chkconfig htpd on (tt eioable the ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart htpd (tt start the webser er
deamtio iio RHEL - 7).
# systemctl enable htpd (tt eioable the ser ice at ioext
bttt iio RHEL - 7).
(i). Add the ser ice tt the IP tables aiod frewall.

Ratnakar Page 175


[Pick the date] [LINUX NOTES FOR LEVEL 2]

In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 8999 -j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 8999 -j ACCEPT
# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ser ice=http
# frewall-cmd --permaioeiot -add-ptrt=8999/Stcp
# frewall-cmd --ctmplete-reltad
(j). Gt tt clieiot system tpeio the freftx brtwser aiod type as htp://port9.example.com iio
address bar aiod check the iiodex paie is displayed tr iott.
(k). We caio alst access the website gusiioi elinks CLI tttl.
# yum install elinks* -y (iiostall the
eliioks packaie).
# elinks --dump port9.example.com (access the iiodex
paie).
11. How to configure user authentication based web hosting?
It will ask guser ioame aiod passwtrd tt access this website. St we ha e tt prt ide http
passwtrd.
(f). Gt tt the ctiofigurattio fle directtry by # cd /etc/htpd/conf.d
(i). Create the ctiofigurattio ftr guser agutheiotcattio based htstioi.
# vim /etc/htpd/conf.d/userbase.conf
<VirtgualHtst <IP address tf the web ser er> : 80>
Ser erAdmiio rttt@<htstioame tf the web ser er>
Ser erName <htstioame tf the web ser er>
DtcgumeiotRttt /S ar/Swww/Shtml
</SVirtgualHtst>

<Directtry "/S ar/Swww/Shtml">


AlltwO erride iotioe
Reqguire All Graioted
AguthType asic
AguthName "This site is prttected"
AguthUserFile /Setc/Shttpd/Spass
Reqguire User <guser ioame>
</SDirecttry> (sa e aiod
exit this fle).
Example :
# vim /etc/htpd/conf.d/userbase.conf (create the
ctiofigurattio fle).

Ratnakar Page 176


[Pick the date] [LINUX NOTES FOR LEVEL 2]

<VirtgualHtst 172.25.9.11:80>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName ser er9.example.ctm
DtcgumeiotRttt /S ar/Swww/Shtml
</SVirtgualHtst>

<Directtry "/S ar/Swww/Shtml">


AlltwO erride iotioe
Reqguire All Graioted
AguthType asic
AguthName "This site is prttected"
AguthUserFile /Setc/Shttpd/Spass
Reqguire User rajgu
</SDirecttry>
(h). Gt tt dtcgumeiot rttt directtry aiod create the iiodex.html fle.
# cd /var/www/html
# vim index.html
<html>
<H1>
This is User Agutheiotcattio based Web Htstioi
</SH1>
</Shtml>
(sa e aiod exit this fle).
(i). Restart the web ser er deamtio.
# service htpd start (tt start the webser er
deamtio iio RHEL - 6).
# chkconfig htpd on (tt eioable the ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart htpd (tt start the webser er
deamtio iio RHEL - 7).
# systemctl enable htpd (tt eioable the ser ice at ioext
bttt iio RHEL - 7).
(j). Add the ser ice tt the IP tables aiod frewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ser ice=http
# frewall-cmd --ctmplete-reltad
(k). Create the guser aiod assiiio the http passwtrd.

Ratnakar Page 177


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# useradd raju
* Dtio't ii e the iotrmal passwtrd becaguse this guser reqguires the http passwtrd.
# htpasswd -c m /etc/htpd/pass <user name>
Example : # htpasswd -c m /Setc/Shttpd/Spass rajgu
(l). Gt tt clieiot system tpeio the freftx brtwser aiod type as htp://server9.example.com
iio address bar aiod check the iiodex paie is displayed tr iott. Theio it asks passwtrd st we
ha e tt prt ide http passwtrd.
(m).We caio alst access the website gusiioi elinks CLI tttl.
# yum install elinks* -y (iiostall the
eliioks packaie).
# elinks --dump server9.example.com (access the
iiodex paie).
* Theio it asks passwtrd st we ha e tt prt ide http passwtrd.
12. How to restrict the web sites access from hosts or domains or networks?
(a). Gt tt the ctiofigurattio fle directtry by # cd /etc/htpd/conf.d
(b). Create the ctiofigurattio ftr IP based htstioi.
# vim /etc/htpd/conf.d/restrict.conf
<VirtgualHtst 172.25.9.11:80>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName ser er9.example.ctm
DtcgumeiotRttt /S ar/Swww/Shtml
</SVirtgualHtst>

<Directtry "/S ar/Swww/Shtml">


AlltwO erride iotioe
Reqguire All Graioted
Order Alltw Deioy
Alltw frtm 172.25.9.0 tr 172.25.0 (alltws 172.25.9 ioetwtrk tr 172.25 ioetwtrk tt
access the websites).
Deioy frtm .my133t.tri (deioy all the systems tf *.my133t.tri dtmaiio tt
access the websites).
</SDirecttry>
13. How to Redirect the website?
* Redirectioi meaios wheioe er we access the website it redirects tt aiotther website.

(a). Gt tt the ctiofigurattio fle directtry by # cd /etc/htpd/conf.d


(b). Create the ctiofigurattio ftr redirect based htstioi.
# vim /etc/htpd/conf.d/rediect.conf
<VirtgualHtst 172.25.9.11:80>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName ser er9.example.ctm

Ratnakar Page 178


[Pick the date] [LINUX NOTES FOR LEVEL 2]

DtcgumeiotRttt /S ar/Swww/Shtml
Redirect /S "http:/S/Swww.ittile.ctm"
</SVirtgualHtst>

<Directtry "/S ar/Swww/Shtml">


AlltwO erride iotioe
Reqguire All Graioted
</SDirecttry> (sa e aiod
exit this fle).
(c). Gt tt dtcgumeiot rttt directtry aiod create the iiodex.html fle.
# cd /var/www/html

# vim index.html
<html>
<H1>
This is Redirect based Web Htstioi
</SH1>
</Shtml>
(sa e aiod exit this fle).
(d). Restart the web ser er deamtio.
# service htpd start (tt start the webser er
deamtio iio RHEL - 6).
# chkconfig htpd on (tt eioable the ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart htpd (tt start the webser er
deamtio iio RHEL - 7).
# systemctl enable htpd (tt eioable the ser ice at ioext
bttt iio RHEL - 7).
(e). Add the ser ice tt the IP tables aiod frewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ser ice=http
# frewall-cmd --ctmplete-reltad
(f). Gt tt clieiot system tpeio the freftx brtwser aiod type as htp://server9.example.com
iio address bar aiod check the redirecttio ittile web paie is displayed tr iott.
(i). We caio alst access the website gusiioi elinks CLI tttl.
# yum install elinks* -y (iiostall the
eliioks packaie).

Ratnakar Page 179


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# elinks --dump server9.example.com (access the


iiodex paie).
* This website redirects tt the ittile website.
14. How to configure the website with alias name?
(a). Gt tt the ctiofigurattio fle directtry by # cd /etc/htpd/conf.d
(b). Create the ctiofigurattio ftr alias based htstioi.
# vim /etc/htpd/conf.d/alias.conf
<VirtgualHtst 172.25.9.11:80>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName ser er9.example.ctm
DtcgumeiotRttt /S ar/Swww/Shtml
Alias /Spri ate /S ar/Swww/Shtml/Spri ate
</SVirtgualHtst>

<Directtry "/S ar/Swww/Shtml/Spri ate">


AlltwO erride iotioe
Reqguire All Graioted
</SDirecttry> (sa e aiod
exit this fle).
(c). Create pri ate directtry iio /S ar/Swww/Shtml.
# mkdir /var/www/html/private
(c). Gt tt dtcgumeiot rttt pri ate directtry aiod create the iiodex.html fle.
# cd /var/www/html/private
# vim index.html
<html>
<H1>
This is Alias based Web Htstioi
</SH1>
</Shtml>
(sa e aiod exit this fle).
(d). Restart the web ser er deamtio.
# service htpd start (tt start the webser er
deamtio iio RHEL - 6).
# chkconfig htpd on (tt eioable the ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart htpd (tt start the webser er
deamtio iio RHEL - 7).
# systemctl enable htpd (tt eioable the ser ice at ioext
bttt iio RHEL - 7).
(e). Add the ser ice tt the IP tables aiod frewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT

Ratnakar Page 180


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT


# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ser ice=http
# frewall-cmd --ctmplete-reltad
(f). Gt tt clieiot system tpeio the freftx brtwser aiod type as
htp://server9.example.com/privae iio address bar aiod check the pri ate tr alias based
web paie is displayed tr iott.
(i). We caio alst access the website gusiioi elinks CLI tttl.
# yum install elinks* -y (iiostall the
eliioks packaie).
# elinks --dump server9.example.com/private (access the
iiodex paie).
15. How to configure the directory based web hosting?
(a). Gt tt the ctiofigurattio fle directtry by # cd /etc/htpd/conf.d
(b). Create the ctiofigurattio ftr direct based htstioi.
# vim /etc/htpd/conf.d/confidential.conf
<VirtgualHtst 172.25.9.11:80>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName ser er9.example.ctm
DtcgumeiotRttt /S ar/Swww/Shtml
</SVirtgualHtst>

<Directtry "/S ar/Swww/Shtml/Sctiofdeiotal">


AlltwO erride iotioe
Reqguire All Graioted
</SDirecttry> (sa e aiod
exit this fle).
(c). Create ctiofdeiotaldirecttry iio /S ar/Swww/Shtml.
# mkdir /var/www/html/confidential
(c). Gt tt ctiofdeiotal directtry aiod create the iiodex.html fle.
# cd /var/www/html/confidential
# vim index.html
<html>
<H1>
This is Alias based Web Htstioi
</SH1>
</Shtml>
(sa e aiod exit this fle).
(d). Restart the web ser er deamtio.

Ratnakar Page 181


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# service htpd start (tt start the webser er


deamtio iio RHEL - 6).
# chkconfig htpd on (tt eioable the ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart htpd (tt start the webser er
deamtio iio RHEL - 7).
# systemctl enable htpd (tt eioable the ser ice at ioext
bttt iio RHEL - 7).
(e). Add the ser ice tt the IP tables aiod frewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ser ice=http
# frewall-cmd --ctmplete-reltad
(f). Gt tt clieiot system tpeio the freftx brtwser aiod type as
htp://server9.example.com/confidential iio address bar aiod check the directtry based
web paie is displayed tr iott.
(i). We caio alst access the website gusiioi elinks CLI tttl.
# yum install elinks* -y (iiostall the
eliioks packaie).
# elinks --dump server9.example.com/confidential (access the
iiodex paie).
16. How to configure the web server to display the user defined home page not the index.html
page?
Ntrmally Apache will lttk the iiodex.html as the htme paie by defagult. If the ioame chaioied it
will display the htme paie withtgut ctiofigure that tioe. Ftr that we caio dt the abt e as ftlltws.
(i). Gt tt ctiofigurattio fle directtry by # cd /etc/htpd/conf.d ctmmaiod.
(ii). Create a guserpaie ctiofigurattio fle.
# vim userpage.conf
<VirtgualHtst 172.25.9.11:80>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName ser er9.example.ctm
DtcgumeiotRttt /S ar/Swww/Shtml
DirecttryIiodex guserpaie.html
</SVirtgualHtst>

<Directtry "/S ar/Swww/Shtml">

Ratnakar Page 182


[Pick the date] [LINUX NOTES FOR LEVEL 2]

AlltwO erride iotioe


Reqguire All Graioted
</SDirecttry> (sa e
aiod exit this fle).
(iii).Gt tt dtcgumeiot rttt directtry by # cd /var/www/html ctmmaiod.
(i ). # vim userpage.html
<html>
<H1>
This is guserpaie as htme paie web htstioi
</SH1>
</Shtml>
(sa e aiod exit this fle).
(d). Restart the web ser er deamtio.
# service htpd start (tt start the webser er
deamtio iio RHEL - 6).
# chkconfig htpd on (tt eioable the ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart htpd (tt start the webser er
deamtio iio RHEL - 7).
# systemctl enable htpd (tt eioable the ser ice at ioext
bttt iio RHEL - 7).
(e). Add the ser ice tt the IP tables aiod frewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ser ice=http
# frewall-cmd --ctmplete-reltad
(f). Gt tt clieiot system tpeio the freftx brtwser aiod type as htp://server9.example.com
iio address bar aiod check the guser defioed web paie is displayed tr iott.
(i). We caio alst access the website gusiioi elinks CLI tttl.
# yum install elinks* -y (iiostall the
eliioks packaie).
# elinks --dump server9.example.com (access the
iiodex paie).
17. How to configure CGI based web hosting?
CGI ctioteiot will chaioie dyioamically e ery tme the clieiot accessed it. Ntrmal web ser er will
iott be gused tt sgupptrt this type tf web htstioi. Tt access these dyioamic paies we ha e tt

Ratnakar Page 183


[Pick the date] [LINUX NOTES FOR LEVEL 2]

ctiofigure the web ser er as ".wsii" ser er. The ftlltwiioi steps will ctiofigure the CGI web
ser er.
(a). Iiostall the CGI packaie by # yum install mod_wsgi* -y ctmmaiod.
(b). Dtwioltad tr create the CGI script fle iio web ser er's dtcgumeiot rttt directtry.
Example : # cp webapp.wsii /S ar/Swww/Shtml
(c). Create the ctiofigurattio fle ftr CGI based web htstioi.
<VirtgualHtst 172.25.9.11:80>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName webapp9.example.ctm
DtcgumeiotRttt /S ar/Swww/Shtml
WSGIScriptAlias /S /S ar/Swww/Shtml/Swebapp.wsii
</SVirtgualHtst>
(d). Restart the web ser er deamtio.
# service htpd start (tt start the webser er
deamtio iio RHEL - 6).
# chkconfig htpd on (tt eioable the ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart htpd (tt start the webser er
deamtio iio RHEL - 7).
# systemctl enable htpd (tt eioable the ser ice at ioext
bttt iio RHEL - 7).
(e). Add the ser ice tt the IP tables aiod frewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 80 -j ACCEPT
# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ser ice=http
# frewall-cmd --ctmplete-reltad
(f). Gt tt clieiot system tpeio the freftx brtwser aiod type as htp://webapp9.example.com
iio address bar aiod check the CGI based web paie is displayed tr iott.
(i). We caio alst access the website gusiioi elinks CLI tttl.
# yum install elinks* -y (iiostall the
eliioks packaie).
# elinks --dump webapp9.example.com (access the
iiodex paie).
18. What is secured web server?
Secgured web ser er meaios iotrmal Apache web ser er with SSL sgupptrt. Iio iotrmal web
ser er the data ctmmguioicattio is dtioe iio plaiio text ftrmat. St there is iot secgurity ftr data

Ratnakar Page 184


[Pick the date] [LINUX NOTES FOR LEVEL 2]

becaguse e erytioe caio access the data. If we waiot tt prt ide secgurity tt the data theio we ha e
tt ctiofigure the web ser er with SSL sgupptrt.
19. What is the profile of secured web server?
Packaie : mod_ssl
Ctiofigurattio fle : /etc/htpd/conf.d/ssl.conf
Pri ate key ltcattio : /etc/pki/tls/private
Pgublic key ltcattio : /etc/pki/tls/certs
Agutheiotcattio certfcate : /etc/pki/tls/certs
Ptrt iogumber : 443
* Pri ate key exteiottio is " . key " aiod pgublic key exteiottio is " . crt "
20. How to configure the secured web server?
(a). Iiostall the web ser er aiod secgure shell packaies.
# yum install htpd* mod_ssl* -y ctmmaiod.
(b). Dtwioltad the pri ate key aiod pgublic certfcates.
# cd /etc/pki/tls/private
# wget htp://classroom.example.com/pub/tls/private/server<no.> . key
# cd /etc/pki/tls/certs
# wget htp://classroom.example.com/pub/tls/certs/server<no.> . crt
# wget htp://classroom.example.com/pub/example-ca.crt
(c). Create the ctiofigurattio fle ftr secgured web ser er.
# vim /etc/htpd/conf.d/htps.conf
<VirtgualHtst 172.25.9.11:443>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName ser er9.example.ctm
DtcgumeiotRttt /S ar/Swww/Shtml
</SVirtgualHtst>
(d). We ha e tt ctpy 7 liioes frtm ssl.ctiof fle tt https.ctiof fle.
# vim -O ssl.conf htps.conf
Ctpy the liioe iogumbers 70 75 80 93 100 107 116 ctpy aiod paste them iio
https.ctiof fle.
St afer ctpied thtse liioe the https.ctiof fle shtguld be as beltw.
<VirtgualHtst 172.25.9.11:443>
Ser erAdmiio rttt@ser er9.example.ctm
Ser erName ser er9.example.ctm
SSLEioiiioe tio
SSLPrtttctl all -SSL 2 -SSL 3
SSLCipherSguite ALL:!ADH:!EXPORT:!SSL 2:RC4+RSA:+HIGH:+MBEDIUMB:+LOW
SSLCertfcateFile /Setc/Spki/Stls/Scerts/Sser er9.crt
SSLCertfcateKeyFile /Setc/Spki/Stls/Spri ate/Sser er9.key
#SSLCertfcateChaiioFile /Setc/Spki/Stls/Scerts/Sexample-ca.crt

Ratnakar Page 185


[Pick the date] [LINUX NOTES FOR LEVEL 2]

DtcgumeiotRttt /S ar/Swww/Shtml
</SVirtgualHtst>
<Directtry "/S ar/Swww/Shtml">
AlltwO erride
Reqguire All Graioted
</SDirecttry> (sa e
aiod exit this fle).
(e). Gt tt dtcgumeiot rttt directtry by # cd /var/www/html ctmmaiod.
(f). # vim index.html
<html>
<H1>
This is a secgured web htstioi
</SH1>
</Shtml>
(sa e aiod exit this fle).
(i). Restart the web ser er deamtio.
# service htpd start (tt start the webser er
deamtio iio RHEL - 6).
# chkconfig htpd on (tt eioable the ser ice at ioext
bttt iio RHEL - 6).
# systemctl restart htpd (tt start the webser er
deamtio iio RHEL - 7).
# systemctl enable htpd (tt eioable the ser ice at ioext
bttt iio RHEL - 7).
(h). Add the ser ice tt the IP tables aiod frewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 443 -j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 443 -j ACCEPT
# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ser ice=http
# frewall-cmd --permaioeiot --add-ser ice=https
# frewall-cmd --ctmplete-reltad
(i). Gt tt clieiot system tpeio the freftx brtwser aiod type as htps://server9.example.com/
iio address bar aiod check the secgured web paie is displayed tr iott.
21. How to generate our own private and public keys using crypto-utils package?
(i). Iiostall the packaie by # yum install crypto-utils* -y ctmmaiod.
(ii). Create tgur twio pgublic aiod pri ate keys by # genkey <hostname of the server>
ctmmaiod.

Ratnakar Page 186


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Example : #ieiokey ser er9.example.ctm (tioe wiiodtw will be tpeioed aiod we ha e tt


eioter the details).
Click tio Next ---> Dtio't chaioie the defagult sise ---> Next ---> Nt --->The keys
are ieioerated iio
their directtries.
Other useful commands :
# httpd -t (tt check the web ser er ctiofigurattio fle ftr
syiotax errtrs).

21. Mail Server

1. What is mail server?


A mail ser er (stmetmes alst referred tt aio e-mail ser er). is a ser er that haiodles aiod deli ers
e-mail t er a ioetwtrk gusgually t er the Iioterioet. A mail ser er caio recei e e-mails frtm clieiot
ctmpguters aiod deli er them tt tther mail ser ers. A mail ser er caio alst deli er e-mails tt
clieiot ctmpguters. A clieiot ctmpguter is iotrmally the ctmpguter where ytgu read ytgur e-mails ftr
example ytgur ctmpguter at htme tr iio ytgur tfce. Alst aio ad aioced mtbile phtioe tr
Smartphtioe with e-mail capabilites caio be reiarded as a clieiot ctmpguter iio these
circgumstaioces.
2. How many types of mail servers available in Linux?
There are twt types tf mail ser ers.
(i). Sendmail server (defagult iio RHEL - 5 a ailable iio 6 aiod 7).
(ii). Postfix (defagult iio RHEL - 6 aiod 7).
These btth mail ser er are gused tt seiod aiod recei e the mails bgut we caioiott gused btth mail
ser ers at a tme ie. we ha e tt guse tioly tioe ser er at a tme. These mail ser ers are gused as
CLI mtde. Ogutlttk express iio wiiodtws is gused tt seiod tr recei e the mails. Thguioderbird is
gused tt seiod tr recei e the mails gusiioi GUI mtde iio Liiogux. # mail is the ctmmaiod gused tt
seiod the mails iio CLI mtde.
3. What are MUA, MTA, SMTP, MDA and MRAs?
MUA :
MBUA staiods ftr MBail User Aieiot. It is the e-mail clieiot which we gused tt create-draf-send
emails. Geioerally MBicrtstf Ogutlttk Thguioderbird kmail ....etc. are the examples ftr
MBUAs.
MTA :
MBTA staiods ftr MBail Traiosfer Aieiot. It is gused tt traiosfer the messaies aiod mails betweeio
seioders aiod recipieiots. Exchaioie Qmail Seiodmail Ptstix ....etc. are the examples ftr
MBTAs.
SMTP:

Ratnakar Page 187


[Pick the date] [LINUX NOTES FOR LEVEL 2]

SMBTP staiods ftr Simple MBail Traiosfer Prtttctl. It is gused tt traiosfer the messaies aiod
mails betweeio the MBTAs.
MDA :
MBDA staiods ftr MBail Deli ery Aieiot. It is a ctmpguter stfware ctmptioeiot that is resptiosible
ftr the deli ery tf e-mail messaies tt a ltcal recipieiot's mailbtx. Withiio the Iioterioet mail
architectgure ltcal messaie deli ery is achie ed thrtguih a prtcess tf haiodliioi messaies frtm
the messaie traiosfer aieiot aiod sttriioi mail iiott the recipieiot's eio irtiomeiot (typically
a mailbtx)..
MRA :
MBRA staiods ftr MBail Retrie al Aieiot. It is a ctmpguter applicattio that retrie es tr fetches e-
mail frtm a remtte mail ser er aiod wtrks with a mail deli ery aieiot tt deli er mail tt a ltcal tr
remtte email mailbtx. MBRAs may be exterioal applicattios by themsel es tr be bguilt iiott a
biiier applicattio like aio MBUA. Siiioifcaiot examples tf staiodaltioe MBRAs
iioclgude fetchmail ietmail aiod retchmail.
4. What is the profile of mail server?
Packaie : sendmail (iio RHEL - 5 6 aiod 7). tr postfix (iio RHEL - 6
aiod 7)..
Ctiofigurattio fle : /etc/postfix/main.cf, /etc/dovecot/dovecot.conf
Lti fle : /var/log/mail.log
User's mails ltcattio : /var/spool/mail/<user name>
rttt guser's mail ltcattio : /var/spool/mail/root
Deamtios : postfix
Ptrt iogumber : 25
5. How to configure the mail server?
The pre-reqguisite ftr mail ser er is DNS. ie. Dtmaiio Namiioi System shtguld be ctiofigured
frst.
(i). Check the htstioame tf the ser er by # hostname ctmmaiod.
(ii). Iiostall the mail ser er packaie by # yum install postfix* dovecot* -y ctmmaiod.
(iii).Opeio the mail ctiofigurattio fle aiod at last type as beltw.
# vim /etc/postfix/main.cf
myhtstioame = ser er9.example.ctm
mydtmaiio = example.ctm
mytriiiio = $mydtmaiio
iioet_iioterfaces = $myhtstioame ltcalhtst
mydestioattio = $myhtstioame ltcalhtst.$ltcaldtmaiio ltcalhtst $mydtmaiio
htme_mailbtx = MBaildir /S (sa e aiod
exit this fle).
(i ). Opeio the aiotther ctiofigurattio fle aiod at last type as beltw.
# vim /etc/dovecot/dovecot.conf

Ratnakar Page 188


[Pick the date] [LINUX NOTES FOR LEVEL 2]

prtttctls = imap ptp3 lmtp (sa e aiod


exit this fle).
( ). Restart the mail ser er ser ices.
# service postfix restart (tt restart the ptstix
deamtio iio RHEL - 6).
# service dovecot restart (tt restart the dt ectt
deamtio iio RHEL - 6).
# chkconfig postfix on (tt eioable the ptstix deamtio at ioext bttt
iio RHEL - 6).
# chkconfig dovecot on (tt eioable the dt ectt deamtio at ioext
bttt iio RHEL - 6).
# systemctl restart postfix doveco0t (tt restart the ptstix aiod dt ectt
deamtios iio RHEL - 6).
# systemctl enable postfix dovecot (tt eioable the deamtios at ioext
bttt iio RHEL - 6).
( i). Add the ser ice tt the IP tables aiod frewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 25 -j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 25 -j ACCEPT
# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ptrt=25/Stcp
# frewall-cmd --ctmplete-reltad
( ii). Seiod a test mail tt the guser.
# mail -s testmail raju
Hi this is a test mail
tk bye... bye .... (exit aiod seiod the
mail by Ctrl + d ).
( iii). Ltiiio as rajgu guser aiod check the mail.
# su - raju
$ ls
$ cd Maildir
$ ls
$ cd new
$ cat <mail name>
6. How to configure mail server as null client in RHEL - 7 ?
(i). Opeio the ctiofigurattio fle aiod at last type as beltw.
# vim /etc/postfix/main.cf
relayhtst = [clieiot9.example.ctm]

Ratnakar Page 189


[Pick the date] [LINUX NOTES FOR LEVEL 2]

iioet_iioterfaces = lttpback-tioly
myioetwtrks = 127.0.0.0/S8 [ : : 1]/S128
mytriiiio = ser er9.example.ctm
mydestioattio =
ltcal_traiosptrt = errtr : ltcal deli ery disabled (sa e aiod
exit this fle).
(ii). Restart the ptstix deamtios.
# systemctl restart postfix
# systemctl enable postfix
(iii). Add the ptstix ser ice tt Firewall.
# firewall-cmd --permanent --add-port=25/tcp
# firewall-cmd --complete-reload
(i ). Seiod a test mail tt the guser.
# mail -s testmail raju or # mut -s testmail raju
Hi this is a test mail
tk bye... bye .... (exit aiod seiod the
mail by Ctrl + d ).
( ). Ltiiio as rajgu guser aiod check the mail.
# su - raju
$ ls
$ cd Maildir
$ ls
$ cd new
$ cat <mail name>
Other useful commands :
* Tt seiod a mail tt the ltcal system iot ioeed tt ctiofigure the mail ser er.
* Tt seiod a mail tt the remtte system theio tioly we ha e tt ctiofigure the mail ser er.
# mail rajgu@ser er9.example.ctm (tt seiod the mail tt the rajgu guser tf
the ser er9).
type the messaie whate er ytgu waiot (press Ctrl + d tt exit aiod seiod
the mail).
# sgu - rajgu (tt switch tt the rajgu guser).
$ mail (tt check the mails tf the rajgu guser).
N abcd
N efih
N ijkl
N miotp (there are ftgur mails iio the mail
btx).
& 1 (tt read the 1st mail).

Ratnakar Page 190


[Pick the date] [LINUX NOTES FOR LEVEL 2]

* If the mail is ioew tioe theio 'N' letter is appears beftre the mail. If it is already seeio
theio there is iot letter beftre the mail.
* press 'q' tt qguit the mail gutlity.
# mail tr mgutt -s " hellt " <guser ioame1><guser ioame2><guser ioame3>
type the matter whate er ytgu waiot (press Ctrl + d tt exit aiod seiod
the mail tt 3 gusers).
$ mail (tt see all the mail iio the mail btx).
&<type the mail iogumber> (tt read the specifed mail by it's iogumber).
& r (tt seiod the replay mail tt that
guser).
& p (tt seiod the mail tt the priioter ftr
priiotioi).
& w (tt write the ctioteiots tf the mail iiott a fle ie. sa e the ctioteiots tf the
mail iioa fle).
& q (tt qguit the mail btx).
& d (tt delete the mail).
& d <mail iogumber> (tt delete the specifed mail by it's
iogumber).
& d 1-20 (tt delete the mails frtm 1 tt 20
iogumbers).
# mail -s "hellt" <guser ioame>@<ser erioame> . <dtmaiio ioame> (tt seiod the mail tt the
remtte system).
# mailq (tt see the mails iio the qguegue).
* If the mail ser er is iott ctiofigured tr iott rguioioiioi theio the seiot mails will be iio the qguegue.
# mail -s "hellt" <guser ioame1><guser ioame2><<File ioame> (seiod the mail with
attached fle tt
the 2 gusers).
# ptstixcheck (tt erify the mail ctiofigurattio fle ftr
syiotax errtrs).

Ratnakar Page 191


[Pick the date] [LINUX NOTES FOR LEVEL 2]

22. iSCSI (Remote Storage)

1. What is storage?
The memtry where we caio sttre the data sguch as fles directtries ...etc. is called the
sttraie. Sttraie is maiioly twt types. (i). Ltcal sttraie aiod (ii). Remtte Sttraie.
(i). Local storage :
Ltcal sttraie is a sttraie which is directly ctioioected tt tgur system aiod ready tt guse.
Example : Ltcal hard disk ltcal peio dri e DAS (Direct Access Sttraie). ... etc.
(ii). Remote storage :
The sttraie which is iott ctioioected tt tgur system directly bgut allttted stme space tt tgur
system iio remtte ltcattio is called remtte sttraie.
Example : iSCSI (Iioterioet Small Ctmpguter System Iioterface). SAN (Sttraie Area
Netwtrk). NAS (Netwtrk Area Sttraie).
2. What is iSCSI and explain it?
iSCSI is a way tf ctioioectioi sttraie de ices t er a ioetwtrk gusiioi TCP/SIP. It caio be gused t er a
ltcal area ioetwtrk (LAN). a wide area ioetwtrk (WAN). tr the Iioterioet.
iSCSI de ices are disks tapes CDs aiod tther sttraie de ices tio aiotther ioetwtrked ctmpguter
that ytgu caio ctioioect tt. Stmetmes these sttraie de ices are part tf a ioetwtrk called a Storage
Area Network (SAN)..
Iio the relattioship betweeio tgur ctmpguter aiod the sttraie de ice tgur ctmpguter is called
aio initiator becaguse it iioitates the ctioioecttio tt the de ice which is called a target.

Ratnakar Page 192


[Pick the date] [LINUX NOTES FOR LEVEL 2]

iSCSI prt ides Remtte ltck tr File Sttraie. MBtst data ceioters keep their sttraie iio
ceiotralised SAN racks. iSCSI prt ides aio iioexpeiosi e alterioat e tt prtprietary SAN
hardware.
3. What is the terminology of iSCSI?
iSCSI sgupptrts seiodiioi SCSI ctmmaiods frtm clieiots (iioitattrs). t er IP tt SCSI sttraie
de ices (tariets). tio remtte systems (ser ers).. iqn is a iSCSI qgualifed ioame tr iogumber.
The ftrmat tf iqio is "iqn.yyyy-mm.<domain name in reverse order>label is gused tt ideiotfy
iioitattrs aiod tariets ctmmguioicate thrtguih ptrt iogumber 3260.
4. What is the profile of iSCSI?
Packaie : iscsi* (ftr RHEL-6). target* (ftr RHEL-7 ser er). aiod iscsi-utils*
(ftr RHEL-7 Clieiot).
Ctiofigurattio fles : /etc/tgt/target.conf (ftr RHEL - 6). aiod
/etc/target/saveconfig.json (ftr RHEL - 7).
Deamtios : titd (ftr RHEL-6). aiod tariet (ftr RHEL-7 ser er). aiod iscsi, iscsid
(ftr RHEL-7).
Ptrt iogumber : 3260
5. How to configure the iSCSI server?
(i). Create tioe partttio aiod create the LVMB with that partttio.
# fdisk <device name>
: n (new partition) ---> Enter ---> Enter ---> Enter ---> +<size in MB/GB/TB> ---> w
(write the changes into the disk)
# partprobe (tt write the chaioies iiott
the partttio table).
# pvcreate <disk partition name> (tt create the physical
tlgume).
# vgcreate <physical volume name> (tt create the tlgume
irtgup).
# lvcreate -s <extent size> -n <logical volume name><vg name> (tt create the
ltiical tlgume).
(ii). Iiostall the iSCSI packaie by # yum install scsi-target-utils -y ctmmaiod iio RHEL - 6 tr
Iiostall the iSCSI packaie by # yum install target* -y ctmmaiod iio RHEL - 7.
(iii). Start the iSCSI deamtio aiod eioable the deamtio at ioext bttt tme.
# service tgtd restart (tt start the iSCSI deamtio
iio RHEL - 6).
# chkconfig tgtd on (tt eioable the iSCSI deamtio at ioext bttt
iio RHEL - 6).
# systemctl start target (tt start the tariet deamtio
iio RHEL - 7).
# systemctl enable target (tt eioable the tariet deamtio at ioext bttt
iio RHEL - 7).

Ratnakar Page 193


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i ). Ctiofigure the iSCSI sttraie.


In RHEL - 6 :
#vi /etc/tgt/targets.conf
defagult-dri er iscsi
<tariet iqio.2015-06.ctm.example:ser er9.tariet1>
backiioi-sttre <iSCSI partttio ioame>
write-cache tfe
</Stariet>
In RHEL - 7 :
# targetcli (tt iet the ctiofigurattio wiiodtw aiod displays "/>"
prtmpt appears).
/S> ls (tt see the ctiofigurattio
ctioteiots).
/S> /Sbacksttres/Sbltck create <bltck sttraie ioame><the abt e created tlgume ioame>
(create the
bltck sttraie).
/S> /Siscsi create iqio.2015-06.ctm.example:ser er9 (tt create the lguio iogumber iott
the lguio ioame).
/S> /Siscsi/Siqio.2015-06.ctm.example:ser er9/Stpi1/Sacls create iqio.2015-
06.ctm.example:ser er9
(tt create the alias ioame ftr clieiot side lguio iogumber).
/S> /Siscsi/Siqio.2015-06.ctm.example:ser er9/Stpi1/Slguios create /Sbacksttres/Sbltck/S<bltck
sttraie ioame>
(tt create the lguio gusiioi the bltck
sttraie de ice).
/S> /Siscsi/Siqio.2015-06.ctm.example:ser er9/Stpi1/Sptrtals create <IP address tf the ser er>
(tt alltt the abt e created lguio tt the IP address aiod ptrt
iogumber ie. 3260).
/S> sa ectiofi (tt sa e the iSCSI ctiofigurattio iiott the
ctiofigurattio fle).
/S> exit (tt exit frtm the
ctiofigurattio wiiodtw).
( ). Restart the iSCSI deamtios afer the ctiofigurattio tf iSCSI tr tariet.
# service tgtd restart (tt start the iSCSI deamtio
iio RHEL - 6).
# chkconfig tgtd on (tt eioable the iSCSI deamtio at ioext bttt
iio RHEL - 6).
# systemctl restart target (tt start the tariet deamtio
iio RHEL - 7).

Ratnakar Page 194


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# systemctl enable target (tt eioable the tariet deamtio at ioext bttt
iio RHEL - 7).
( i). # tgt-admin --show (tt check the iSCSI ctiofigurattio iio RHEL -
6).
( ii). Add the iSCSI ser ice aiod ptrt iogumber tt the IP tables aiod frewall.
In RHEL - 6 :
# iptables-I INPUT -p tcp-m tcp --dptrt3260 -jACCEPT
# iptables-O OUTPUT -p tcp-m tcp --dptrt3260 -jACCEPT
# ser ice iptables sa e
# ser ice iptables restart
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ptrt=3260/Stcp
# frewall-cmd --ctmplete-reltad
6. How to configure the iSCSI client?
(i). Iiostall iscsi-iioitattr-gutls packaie tio the clieiot by # yum install iscsi-initiator-utils* -y
ctmmaiod iio RHEL-6.
Iiostall the iSCSI packaies by # yum install iscsi-utils* -y ctmmaiod iio RHEL - 7.
(ii). Disct er the tariet LUN’s exptrted by ser er gusiioi ftlltwiioi ctmmaiod. It will prt ide iqio
ioame with tf LUN asstciated with ii eio ip address.
# iscsiadm -m discovery -t sendtargets -p <IP address of the server> (iio
RHEL - 6).
# iscsiadm --mode discoverydb --type sendtargets --portals <IP address of the
server) (iio RHEL - 7).
(iii). Opeio the iscsi iioitattr fle aiod pgut aio eiotry tf the abt e disct ered lguio iogumber iio RHEL
- 7 tioly.
# vim /etc/iscsi/initiatorname.iscsi (it tt last liioe
aiod type as beltw).
Iioitattrioame=iqio.2015-06.ctm.example:ser er9 (sa e
aiod exit this fle).
(i ). Restart aiod eioable the iSCSI clieiot side deamtios.
# service iscsi restart (tt restart the iscsi clieiot
deamtio iio RHEL - 6).
# chkconfig iscsi on (tt eioable the iscsi clieiot deamtio at ioext
bttt iio RHEL - 6).
# systemctl restart iscsid iscsi (tt restart the iscsi clieiot
deamtios iio RHEL - 7).
# systemctl enable iscsid iscsi (tt eioable the iscsi clieiot deamtios at ioext
bttt iio RHEL - 7).
( ). Tt ctioioect iSCSI tariet we caio guse ftlltwiioi ctmmaiod we ioeed tt meiottio ser er ip aiod
iqio ioame.

Ratnakar Page 195


[Pick the date] [LINUX NOTES FOR LEVEL 2]

In RHEL - 6 :
# iscsiadm -m node -T iqn.2015-06.com.example:server9.target1–p <IP address of the
server>login
In RHEL - 7 :
# iscsiadm --mode node --targetname iqn.2015-06.com.example:server9 --portal <IP
address of the
server> : 3260 --login
( i). Check the ioew remtte disk ioame by # fdisk -l ctmmaiod.
( ii). Create the reqguired sise partttio gusiioi # fdisk # partprobe ctmmaiods.
( iii). Create the reqguired type tf fle systems by # mkfs.ext4 <above created partition
name> ctmmaiod.
(ix). Create a mtguiot ptiiot ftr the abt e fle system by # mkdir /mnt/iscsi ctmmaiod.
(x). Opeio the /etc/fstab fle aiod pgut eio eiotry tf the abt e fle system iioftrmattio.
# vim /etc/fstab
<partttio ioame> tr <UUID> /Smiot/Siscsi ext4 _ioetde 0 0 (sa e aiod
exit this fle).
(xi). MBtguiot the all the partttios which are ha iioi eiotries iio /etc/fstab fle by # mount -a
ctmmaiod.
(xii). Check all the mtguioted fle systems by # df -hT ctmmaiod.
(xiii). Tt disctioioect iSCSI tariet we caio guse ftlltwiioi ctmmaiods. Dtio't ftriet that ltitgut frtm
the tariet.
In RHEL - 6 :
# iscsiadm -m node -T iqn.2015-06.com.example:server9.target1–p <IP address of the
server>logout
In RHEL - 7 :
# iscsiadm --mode node --targetname iqn.2015-06.com.example:server9 --portal <IP
address of the
server> : 3260 --logout
(xi ). Restart the clieiot system by # init 6 ctmmaiod.
(x ). Afer rebttt check the remtte fle system by # df -hT ctmmaiod.

23. MySQL Server or MariaDB

1. What is MySQL or MariaDB?

Ratnakar Page 196


[Pick the date] [LINUX NOTES FOR LEVEL 2]

MBySQL tr MBariaD is a database stfware tt create aiod maiiotaiio the databases.


Uptt RHEL - 6 the database stfware is MBySQL aiod frtm RHEL - 7 tiowards the database
stfware is MBariaD .
If we waiot tt dt aioy traiosacttios tr database tperattios we ha e tt tpeio the mysql > tr
mariadb > prtmpt.
Iio MBySQL tr MBariaD all the database tperattio ctmmaiods will eiod with a " ; " (semictltio)..
2. What is the profile of MySQL or MariaDB?
Packaie : mysql* (iio RHEL - 6). aiod mariadb* (iio RHEL - 7).
Versitio : 5.0 (iio RHEL - 6). aiod 5.5 (iio RHEL - 7).
Deamtios : mysqld (iio RHEL - 6). aiod mariadb (iio RHEL - 7).
Ctiofigurattio fle : /etc/my.cnf
Iiostallattio
Ctmmaiods : mysql_secure_installation
3. How to configure MySQL or MariaDB?
(i). Iiostall the MBySQL tr MBariadb stfware packaies.
# yum groupinstall mysql* -y (tt iiostall
MBySQL iio RHEL - 6).
# yum groupinstall mariadb* (tt iiostall
MBariadb iio RHEL - 7).
(ii). Restart the mysqld aiod mariadb deamtios.
# service mysqld restart (tt start the mysqld
deamtio iio RHEL - 6).
# chkconfig mysqld on (tt eioable the mysqld deamtio at ioext bttt
iio RHEL - 6).
# systemctl restart mariadb (tt start the mysqld
deamtio iio RHEL - 7).
# systemctl enable mariadb (tt eioable the mysqld deamtio at ioext
bttt iio RHEL - 7).
(iii).Check the mysql ptrt is listeioiioi tr iott.
# netstat -ntulp | grep mysql (it wtrks iio btth
RHEL - 6 & 7).
Where io -----> ioetwtrk t -----> tcp prtttctl gu -----> gudp
prtttctl
l -----> listeioiioi tr iott aiod p -----> ptrt iogumber
(i ). If we waiot tt ctiofigure the database as ltcalhtst ie. database will iott be a ailable tt
remtte systems.
# vim /etc/my.cnf (tpeio this fle aiod it tt 2iod liioe create aio empty liioe aiod type
as beltw).
skip-ioetwtrkiioi=1 (sa e aiod
exit this fle).

Ratnakar Page 197


[Pick the date] [LINUX NOTES FOR LEVEL 2]

( ). Restart the mysqld aiod mariadb deamtios.


# service mysqld restart (tt start the mysqld
deamtio iio RHEL - 6).
# chkconfig mysqld on (tt eioable the mysqld deamtio at ioext
bttt iio RHEL - 6).
# systemctl restart mariadb (tt start the mysqld
deamtio iio RHEL - 7).
# systemctl enable mariadb (tt eioable the mysqld deamtio at ioext
bttt iio RHEL - 7).
( i). Iiostall the database eioiiioe. (it wtrks iio
btth RHEL - 6 & 7).
# mysql_secure_installation
Eioter cgurreiot rttt passwtrd : (here dt iott eioter aioy passwtrds aiod jgust press
the Eioter Key).
Set rttt passwtrd [y/Sio] : y
Remt e aioaioymtgus gusers [y/Sio] : y
Disalltw rttt ltiiio remttely [y/Sio] : y
Remt e test database aiod access tt it [y/Sio] : y
Reltad the pri ilaies tables iotw [y/Sio] : y
( ii). Ltiiio iiott the mysql ser er as a rttt guser.
# mysql -u root -p (where gu -----> guser aiod p ----->
gusiioi passwtrd).
(we ha e tt eioter the passwtrd ftr rttt guser).
( iii). See the defagult databases.
mysql > show databases; (iio RHEL - 6).
mariadb > show databases; (iio RHEL - 7).
(ix). Exit frtm the database by mysql > exit; (iio RHEL - 6). aiod mariadb > exit; (iio RHEL - 7).
4. How to create a database, create tables, enter the data into the tables and access that
data?
(i). Ltiiio iiott the database ser er by # mysql -u root -p ctmmaiod.
(ii). Create the database aiod ctioioect the databases.
mysql or mariadb > create database <database ioame> (tt
create the database).
mysql or mariadb>shtw databases (tt see all the
databases iio the ser er).
mysql or mariadb > guse <database ioame> (tt ctioioect tt the
specifed database).
(iii). Create a table eioter the data aiod qguery the data.
mysql or mariadb > create table <table ioame> (feld ioame1 data type (sise).
feld ioame2 data type (sise).

Ratnakar Page 198


[Pick the date] [LINUX NOTES FOR LEVEL 2]

feld ioame3 data type (sise).).


Example : mysql tr mariadb > create table mydetails (Name archar (30). statgus
archar (10).
Address archar (50). phtioe iiot
(10).).
(i ). See the strguctgure tf the table.
mysql or mariadb >describe<table ioame> (tt see the strguctgure tf the
table).
Example : mysql tr mariadb > describe mydetails
( ). Iiosert tr eioter the data iiott the table.
mysql or mariadb > iiosert iiott mydetails algues ("Rajgu" "Siioile" Hyderabad"
9848750755).
( i). Qguery the table tt iet the data.
mysql or mariadb >select * frtm mydetails (tt see all the
rectrds tf the tables).
mysql or mariadb > select ioame phtioe frtm mydetails (tt select the waioted data ie.
flteriioi the data).
5. How to take a backup of the database, drop the database and restore the database using
backup?
Tt take a backgup tr resttre tf the database frst we shtguld ctmetgut frtm the database ser er
aiod theio take a backgup tr resttre the backgup.
(i). Exit the frtm the database ser er.
mysql or mariadb > exit
(ii). Take a backgup tf the database.
# mysqldump -u root -p <database name>><file name with full path>
Example : # mysqldgump -gu rttt -p mydetails > /Srttt/Smydetails.bak
(iii). Delete the database frtm the database ser er.
mysql or mariadb >drop database <database name>;
Example : mysql tr mariadb > drtp database mydetails
(i ). Resttre the deleted database gusiioi the backgup ctpy.
mysql or mariadb >exit;
# mysql -u root -p <database name><<backup file name with path>
Example : # mysql -gu rttt -p mydetails < /Srttt/Smydetails.bak
6. How to create the user in the database and make the user to do transactions or operations?
(i). Tt create the guser iio the database frst ltiiio tt the database aiod theio create the guser.
mysql or mariadb > create user <user name>@<host name> identified by
"<password>";
Example : mysql tr mariadb > create guser rajgu@ltcalhtst tr ser er9.example.ctm
ideiotfed by
"rajgu123"

Ratnakar Page 199


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). MBake the guser tt dt traiosacttios tio the database. (iotthiioi bgut iraiotioi the permissitio).
mysql or mariadb > grant select, insert, update, delete on <database name>.* to
<user name>; tr
mysql or mariadb > grant all on <database name> .* to <user name>;
Example : mysql tr mariadb > iraiot select iiosert gupdate delete tio mydetails .* tt
rajgu tr
mysql tr mariadb > iraiot all tio mydetails .* tt rajgu
(where database . * meaios iraiotioi permissitios tio all the ctioteiots like tables iiodexes
iews
syiotioyms aiod tthers).
7. How to update the table in the database with new data?
mysql or mariadb > update <table name><field name>=<new value> where <primary
key field
name>="<value>";
Example : mysql tr mariadb > gupdate mydetails ioame="baioiaram" where ioame='rajgu'
8. How to delete the table from the database?
mysql or mariadb > drop table <table name>;
Example : mysql tr mariadb > drtp table mydetails
9. How to connect the remote database from our system?
# mysql -u root -h <host name> -p (here we ha e tt eioter
the passwtrd).
Example : # mysql -gu rttt -h ser er9.example.ctm -p
(If the database is ctiofigured as ltcalhtst database theio ser er will iott alltw remtte
database ctioioecttios aiod Permission denied messaie will be displayed tio the screeio).
10. How to add mysqld service to IPtables and mariadb service to firewall?
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deptrt 3306 -j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deptrt 3306 -j ACCEPT
# ser ice iptables sa e
# ser ice iptables restart
# chkctiofi iptables tio
In RHEL - 7 :
# frewall-cmd --permaioeiot --add-ptrt=3306
# frewall-cmd --ctmplete-reltad

Ratnakar Page 200


[Pick the date] [LINUX NOTES FOR LEVEL 2]

24. Log Server and Log Files

1. What is log server?


A lti ser er represeiots a ceiotral lti mtioittriioi ptiiot tio a ioetwtrk tt which all kiiods tf
de ices iioclgudiioi Liiogux tr Wiiodtws ser ers rtguters switches tr aioy tther htsts caio seiod their
ltis t er ioetwtrk. y setioi gup a lti ser er ytgu caio flter aiod ctiostlidate ltis frtm difeereiot
htsts aiod de ices iiott a siioile ltcattio st that ytgu caio iew aiod archi e imptrtaiot lti
messaies mtre easily.
Oio mtst Liiogux distribguttios rsyslti is the staiodard syslti daemtio that ctmes pre-iiostalled.
Ctiofigured iio a clieiot/Sser er architectgure rsyslti caio play btth rtles as a syslti
ser er rsyslti caio iather ltis frtm tther de ices aiod as a syslti clieiot rsyslti caio traiosmit its
iioterioal ltis tt a remtte syslti ser er.
Wheio ltis are ctllected with syslti mechaioism three imptrtaiot thiiois mgust be takeio iiott
ctiosiderattio:
 Facility level: what type tf prtcesses tt mtioittr
 Severity (priority) level: what type tf lti messaies tt ctllect
 Destination: where tt seiod tr rectrd lti messaies
2. What is the profile of log server?
This is alst called as rsyslti ser er. The reqguiremeiots are ii eio beltw.
(i). Packaie : rsyslog*
(ii). Deamtio : rsyslog
(iii).Ptrt Nt. : 514
(i ). Ctiofigurattio fle : /etc/rsyslog.conf
3. How to configure the log server?
(i). Iiostall rsyslti packaie by # yum install rsyslog* -y ctmmaiod.
(ii). Opeio the lti ser er ctiofigurattio aiod fle aiod edit as per reqguiremeiots.
# vim /etc/rsyslog.conf
Gt tt liioe iot. : 15 & 16 aiod guioctmmeiot tio thtse liioes. (sa e aiod
exit this fle).
(iii).Restart the lti ser er deamtio iio RHEL - 6 aiod RHEL - 7.
# service rsyslog restart (tt restart the lti ser er
deamtio iio RHEL - 6).
# chkconfig rsyslog on (tt eioable the lti ser er deamtio at ioext
bttt iio RHEL - 6).

Ratnakar Page 201


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# systemctl restart rsyslog (tt restart the lti ser er


deamtio iio RHEL - 7).
# systemctl enable rsyslog (tt eioable the lti ser er deamtio at ioext
bttt iio RHEL - 7).
(i ). Verify whether the lti ser er is listeioiioi tr iott.
# netstat -ntulp | grep 514
( ). Add the lti ser er ser ice tt IPtables.
# iptables -A INPUT -p tcp -m tcp --deport 514 -j ACCEPT (tt add the
iioctmiioi ptrt iot. tt
Iptables iio RHEL - 6).
# iptables -A INPUT -p udp -m udp --deport 514 -j ACCEPT (tt add the
iioctmiioi ptrt iot. tt
Iptables iio RHEL - 6).
# iptables -A OUTPUT -p tcp -m tcp --deport 514 -j ACCEPT (tt add the
tgutitiioi ptrt iot. tt
Iptables iio RHEL - 6).
# iptables -A OUTPUT -p udp -m udp --deport 514 -j ACCEPT (tt add the
tgutitiioi ptrt iot. tt
Iptables iio RHEL - 6).
# firewall-cmd --permanent -add-port=514/tcp (tt add the 514 tcp ptrt iot.
tt the frewall).
# firewall-cmd --permanent -add-port=514/udp (tt add the 514 gudp ptrt
iot. tt the frewall).
# firewall-cmd --complete-reload (tt reltad the
frewall ctiofigurattio).
4. How to configure the client system to send log messages to the log server?
(i). Opeio the lti ser er ctiofigurattio fle by # vim /etc/rsyslog.conf ctmmaiod.
(ii). Gt tt liioe iot. 90 aiod type as beltw.
*.*@<log server IP address> : 514
Example : *.* @172.25.9.11:514 (sa e aiod exit this
fle).
(iii).Restart the lti ser er deamtios iio RHEL - 6 aiod RHEL - 7.
# service rsyslog restart (tt restart the lti ser er
deamtio iio RHEL - 6).
# chkconfig rsyslog on (tt eioable the lti ser er deamtio at ioext
bttt iio RHEL - 6).
# systemctl restart rsyslog (tt restart the lti ser er
deamtio iio RHEL - 7).
# systemctl enable rsyslog (tt eioable the lti ser er deamtio at ioext
bttt iio RHEL - 7).

Ratnakar Page 202


[Pick the date] [LINUX NOTES FOR LEVEL 2]

* Theio all the lti messaies are sttred iio /var/log/secure ltcattio.
* Tt mtioittr all the messaies tio the ser er by # tailf /var/log/secure ctmmaiod.
* Opeio the /etc/rsyslog.conf fle aiod type as beltw tt sttre all the clieiot's lti messaies iio
remtte lti ser er tioly.
# vim /etc/rsyslog.conf
*.* /S ar/Slti/Ssecgure (sa e aiod
exit this fle).
* Theio restart the lti ser er deamtios iio RHEL - 6 aiod RHEL - 7.
# service rsyslog restart (tt restart the lti ser er
deamtio iio RHEL - 6).
# systemctl restart rsyslog (tt restart the lti ser er
deamtio iio RHEL - 7).
5. What is log file?
Lti fle is fle that ctiotaiios messaies abtgut that system iioclgudiioi the kerioel ser ices aiod
applicattios rguioioiioi tio it ....etc. There are difeereiot lti fles ftr difeereiot iioftrmattio. These
fles are ery gusefgul wheio tryiioi tt trtgubleshttt a prtblem with systems.
Almtst all lti messaies are sttred iio /var/log directtry. Oioly rttt guser caio read these lti
messaies. We caio guse less tr mtre ctmmaiods tt read these lti fles. The messaies will be
ieioerated tioly wheio rsyslti ser ice is rguioioiioi ttherwise the lti messaies will iott be
ieioerated.
The diferent types of log files and their locations :
/var/log/messages -----> System aiod ieioeral messaies aiod DHCP lti messaies.
/var/log/authlog -----> Agutheiotcattio lti messaies.
/var/log/secure -----> Secgurity aiod agutheiotcattio aiod guser lti messaies.
/var/log/maillog -----> MBail ser er lti messaies.
/var/log/cron -----> Crtio jtbs lti messaies.
/var/log/boot.log -----> All btttioi lti messaies.
/var/log/htpd -----> All Apache web ser er lti messaies.
/var/log/mysqld.log -----> MBysql database ser er lti messaies.
/var/log/utmp tr /var/log/wtmp -----> All the guser's ltiiio messaies.
/var/log/Qmail -----> Qmail lti messaies.
/var/log/kernel.log -----> All kerioel related lti messaies.
/var/log/samba -----> All samba ser er lti messaies.
/var/log/anakonda.log -----> Liiogux iiostallattio lti messaies.
/var/log/lastlog -----> Receiot ltiiio iioftrmattio ftr all gusers.
# lastlog (tt see the lti messaies tf the
abt e lti fle).
/var/log/yum.log -----> All packaie iiostallattio lti messaies ieioerated by # ygum tr # rpm
ctmmaiods.
/var/log/cups -----> All priioter aiod priiotioi related lti messaies.

Ratnakar Page 203


[Pick the date] [LINUX NOTES FOR LEVEL 2]

/var/log/ntpstat -----> All iotp ser er aiod ser ices lti messaies.
/var/log/spooler -----> MBail priioter aiod crtio jtbs spttliioi messaies.
/var/log/sssd -----> System secgurity ser ice deamtio lti messaies.
/var/log/audit.log -----> SELiiogux lti messaies.
# dmesg (tt see the bttt lti messaies).
# tailf or # tail -f /var/log/secure (tt check tr watch the lti fles
ctiotiogutgusly).
# vim /etc/rsyslog.conf (we caio chaioie the lti messaies
defagult destioattios).
* Wheioe er we chaioie the ctioteiots tf the /etc/rsyslog.conf fle theio we ha e tt restart
the rsyslti ser ice.
* There are 7 types tf pritrity messaies. We caio chaioie the defagult destioattio tf thtse lti
fles. Ftr that
tpeio rsyslti ser er ctiofigurattio fle aiod we ha e eioter the rgules as ftlltws.
# vim /etc/rsyslog.conf
<pritrity type> . <pritrity ioame> <ioew destioattio tf the lti fles> (sa e aiod
exit this fle).
# logger <type any text> (tt seiod that text iiott /var/log/messages fles aiod tt test
whether ltiiiioi
ser ice is rguioioiioi tr iott).
# logrotate (tt create the lti fles with datewise).
* Geioerally iio lti messaies the felds are
Date & Time : From which system : command name or change : Execution of the
command
# yum install tmpwatch -y (tt iiostall the tmpwatchpackaie tt execgute the beltw
ctmmaiod).
# tmpwatch (tt mtioittr the /tmp directtry).
# logwatch (tt mtioittr the lti messaies).
# yum install watch -y (tt iiostall the watch packaie tt execgute the beltw
ctmmaiod).
# watch <command> (tt watch the specifed ctmmaiod resgults ctiotiogutgusly).
# mkdir mode=755 /ram (tt ii e the permissitios tt the directtry while creatioi that
directtry).
# journalctl (it tracks all the lti fles betweeio twt difeereiot tmiiois aiod
sa e by defagult
iio /run/log ltcattio).
* /run/log is mtguioted tio tmpfs fle system ie. if the system is rebttted the whtle
iioftrmattio iio that
ltcattio will be deleted tr erased.

Ratnakar Page 204


[Pick the date] [LINUX NOTES FOR LEVEL 2]

25. Configuring IP tables and Firewall

1. What are IPtables or firewalls?


IP tables is a ctmmaiod-liioe frewall gutlity that guses ptlicy chaiios tt alltw tr bltck trafc. Wheio
a ctioioecttio tries tt establish itself tio ytgur system iptables lttks ftr a rgule iio its list tt match it
tt. If it dtesio’t fiod tioe it restrts tt the defagult acttio. IP tables almtst always ctmes pre-
iiostalled tio aioy Liiogux distribguttio.
We caio gupdate/SReiiostall the IP tablespackaie by # yum install iptables* -y ctmmaiod.
2. What are the types of firewalls?
There are ftgur types tf frewalls.
(i). Packet firewalls :
 It wtrks atPhysical Data Liiok aiod Netwtrk Layers.
 It wtrks fast aiod efcieiotly.
 It treats each packet iio istlattio.
(ii). Statefull firewalls :
 It ideiotfes a packets ctioioecttio state.
 It maiiotaiios packets histtry iio the state tables.
(iii). Application layer firewalls :
 It iiospects aiod flter packets tio OSI layer guptt Applicattio Layer.
 It ideiotfes if prtttctls are beiioi misgused.
(i ). Proxies firewalls :
 It acts as aio iiotermediary.
 It tperates at Applicattio Layer.
 It wtio't alltw direct ctioioecttios.
3. What are the tables maintained by IP tables?

Ratnakar Page 205


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Ntrmally IP tables maiiotaiio 3 tables.


(i). INPUT table:
This chaiio haiodles all packets that are addressed tt ytgur ser er aiod alst tt ctiotrtl the
beha itgur ftr iioctmiioi ctioioecttios. Ftr example if a guser attempts tt SSH iiott
ytgur PC/Sser er iptables will attempt tt match the IP address aiod ptrt tt a rgule iio the iiopgut
chaiio.
(ii). OUTPUT table :
This chaiio ctiotaiios rgules ftr trafc created by ytgur ser er. This chaiio is gused ftr tgutitiioi
ctioioecttios. Ftr example if ytgu try tt piioi google.com iptables will check its tgutpgut chaiio tt
see what the rgules are reiardiioi piioi aiod google.combeftre makiioi a decisitio tt alltw tr
deioy the ctioioecttio attempt.
(iii).FORWARD table :
This chaiio is gused ftr iioctmiioi ctioioecttios that areio’t actgually beiioi deli ered ltcally. Thiiok
tf a rtguter – data is always beiioi seiot tt it bgut rarely actgually destioed ftr the rtguter
itself the data is jgust ftrwarded tt its tariet. Uioless ytgu’re dtiioi stme kiiod tf rtgutioi NATiioi
tr stmethiioi else tio ytgur system that reqguires ftrwardiioi ytgu wtio’t e eio guse this
chaiio.This chaiio is gused tt deal with trafc destioed ftr tther ser ers that are iott created
tio ytgur ser er. This chaiio is basically a way tt ctiofigure ytgur ser er tt rtgute reqguests tt
tther machiioes.
4. What are the meanings of REJECT, DROP and ACCEPT ?
REJECT :
REJECT meaios ser er recei es the FTP reqguest frtm the specifed IP address aiod rejects
that reqguest aiod
alst seiod the ackiotwlediemeiot.
DROP :
DROP meaios ser er recei es the FTP reqguests frtm the specifed IP address aiod drtp the
reqguest withtgut seiodiioi aioy ackiotwlediemeiot.
ACCEPT :
ACCEPT meaios ser er recei es the FTP reqguests frtm the specifed IP address aiod alltw
that system ftr FTP ser ices.
5. What is the configuration file of IP tables and what are the options available in IP tables
command?
/etc/sysconfig/iptables is the ctiofigurattio fle tf IP tables.
# iptables <options><chain> firewall-rule (tt
execgute the IP tables).
The tpttios are as ftlltws.
-A -----> Add tr appeiod the rgule.
-p -----> Iiodicates the prtttctl ftr that rgule (tcp gudp icmp ....etc. )..
-s -----> Iiodicates the stgurce tf the packet (IP address Netwtrk ID tr Htstioame)..
-d ----->Iiodicates the destioattio tf the packet.

Ratnakar Page 206


[Pick the date] [LINUX NOTES FOR LEVEL 2]

-j -----> 'Jgump tt tariet' iiodicates the iioterface thrtguih which the iioctmiioi packets are
ctmiioi thrtguih the INPUT FORWARD aiod PREROOTING chaiio.
-t -----> 'Ogutpgut Iioterface' iiodicates the iioterface thrtguih which the tgutitiioi packets
are seiot thrtguih the INPUT FORWARD aiod PREROOTING chaiio.
-sptrt tr -stgurce-ptrt -----> Stgurce ptrt ftr -p tcp tr -p gudp.
-dptrt tr -destioattio-ptrt -----> Destioattio ptrt ftr -p tcp tr -p gudp.
6. How to allow a ping from outside to inside and inside to outside?
# iptables -A INPUT -p icmp --icmp-type echt-reqguest -j ACCEPT
# iptables -A OUTPUT -p icmp --icmp-type echt-reply -j ACCEPT
# iptables -A OUTPUT -p icmp --icmp-type echt-reqguest -j ACCEPT
# iptables -A INPUT -p icmp --icmp-type echt-reply -j ACCEPT
7. In how many ways can we protect the network?
There are 4 ways tt prttect the ioetwtrk.
(i). SELiiogux
(ii). IP tables
(iii). Firewalld
(i ). TCP wrappers
IP tables aiod frewalld btth are gused tt prttect tgur systems ser ices frtm tgutside. gut we caio
guse tioly tioe way at a tme.
8. How to configure the firewalld?
(i). Iiostall the frewalld packaie by # yum install firewalld* -y ctmmaiod.
(ii). Check whether the frewalld packaie is iiostalled tr iott by # rpm -qa firewalld
ctmmaiod.
(iii).Check the statgus tf the frewalld by execgutioi the beltw ctmmaiods.
# systemctl status firewalld tr # firewall-cmd --status
Examples of IP tables commands :
# ser ice iptables statgus (tt check the IP
tables statgus).
# ser ice iptables start (tt start the
IP tables).
# ser ice iptables sttp (tt sttp the
IP tables).
# ser ice iptables restart (tt restart
the IP tables).
# ser ice iptables sa e (tt sa e the iptable
rgules permaioeiotly).
# chkctiofi iptables tio (tt eioable the
iptables at ioext bttt).
# chkctiofi iptables tfe (tt disable the
iptables at ioext bttt).

Ratnakar Page 207


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# iptables -A INPUT -i eth0 -p tcp --deptrt 22 -j ACCEPT (tt add the rgules tt
the existioi
iptables tt alltw ssh).
where -A ---> Add tr appeiod a rgule tt the INPUT chaiio ftr iioctmiioi trafc.
-i eth0 ---> Iioctmiioi packets thrtguih the iioterface eth0 will be erifed aiaiiost this
added ioew rgule.
-p tcp -deptrt 22 ---> prtttctl is tcp aiod the destioattio ptrt is 22.
-j ACCEPT ---> Accept the packet.
# iptables -A INPUT -p tcp -m state --state NEW -m tcp --deptrt 80 -j ACCEPT
(tt
alltw http trafc).
# iptables -A INPUT -s 9.9.9.9 -p tcp -m state --state NEW -m tcp --deptrt 443 -j
ACCEPT
(tt
alltw https trafc).
# iptables -A INPUT -i eth0 -p tcp --deptrt 22 -m state --state NEW ESTA LISHED
-j ACCEPT aiod # iptables -A INPUT -t eht0 -p tcp --sptrt 22 -m state --state
ESTA LISHED -j ACCEPT
(tt alltw ssh iiopgut aiod tgutpgut tio ptrt iogumber 22 thrtguih a de ice eth0).
# iptables -A IN PUT -p gudp -m state --state NEW -m gudp --deptrt 161 -j ACCEPT
(tt alltw SNMBP trafc thrtguih ptrt iogumber 161).
# iptables -P INPUT DROP (tt bltck
the iiopgut trafc).
# iptables -P FORWARD DROP (tt bltck
the ftrward trafc).
# iptables -p OUTPUT DROP (tt bltck
the tgutpgut trafc).
(where P is capital letter).
# iptables -A INPUT -s 9.9.9.9 -j DROP (tt bltck the
9.9.9.9 iiopgut trafc).
# iptables -L (tt see the list
tf the IP tables).
# iptables -F (tt fgush the iptable rgules iotthiioi bgut
deletioi all the rgules).
* Dtio't rguio this ctmmaiod tio prtdgucttio ser ers tr real tme eio irtiomeiot.
# iptables -sa e > /Srttt/Siptables (tt sa e all the existioi iptables rgules as backgup ctpy iio
/Srttt/Siptables fle).
# iptables -F (tt delete
all iptables rgules).

Ratnakar Page 208


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# iptables -resttre < /Srttt/Siptables (tt resttre the IP tables frtm


the backgup fle).
# iptables -I INPUT -s <IP address> -p tcp --deptrt 21 -j <REJECT> tr <DROP> tr
<ACCEPT>
(tt REJECT tr DROP tr ACCEPT the FTP reqguests frtm the specifed IP address system).
# iptables -I INPUT -s <IP address>/S<ioet mask as 8/S16/S24> -p tcp --deptrt 21 -j
<REJECT> tr
<DROP> tr <ACCEPT>
(tt REJECT DROP tr ACCEPT the FTP reqguests frtm all the systems iio that ioetwtrk ).
# iptables -I INPUT -s <IP address>/S<ioet mask as 8/S16/S24> -p tcp -j <REJECT> tr
<DROP> tr <ACCEPT>
(tt REJECT DROP tr ACCEPT all the reqguests frtm the specifed system all the systems
iio that ioetwtrk).
# watch -d -io 5 free (tt repeat a free ctmmaiod ftr
e ery 5 sectiods).
* Defagult is ftr e ery 2 sectiods. -d tpttio hiihliihts the chaioie. Press Ctrl+c tt qguit
frtm the abt e ctmmaiod.
# piioi -a 192.168.10.1 (tt piioi the IP address with agudiable piioi ie.
it makes iotises).
# shred -io 5 trail.txt (tt t er write the trail.txt fle f e tmes
defagult is 3 tmes).
# shred -gu 5 trail.txt (tt remt e a fle
afer t er writioi).
* This shed tttl may iott wtrk iio jtgurioaliioi tr RAID fle systems.
# fle <fle ioame> (tt kiotw what type
fle is that).
# mtr <IP address> (tt check the ctioioecttio betweeio the stgurce aiod
the destioattios).
* The abt e ctmmaiod ii es the reptrt ctiotiogutgusly guiotl the guser press Ctrl+c.
# http (it is aio imprt ed top ctmmaiod aiod it alltws tt scrtll ertcally
tr htristiotally).
# ltisa e flelist.txt ls -l (tt captgure the tgutpgut tf aioy ctmmaiod aiod sttres it iio a
fle altioi with the startioi aiod
eiodiioi tme tf the ctmmaiod).
# lttk "priiot" a ltree.c (tt display all the liioes iio a fle that start with a
partcgular striioi aiod
perftrmaioce tf this ctmmaiod is mtre thaio irep).
# stat <fle ioame> (tt display the statgus tf a fle tr fle system like abstlgute path tf
the fles the iot tf bltcks gused by the fle the I/SO bltck sise iiotde access specifer access
tme tme tf mtdifcattio ....etc).

Ratnakar Page 209


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# mc (it is a ptwerfgul text based fle maioaier aiod it is a directtry brtwsiioi tttl
aiod alltws tt see thectioteiots tf
the archi ed fles ...etc. ).
* Iio RHEL - 6 we ha e tt write the rgules aiod reigulattios tt alltw tr deioy the system bgut iio
RHEL - 7 we ha e
eioable tr disable the frewalld tpttios tioly.
# frewall-ctiofi (tt maioaie the frewalld ser ices gusiioi
iraphical guser mtde).
# frewall-cmd --iet-stioes (tt display all
a ailable stioes).
# frewall-cmd --iet-defagult-stioe (tt check the defagult stioe the defagult stioe
is public zone).
# frewall-cmd --set-defagult-stioe=wtrk (tt act ate the wtrk stioe iotthiioi bgut
chaioiiioi defagult
stioe temptrarily).
# frewall-cmd --permaioeiot --set-defagult-stioe=wtrk (tt set the defagult stioe as wtrk
permaioeiotly).
# frewall-cmd --iet-act ate-stioes (tt display which stioe is aio act e with IP address aiod
iioterface eth0).
# frewall-cmd --add-ser ice=172.25.0.0/S24 --stioe=pgublic (tt add the stgurce tt the pgublic
stioe temptrarily).
# frewall-cmd --iet-act ate-stioe (tt see the defagult stioe
which is act ated).
# frewall-cmd --permaioeiot -add-stgurce=172.25.0.0/S24 --stioe=pgublic
(tt add the IP address tt pgublic
stioe permaioeiotly).
# frewall-cmd --remt e -stguce =172.25.0.0/S24 --stioe=pgublic (tt remt e the iP address
frtm pgublic stioe
temptrarily).
# frewall-cmd --permaioeiot --remt e-stgurce=172.25.0.0/S24 --stioe=pgublic
(tt remt e the iP address frtm pgublic
stioe permaioeiotly).
# frewall-cmd --add-iioterface=eth1 --stioe=pgublic (tt chaioie the iioterface tr add
iioterface tt the
pgublic stioe temptrarily).
# frewall-cmd --permaioeiot --add-iioterface=eth1 --stioe=pgublic (tt chaioie the
iioterface tr add iioterface
tt the pgublic stioe permaioeiotly).
# frewall-cmd --iet-act e-stioes (tt see the
act ated stioes).

Ratnakar Page 210


[Pick the date] [LINUX NOTES FOR LEVEL 2]

* All rgules what we ha e writteio are temptrary. If the system is rebttted theio all chaioied
algues are re ert
back tt it's pre itgus state
* Tt make the chaioied algues permaioeiot theio add --permanent tt all the ctmmaiods set
tf frewalld.
# frewall-cmd --reltad (tt apply the chaioied rgules
immediately).
# frewall-cmd --permaioeiot --add-ser ice=sshd (tt add the sshd ser ice tt frewall
permaioeiotly).
# frewall-cmd --list-ser ices (tt list all the frewall
added ser ices).
# frewall-cmd --list-all (tt list all the all the frewall added ser ices with detailed
iioftrmattio).
# frewall-cmd --permaioeiot --remt e-ser ice=sshd (tt remt e sshd ser ice frtm
frewall permaioeiotly).
# frewall-cmd --permaioeiot --add-ptrt=22/Stcp (tt add the ptrt iogumber 22 with tcp
prtttctl tt frewall
permaioeiotly).
# frewall-cmd --permaioeiot --remt e-ptrt=22/Stcp (tt remt e the ptrt iogumber
22 permaioeiotly).
# frewall-cmd --ctmplete-reltad (frst it guioltad all the frewall setiois aiod aiaiio
reltad the frewall
setiois ctmpletely).
TCP WRAPPERS :
* Firewalld will prttect all the ser ices.
* TCP WRAPPER will alst prttect the ser ices bgut it caio sgupptrt ftr tioly limited ser ices. Aiod
it caio prttect
the ser ices which are ha iioi the libwrap.so mtdgule is ltaded ftr that ser ice.
* St TCPWRAPPER dtes iott sgupptrt tt prttect all the ser ices except libwrap.so mtdgule
ltaded.
# ldd (this ctmmaiod is gused tt check the mtdgules which are ltaded
ftr this ser ices).
# ldd <ser ice ioame with fgull path> (tt display all the ltaded mtdgules tf the
specifed ser ice).
# ldd /Sgusr/Ssbiio/Ssshd (tt display all the ltaded mtdgules tf the
sshd ser ice).
# ldd /Sgusr/Ssbiio/Ssshd | irep -i libwrap.st (tt check whether libwrap.st mtdgule is
ltaded tr iott).
To configure the TCPWRAPPER :

Ratnakar Page 211


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i). Opeio /Setc/Shtsts.deioy tr /Setc/Shtsts.alltw fle by # vim /etc/hosts.deny or


hosts.allow ctmmaiods.
* The abt e fles are tt be edited tr mtdifed tt eioable tr disable the tcpwrapper ser ices
the gusers.
# im /Setc/Shtsts.deioy (Gt tt last liioe aiod type as beltw).
sshd : 172.25.9.11 or system9.example.com (tt deioy the specifed htst tr
htstioame).
sshd : ALL (tt deioy all the clieiots).
sshd : ALL EXCEPT *.eample.com (tt deioy all the clieiots except all
the systems tf
example.ctm dtmaiio).
(ii). sa e aiod exit this fle.
(iii). Opeio /etc/hosts.allow by # vim /etc/hosts.allow ctmmaiod aiod it tt last liioe aiod
type as beltw.
sshd : 172.25.9.11 172.25.6.11 (tt alltw 2
systems tioly).
(i ). sa e aiod exit this fle.
* If the clieiot system's eiotry is there iio btth /Setc/Shtsts.deioy aiod /Setc/Shtsts.alltw fles
theio the
TCPWRAPPER will lttk /Setc/Shtsts.alltw fle frst. Theio it will lttk /Setc/Shtsts.deioy fle. If there is
aio eiotry iio btth the fles theio it will alltw the system becaguse based tio the abt e rgule
frst it will read /Setc/Shtsts.alltw fle aiod alltw the system. It wtio't read the
/Setc/Shtsts.deioy fle.

26. Virtualization

Ratnakar Page 212


[Pick the date] [LINUX NOTES FOR LEVEL 2]

1. What is virtualization?
Virtgualisattio alltws mgultple tperatioi system iiostaioces tt rguio ctiocgurreiotly tio a siioile
ctmpguter it is a meaios tf separatioi hardware frtm a siioile tperatioi system. Each “iguest” OS is
maioaied bya Virtgual MBachiioe MBtioittr (VMBMB). alst kiotwio as a hyper istr. ecaguse the
irtgualisattio system sitsbetweeio the iguest aiod the hardware it caio ctiotrtl the iguests’ guse tf
CPU memtry aiod sttraie e eio alltwiioi a iguest OS tt miirate frtm tioe machiioe tt aiotther.
2. What are types of virtualizations available in Linux?
RHEL - 5 : RHEL - 6 & 7 :
xeio k m
64 bit 64 bit
VT-Eioabled VT-Eioabled
Iiotel/SAMBD Iiotel/SAMBD
2G RAMB 2G RAMB
6G Hard disk 6G Hard disk
3. What are the packages of virtualization and how to install the packages?
(i). qemgu (It is gused tt prt ide guser le el KVMB irtgualisattio aiod disk imaie alst).
(ii). irt (It is gused tt prt ide irtgualisattio stfware).
(iii). lib irt (It is gused tt prt ide the libraries ftr irtgualisattio stfware).
(i ). pythtio (This packaie prt ides the htst aiod ser er libraries ftr iioteractioi with
Hyper istr aiod
Htst system).
# yum install qemu* virt* libvirt* python* -y (tt iiostall the
irtgualisattio stfwares).
4. How to start the virtualization manager and how to create a new virtual machine?
(i). Gt tt Applicattios -----> System Tttls -----> Virtgual MBachiioe MBaioaier
(ii). Vitgual MBachiioe MBaioaier is gused tt check aiod displays the a ailable irtgual machiioes. It is
alst gused tt create the ioew irtgual machiioes.
(iii). Tt create a ioew irtgual machiioe frst click tio mtioittr ictio theio eioter the irtgual
machiioe ioame Select Ltcal aiod Select Ftrward.
(i ). Click tio rtwse Ltcal Select the iguest O/SS " . iso " imaie fle aiod Select Ftrward.
5. What are the packages of Virtualization Hypervisor and how to install the packages?
(i). " irtgualisattio hyper istr" (prt ides the ftguiodattio tt htst irtgual machiioes iioclgudes
the lib irt aiod
qemgu- k m packaie).
(ii). " irtgualisattio clieiot" (prt ides the sgupptrt tt iiostall aiod maioaie irtgual
machiioes iioclgudes irsh irt-iiostall irt-
maioaier irt-ttp aiod irt- iewer packaies).
(iii). " irtgualisattio tttls" (prt ides tttls ftr tffliioe maioaiemeiot tf irtgual machiioes
iioclgudes the
libiguests packaie).

Ratnakar Page 213


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i ). " irtgualisattio plattrm" (prt ides aio iioterface tt access aiod ctiotrtl irtgual
machiioes iioclgudes the lib irt
lib irt-clieiot aiod irt-wht packaies).
Installation of Virtualization Hypervisor :
# yum group install "virtualization hypervisor" "virtualization client" "virtualization
tools"
"virtualization platform" -y

6. How to create a storage pool and volume using virsh tool?


(i). View all the a ailable sttraie pttls by # virsh pool-list ctmmaiod.
(ii). Create a sttraie pttl directtry by # mkdir /var/lib/libvirt/<pool name> ctmmaiod.
(iii).Defioe the sttraie pttl directtry by # virsh pool-define-as <pool name> dir
----/var/lib/libvirt/<pool
name> ctmmaiod.
(i ). Start the irtgual sttraie pttl by # virsh pool-start <pool name> ctmmaiod.
( ). Tt see the specifed sttraie pttl iioftrmattio by # virsh pool-info <pool name>
ctmmaiod.
( i). Create the sttraie pttl tlgume with specifed sise by # virsh vol-create-as <pool
name><pool
volume><size in MB/GB/TB> ctmmaiod.
( ii). Tt see the list tf all a ailable sttraie pttl tlgumes by # virsh vol-list <pool name>
ctmmaiod.

Other useful commands :


# lscpgu (tt list the CPU iioftrmattio).
# cat /Sprtc/Scpguiioft (tt display the CPU iioftrmattio).
# irsh start < irtgual machiioe ioame> (tt start the irtgual machiioe).
# irsh shgutdtwio< irtgual machiioe ioame>(tt shgutdtwio the irtgual machiioe).
# irsh destrty < irtgual machiioe ioame> (tt delete the irtgual machiioe).
# irsh sguspeiod < irtgual machiioe ioame> (tt paguse the irtgual machiioe).
# irsh resgume < irtgual machiioe> (tt start the pagused irtgual machiioe).
# irsh ioet-list (tt see all the a ailable irtgual machiioes).
# irsh ioet-defioe /Srttt/S< irtgualioetioame.xml> (tt defioe a irtgual ioetwtrk gusiioi xml fle).
# irsh ioet-aguttstart < irtgualioet ioame> (tt set the irtgual ioetwtrk aguttstart at
rebttt).
# irsh ioet-start < irtgual ioet ioame> (tt start the irtgual ioetwtrk).
# rht- mctl fgullreset all (tt reset all the irtgual machiioes as ioew
machiioes).
# rht- mctl reset ser er (tt reset the ser er irtgual machiioe).
# rht- mctl reset clieiot (tt reset the clieiot irtgual machiioe).

Ratnakar Page 214


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# pgushctgurse all <system htstioame> (tt seiod the ser er aiod clieiot irtgual
machiioes tt the
specifed system).

27. General Questions

1. Tell me about yourself ?


(i). Tell ytgur perstioal details
(ii). Techioical (Edgucattioal details).
2. Tell me about your profile?
(i). Tell ytgur perstioal details.
(ii). Edgucattioal details.
(iii). Wtrk histtry (pre itgus ctmpaioies)..
(i ). Prtfle (Preseiot ctmpaioy). :
(a). Coming to Linux : (guptt tll date).
(1). O/SS iiostallattio.
(2). File system creattio.
(3). User admiioistrattio like guser creattio guser permissitios prtfles setioi
eio irtiomeiot tt guser ii iioi special permissitios (sgudt aiod ACLs). tt them aiod guser
trtgubleshtttioi issgues like guser guioable tt ltiiio passwtrd reqguests.
(4). Hardware related issgues like addiioi disks NIC cards prtcesstr replacemeiot memtry
replacemeiot iiocrease memtry aiod ptwer sgupply replacemeiot ....etc.
(5). Netwtrk related issgues like prt idiioi ioetwtrkiioi setioi NIC card parameters
trtgubleshtttioi issgues.
(6). Stme iioterioal backgups.

Ratnakar Page 215


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(7). O/SS patchiioi aiod packaie admiioistrattio wheioe er ioeeded gusiioi rpm aiod yum.
(8). I alst sgupptrts prtcess related issgues like memtry gutlisattio fgull (90%). CPU
gutlisattio fgull (90%). aiod fle system fgull ...etc.
(9). I alst sgupptrt ftr system trtgubleshtttioi issgues like system iott resptiodiioi iotde
dtwio startioi aiod sttppiioi ser ices aiod deamtios.
(b). Coming to Veritas Volume Manager : (frtm the last 1 year).
(1). We iet reqguests frtm prtdgucttio database Q A petple like creatioi tlgumes fle
system creattio iiocrease aiod (tr). decrease the tlgume sises prt ide permissitios
redguiodaiocy pgut the tlgume iiott clguster tt prt ide hiih a ailability
(2). stmetmes destrty tr remt e the tlgumes backgup aiod resttre wheioe er ioecessary
(3). We alst iet stme trtgubleshtttioi issgues like tlgume iott started tlgume iott
accessible fle system crashed mtguiot ptiiot deleted disks failed tlgume maioaier
deamtios are iott wtrkiioi ctiofigurattio fles missed crashed disk irtgups iott
deptrtioi aiod iott imptrtioi tlgume started bgut gusers are guioable tt access fle
systems tio thtse tlgumes ...etc.
(c). Coming to Veritas Cluster : (frtm 6 mtioths).
(1). We iet reqguests like iotde addiioi restgurce addiioi ser ice irtgup addiioi addiioi
ser ice irtgups aiod restgurces tt existioi ser ice irtgups mtguiot ptiiots addiioi
addiioi NIC cars IP addresses addiioi tlgumes disk irtgups freesiioi aiod
guiofreesiioi ser ices irtgups aiod alst iet stme trtgubleshtttioi issgues like clguster
iott rguioioiioi if restgurces fagulted theio restart the ser ice irtgups ctmmguioicattio
failed betweeio twt systems Gab is iott rguioioiioi llt iott rguioioiioi aiod ctiofigurattio fles maiio.cf
crashed tr missed aiod restgurces are iott started ... etc.
(d). I alst write small scripts tt perftrm iioterioal rtgutioe jtbs dtcgumeiot preparattio
haiodt er mails checkiioi htw maioy tckets issgued htw maioy tckets stl ed aiod
htw maioy jtbs peiodiioi ....etc.
(e). I alst sgupptrts iio applicattio depltymeiot database depltymeiot aiod tthers.
3. What are the tools you are using?
(i). ioetstat mstat itstat iomap aiod ttp ftr perftrmaioce mtioittriioi tttls.
(ii). crtio aiod at ftr jtb schedguliioi.
(iii). Remedy tttl ftr tcketioi system.
(i ). Veritas Netbackgup Ti tli .... etc. ftr backiioi pgurptse
( ). Ogutlttk ftr iioterioal mailiioi.
4. What are the storage boxes using?
(i). NetApps VMBC Clariaio aiod EMBC 2.
(ii). Emgulex Qltiic (H A cards)..
5. What are the Applications are you using?
(i). Databases (Oracle 10i 11i aiod MBysql)..
(ii). Oracle Applicattios like ERP packaies (Oracle 11i aiod 12)..
(iii). SAP applicattios.

Ratnakar Page 216


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i ). Datawarehtgusiioi ....etc.
6. What is your company hierarchy?
MBe -----> Team Lead tr Tech Lead -----> MBaioaier -----> Deli ery MBaioaier -----> Asia
head
7. What level are you supporting?
Liiogux Admiioistrattr as Le el 2.
8. What are your shif timings?
Geioeral shif -----> 09:00 - 18:00 hrs.
Shifs : Oioe shif frtm USA aiod twt shifs frtm Iiodia tperattios guptt last 2 mtioths aiod iotw all
the tperattios are frtm Iiodia tioly aiod data ceiotre tperattios frtm USA tioly.
1 st shif frtm 07:00 - 15:00 hrs 2 iod shif frtm 15:00 - 23:00 hrs 3 rd shif frtm 21:00
- 07:00 hrs.
9. What is your team size?
Tttal 18 members. Ftr each shif 5 members each aiod 3 members tio weekly tfe.
10. What about tickets issues and tickets frequency?
(i). 7 - 8 tckets daily aiod MBax. 10 per day.
Iio thtse 85 - 90% are CPU gutlisattio fgull memtry fgull fle system fgull ltiiio prtblems aiod
stmetmes iotde dtwio issgues.
(ii). Geioeral tckets se erity - 3 se erity - 2 se erity - 1.
We are iott restl ed se erity le el - 1 tckets.
(iii). Iiocideiots :
Se erity le el - 1 shtguld be stl ed withiio 1 htgur (Immediate)..
Se erity le el - 2 shtguld be stl ed withiio 6 htgurs.
Se erity le el - 1 shtguld be stl ed withiio 24 htgurs.
Se erity le el - 1 shtguld be stl ed withiio 2 days.
Reqguest pritrity ----> Hiih medigum aiod ltw
11. What is your notice period?
25 - 30 days.
12. Any Mail ids?
Iioterioal mail id (mails wtio't ctme frtm tgutside aiod it tt tgutside)..
13. Are you contract or permanent? And why are you changing?
Permaioeiot iio XXXXXXXXXXX P t limited. I am lttkiioi the ctmpaioy which prt ides hiih
a ailability tio cltgud irtgualisattio aiod sttraie eio irtiomeiots tt eiohaioce my kiotwledie aiod
better career irtwth.
14. What are the projects are you dealing?
(i). Databases.
(ii). aiokiioi.
(iii). Fiioaioce.
(i ). Ltiistcs.
( ). Httel aiod Ttgurism .....etc.

Ratnakar Page 217


[Pick the date] [LINUX NOTES FOR LEVEL 2]

15. How many servers are you handling?


Tttal 600 systems.
200 physical systems aiod remaiioiioi 400 systems are iio irtgualisattio eio irtiomeiot.
10 ftr Applicattio 20 ftr Qguality &
550 ftr Liiogux 10 ftr Wiiodtws 10 guioder traiosittio
De eltpmeiot Iioterioal Testioi
16. What is your environment?
(i). De eltpmeiot guptt 10 ser ers
(ii). Qguality Assguraioce tr Qguality testioi guptt 20 ser ers.
(iii). User Agutheiotcattio (U A). guptt 10 ser ers.
(i ). Prtdgucttio guptt 550 ser ers.
( ). Uioder bguildiioi 10.
17. How to handover the shif?
* MBail tt relie er.
* Direct tt relie er.
18. Can you contact the data centre?
(i). It depeiods tio the se erity.
(ii). If the sitguattio is emerieiocy theio we will call the data ceiotre by phtioe.
(iii). If the sitguattio is iotio - emerieiocy theio we will mail tt the data ceiotre petple.
19. What is server hardening?
(i). Tt checkiioi tgur system is reachiioi tt staiodards reqguired by the triaioisattio.
(ii). That is miioimgum passwtrd leioith miioimgum sise tf rttt partttio.
(iii). MBiioimgum free space aiod passwtrd expiry aiod all tther secgurity staiodards.
20. What are decommission and recommission?
(i). Ntrmally ser ers shtguld be chaioied e ery 5 - 6 years becaguse tf perftrmaioce deiradattio
as per staiodards tf the ctmpaioy.
(ii). Dectmmissitio meaios the prtcess tf remt iioi the tld system frtm the prtdgucttio
eio irtiomeiot aiod Rectmmissitio meaios the prtcess tf pgutioi the ioew system iiott
the prtdgucttio eio irtiomeiot.
(iii).We are iott dedicated ftr dectmmissitio. We dt dectmmissitio altioi with tgur rtgutioe wtrk.
(i ). Ltiiio as rttt thtguih ctiostle.
( ). First iioftrm tr raise the tcket tt mtioittriioi team tt iiiotre the alerts.
( i).Sttp the applicattio aiod databases.
( ii). Sttp the clguster aiod Vtlgume MBaioaier.
( iii). Uiomtguiot the fle system.
(ix). Afer that we shtguld pgut the system ftr tioe week.
(x). We will iioftrm tr raise the tcket tt the ioetwtrk team tt release the ptrts beltioiiioi tt that
system.
(xi).Fiioally we iioftrm tt the data ceiotre petple tt remt e the cables frtm that system.
21. Explain backup and what is your backup policy?

Ratnakar Page 218


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i). ackgup meaios takiioi a ctpy tf the existioi system aiod resttre wheio the system is
ftrmatted tr crashed.
(ii). Iio backgup eio irtiomeiot iotrmally we ha e 3 ser ers.
(a). MBaster Ser er (1 tr 2 systems)..
(b). MBedia Ser er (1 tr 2 systems)..
(c). Clieiot Ser er (1 tr 2 systems)..
(iii). Iio tgur triaioisattio we gused tt take the backgup iio MBedia Ser er.
(i ). ackgup fails meaios prtdgucttio ser er may dtwio tr media ser er may be iio dtwio fle
system may iott be a ailable tr backgup tttl ptrt iogumber may be bltcked.
( ). ackgup caio be takeio iio 3 types.
(a). Applicattio ackgup (Applicattio petple will take)..
(b). File system (O/SS). backgup (System Admiioistrattrs will take)..
(c). Database backgup (Database Admiioistrattrs will take)..
( i). ackgup is aguttmated thtguih crtiotab tr separate backgup tttls like Veritas Net backgup aiod
Ti tli ....etc.
( ii). The crtiotab will iott iioftrm the failed backgup. gut Veritas Net backgup aiod Ti tli tttls will
seiod messaies abtgut backgup fails aiod why the backgup is failed becaguse these tttls will
ieioerate the failed backgup lti fles.
( iii). If aioy fles are tpeio iio the prtdgucttio ser er the backgup may be failed. St check aioy fles
tpeioed tr iott by # lsof tr # fuser -cv <file system> ctmmaiods.
(ix). Stmetmes the script iio Veritas Net backgup tr Ti tli tttls may be ctrrgupted tr iott
rguioioiioi theio resttre thtse scripts frtm backgup tr we ioeed maiogually deptrt & imptrt
aiod take backgup.
(x). Stmetmes backgup failed dgue tt backgup ptrt iot. 13782 may be iott wtrkiioi tr iio bltcked
state. It caio be checked by # netstat -ntulp | grep 13782 ctmmaiod.
(xi). If the media ser er aiod prtdgucttio ser er are iott iio the same dtmaiio theio backgup may be
failed. (ie. prtdgucttio ser er dtmaiio ioame may be chaioied bgut iot iiotmattio
tt backgup team abtgut that chaioie st media ser er is iio aiotther dtmaiio)..
Backup Procedure :
(i). Deptrt the disk irtgup tio prtdgucttio ser er.
(ii). Imptrt the disk irtgup tio backgup (media). ser er.
(iii). Jtiio the disk irtgup with media ser er.
(i ). Syioc the data with prtdgucttio ser er.
( ). Take the backgup.
( i). split the disk irtgup frtm media ser er.
( ii). Jtiio the disk irtgup with prtdgucttio ser er.
( iii). Deptrt the disk irtgup frtm media ser er.
(ix). Imptrt the disk irtgup tio prtdgucttio ser er.
Backup policy :
(i). Ctmplete (fgull). backgup (e ery mtioth ie. tioce iio a mtioth)..

Ratnakar Page 219


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). Iiocremeiotal backgup (Daily)..


(iii). Difeereiotal tr cgumgulat e backgup (e ery week eiod)..
22. How to troubleshoot if the file system is full?
(i). First check whether the fle system is O/SS tr tther thaio O/SS.
(ii). If it is tther thaio O/SS theio iioftrm tt that respect e teams tt htguse keep the fle system
(ie. remt e the guioioecessary fles iio thtse fle system)..
(iii). If iott ptssible tt htguse keep theio iioftrm tt difeereiot teams (raise the CRQ (Chaioie
Reqguest).). ftr iiocreasiioi the fle system.
(a). First take bgusiioess apprt al aiod raise the CRQ tt mtioittriioi team tt iiiotre the alerts
frtm the system sttp the applicattio team tt sttp the applicattio aiod database
team tt sttp the database.
(b). Ntrmally team lead tr tech lead tr maioaier will dt this by iioitate the mail thread.
(c). We will dt this tio weekeiod tt redguce the bgusiioess impact.
(i ). First take a backgup tf the fle system theio guiomtguiot the fle system.
( ). Remt e that partttio aiod aiaiio create that fle system with iiocreased sise theio mtguiot
aiaiio that fle system aiod resttre the backgup.
( i). If the fle system beltiois tt system lti fles tr tther lti fles aiod iott tt delete theio they
reqguested gus tt prt ide tioe Reptsittry ser er (tioly ftr lti fles).. Ntrmally tioe
script will dt aguttmatcally redirect the lti fles tt that reptsittry ser er.
( ii). Stmetmes we will delete fle ctioteiots iott the fles tt redguce the fle sises. Ftr that we
execgute the ctmmaiod # cat /dev/null ><file name with path> ie. iogullifyiioi
the fles.
(ix). If it is rttt fle system tr O/SS fle system
(a). may be /opt fgull tr may be /var fgull tr may be /tmp fgull
(b). Iio /var/log/secure tr /var/log/system tr /var/tmp fles may be fgull. If thtse fles are
imptrtaiot theio redirect them tt tther ceiotral reptsittry ser er tr backgup thtse fles
aiod iogullifyiioi thtse fles.
(c). If /home directtry is preseiot iio rttt ( / ). fle system theio this fle system fgull will
tccgur. Geioerally /home will be separated frtm rttt fle system aiod created as
separate /home fle system. If /home is iio rttt ( / ). as a directtry theio
create a separate fle system ftr /home aiod ctpy thtse fles aiod directtries beltiois
tt /home aiod remt e that /home directtry.
(d). If rttt ( / ). is fgull theio caioiott ltiiio tt the system. St bttt with ioet tr CDROMB iio siioile
guser mtde aiod dt the abt e said.
(x). Ntrmally if fle system is tther thaio O/SS theio we will iioftrm tt that respect e maioaier tr
twioer aiod take the permissitios tt remt e guioioecessary fles thrtguih erbal
permissitio tr CRQ .
23. CPU utilization full, how to troubleshoot it?
(a). Ntrmally we iet these sceioarits tio weekeiods becaguse backgup team will take hea y
backgups.

Ratnakar Page 220


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(b). First check which prtcesses are gusiioi mtre CPU gutlisattio by # top aiod take a sioap shtt tf
that guser prtcesses aiod seiod the sioap shtt aiod iioftrm tt that guser tt kill the
guioioecessary prtcess.
(c). If thtse prtcesses are backgups theio iioftrm tt the backgup team tt redguce the backgups by
sttppiioi stme backgups tt redguce the CPU gutlisattio.
(d). Stmetmes iio peak staies (peak htgurs meaios ha iioi bgusiioess htgurs). CPU gutlisattio will fgull
aiod iet back tt the iotrmal ptsittio aguttmatcally afer stme tme (withiio sectiods).. gut
tcket raised by mtioittriioi team. St we ha e tt take a sioap shtt tf that peak staie
aiod attach that sioap shtt tt the raised tcket aiod cltse that tcket.
(e). Stmetmes if hea y applicattios are rguioioiioi aiod iott tt kill (ie. bgusiioess applicattios). theio
if aioy spare prtcesstr is a ailable tr tther ltw ltad CPUs a ailable theio mt e
thtse hea y applicattio prtcesses tt thtse CPUs.
(d). If CPUs are alst iott a ailable theio if the system sgupptrts aiotther CPU theio iioftrm tt the
data ceiotre petple tr CPU eiodtr tt pgurchase ioew CPU thtguih gusiioess apprt al aiod
mt e stme prtcesses tt the ioewly pgurchased CPUs.
24. How to troubleshoot when the system is slow?
(a). System sltw meaios the eiod gusers resptiose is sltw.
(b). Check the Applicattio fle system CPU gutlisattio memtry gutlisattio aiod O/SS fle system
gutlisattio.
(c). If all are tk theio check ioetwtrk statstcs aiod iioterfaces whether the iioterfaces are rguioioiioi
iio fgull dguplex mtde tr half dguplex mtde aiod check whether the packets are missiioi. If all
are tk frtm tgur side theio
(d). Iioftrm tt ioetwtrk team aiod tther respect e teams tt stl e this issgue.
25. How to troubleshoot if the node is down?
(a). Check piioiiioi the system. If piioiiioi theio check whether the system is iio siioile guser mtde
tr iott.
(b). If the system is iio siioile guser mtde theio pgut the system iio mgult guser mtde ie. defagult rguio
le el by ctiofrmiioi with tgur team whether system is guioder maiioteioaioce tr
iott.
(c). Check iio which rguio le el the system is rguioioiioi. If it is iio iioit 1 it will iott be able tt piioi. If it is
iio iioit s theio it will piioi.
(d). Iio this sitguattio alst if it is iott piioiiioi theio try tt ltiiio thrtguih ctiostle ptrt. If iott ptssible
theio iioftrm tt data ceiotres petple tt hard bttt the system.
(d). If ctioioected thrtguih ctiostle ptrt theio we may iet the ctiostle prtmpt.
26. How to troubleshoot if the memory utilization full?
(a). Check htw mguch memtry is iiostalled iio the system by # dmidecode -t memory
ctmmaiod.
(b). Check the memtry gutlisattio by # vmstat -v ctmmaiod.

Ratnakar Page 221


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(c). Ntrmally applicattio tr hea y backgups gutlise mtre memtry. St iioftrm tt applicattio team
tr backgup team tr tther teams which team is gutlisiioi the mtre memtry tt redguce
the prtcesses by killiioi them tr paguse them.
(d). Try tt kill tr disable tr sttp the guioioecessary ser ices.
(e). If all the ways are iott ptssible theio iioftrm tt team lead tr tech lead tr maioaier tt
iiocrease the memtry (swap space).. If it is alst iott ptssible theio takiioi hiiher aguthtrity's
permissitios tt iiocrease the physical memtry. Ftr thtse we ctiotact the ser er
eiodtr aiod ct-trdiioate with them thrtguih data ceiotre petple tt iiocrease the RAMB
sise.
27. How to replace the failed hard disk?
(a). Check whether the disk is failed tr iott by # iostat -En | grep -i hard/Sstf ctmmaiod.
(b). If hard errtrs are abt e 20 theio we will it ftr replacemeiot tf the disk.
(c). If the disk is frtm SAN petple theio we will iioftrm tt them abtgut the replacemeiot tf the
disk. If it is iioterioal disk theio we raise the CRQ tt replace the disk.
(d). Ftr this we will ctiosidered twt thiiois.
(i). whether the system is withiio the warraioty.
(ii). withtgut warraioty.
(e). We will directly call tt the ttll free iot. tf the system eiodtr aiod raise the tcket. They will
issgue the case iot. This is the iot. we ha e tt meiottio iio all ctrresptiodeioces tt eiodtr
reiardiioi this issgue.
(f). If it is ha iioi warraioty they asks rack iot. system iot. aiod tther details aiod replace the hard
disk with ct- trdiioate tf the data ceiotre petple.
(i). If it is iott ha iioi warraioty we ha e tt stl e the prtblem by tgur twio tr re-aireemeiot tt
exteiod the warraioty aiod stl e that prtblem.
28. How to replace the processor?
(a). Check the prtcesstr's statgus gusiioi # lscpu tr # dmidecode -t processor ctmmaiods.
(b). If it shtws aioy errtrs theio we ha e tt replace the prtcesstr.
(c). Theio raise the case tt eiodtr by ttll free iot. with hiiher aguthtrites permissitio.
(d). The eiodtr will ii e case iot. ftr fgutgure refereioces.
(e). They alst asks rack iot. system iot. tf the data ceiotre ftr prtcesstr replacemeiot.
(f). We will iioftrm tt the Data ceiotre petple tt ct-trdiioate with eiodtr.
29. How replace the failed memory modules?
Causes :
(a). The system is ctiotiogutgusly rebtttioi .
(b). Wheio iio peak bgusiioess htgurs if the hea y applicattios are rguioioiioi the system iet paioic
aiod rebttted. This is repeatioi reigularly.
Solution :
(a). First we check htw mguch RAMB preseiot iio the system with # dmidecode -t memory
ctmmaiod.
(b). Theio we raise the case tt eiodtr with the help tf hiiher aguthtrites.

Ratnakar Page 222


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(c). Theio the eiodtrs will prt ide the case iot. ftr fgutgure refereioce.
(d). They will alst asks rack iot. system iot. tt replace the memtry.
(e). we will iioftrm the data ceiotre petple tt ct-trdiioate with the eiodtr.
30. What is your role in DB patching?
Iio Database patchiioi the ftlltwiioi teams will be iio tl ed.
(i). Database Admiioistrattr (D A). team.
(ii). Liiogux Admiioistrattrs team.
(iii). MBtioittriioi team.
(i ). Applicattio team.
(i). DBA team :
This is the team tt apply the patches tt the databases.
(ii). Linux team :
This team is alst iio tl ed if aioy prtblems tccgur. If the database tlgume is ha iioi a mirrtr
we shtguld frst break the mirrtr aiod theio the D A petple will apply the patches. Afer 1 tr
2 days there is iot prtblem aiaiio we ioeed syioc the data betweeio mirrtred tlgume tt
patch applied tlgume. If there is iot space ftr patch we ha e tt prt ide space tt
D A team.
(iii).Monitoring team :
This team shtguld recei e reqguests tr sguiiesttios tt iiiotre aioy prtblems tccgurs. Afer
applied the patch if the system is aguttmatcally rebttted theio mtioittriioi team will
raise the tcket "Ntde dtwio" tt system admiioistrattrs team. St tt a tid
thtse type tf tckets we ha e tt seiot reqguests tt iiiotre thtse type alerts.
(i ).Application team :
Ftr applyiioi aioy patches the databases shtguld iott be a ailable tt applicattio. St if
sguddeioly database is iott a ailable theio applicattio may be crashed. St frst the
applicattio shtguld be sttpped. This will be dtioe by applicattio team.
31. What is SLA?
A ser ice-le el aireemeiot (SLA). is simply a dtcgumeiot describiioi the le el tf ser ice expected by
a cgusttmer frtm a sgupplier layiioi tgut the metrics by which that ser ice is measgured aiod the
remedies tr peioaltes if aioy shtguld the aireed-guptio le els iott be achie ed. Usgually SLAs are
betweeio ctmpaioies aiod exterioal sguppliers bgut they may alst be betweeio twt departmeiots
withiio a ctmpaioy.
32. What is Problem Management?
The tbject e tf Prtblem MBaioaiemeiot is tt miioimise the impact tf prtblems tio the
triaioisattio. Prtblem MBaioaiemeiot plays aio imptrtaiot rtle iio the detecttio aiod prt idiioi
stlguttios tt prtblems (wtrk artguiod& kiotwio errtrs). aiod pre eiots their retccgurreioce.
A 'Prtblem' is the guiokiotwio caguse tf tioe tr mtre iiocideiots tfeio ideiotfed as a resgult tf
mgultple similar
iiocideiots.A 'Kiotwio errtr' is aio ideiotfed rttt caguse tf a Prtblem.
33. What is Incident Management?

Ratnakar Page 223


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Aio 'Iiocideiot' is aioy e eiot which is iott part tf the staiodard tperattio tf the ser ice aiod which
caguses tr may caguse aio iioterrgupttio tr a redgucttio tf the qguality tf the ser ice.
The tbject e tf Iiocideiot MBaioaiemeiot is tt resttre iotrmal tperattios as qguickly as ptssible
with the least ptssible impact tio either the bgusiioess tr the guser at a ctst-efeect e price.
Iiopguts ftr Iiocideiot MBaioaiemeiot mtstly ctme frtm gusers bgut caio ha e tther stgurces as well
like maioaiemeiot Iioftrmattio tr Detecttio Systems. The tgutpguts tf the prtcess are RFC’s
(Reqguests ftr Chaioies). restl ed aiod cltsed Iiocideiots maioaiemeiot iioftrmattio aiod
ctmmguioicattio tt the cgusttmer.
34. What is Change Management?
Chaioie maioaiemeiot is a systematc apprtach tt dealiioi with chaioie btth frtm the
perspect e tf aio triaioisattio aiod tio the iiodi idgual le el. chaioie maioaiemeiot has at least
three difeereiot aspects iioclgudiioi adaptioi tt chaioie ctiotrtlliioi chaioie aiod efeectioi
chaioie. A prtact e apprtach tt dealiioi with chaioie is at the ctre tf all three aspects.Iio aio
iioftrmattio techiotltiy (IT). system eio irtiomeiot chaioie maioaiemeiot refers tt a systematc
apprtach tt keepiioi track tf the details tf the system (ftr example what tperatioi
system release is rguioioiioi tio each ctmpguter aiod which fxes ha e beeio applied)..
35. What is Request Management?
ser ice reqguest maioaiemeiot (SRMB). is the guioderlyiioi wtrkftw aiod prtcesses that eioable aio IT
prtcguremeiot tr ser ice reqguest tt be reliably sgubmitted rtguted apprt ed mtioittred aiod
deli ered. SRMB is the prtcess tf maioaiiioi a ser ice reqguest thrtguih its lifecycle frtm
sgubmissitio thrtguih deli ery aiod ftlltw-gup.
SRMB may be maiogual tr aguttmated. Iio a maiogual system a guser calls a help desk tt reqguest a
ser ice aiod help desk perstioioel create a ser ice tcket tt rtgute the ser ice reqguest. Iio aio
aguttmated system the guser sgubmits a reqguest thrtguih aio tioliioe ser ice catalti aiod the
applicattio stfware aguttmatcally rtgutes the reqguest thrtguih the apprtpriate prtcesses ftr
apprt al aiod ser ice deli ery. These systems alst typically eioable gusers tt track the statgus tf their
ser ice reqguests aiod maioaiemeiot tt mtioittr ser ice deli ery le els ftr qguality ctiotrtl pgurptses.
36. What is grep?
(i). grep meaios Gltbally search ftr Reigular Expressitio.
(ii). Usiioi irep we caio flter the resgults tt iet a partcgular iioftrmattio.
(iii).We caio iet tioly iioftrmattio abtgut what striioi we ha e specifed iio irep ctmmaiod.
37. What are pipes and filters in Linux?
Pipes :
(a). Pipes are iotthiioi bgut addiioi twt ctmmaiods aiod make as tioe ctmmaiod.
(b). Ntrmally we caioiott ctmbiioe twt ctmmaiods bgut gusiioi pipes we iet tioe ctmmaiod by
ctmbiioiioi twt ctmmaiods.
(c). St we caio iet the resgults as what we reqguired.
Filters :
(a). Filters are iotthiioi bgut flteriioi the resgults what we reqguired.
(b). Usiioi flters we caio iet exact resgults depeiods guptio what we specifed iio the expressitio.

Ratnakar Page 224


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(c). St there is iot wastaie tf tme becaguse it flters resgults what we specifed iio the ctmmaiod
expressitio.
38. What is the full form of COMPUTER ?
C ----->Ctmmtioly
O -----> Operated
M -----> MBachiioe
P -----> Partcgularly
U ----->Used
T ----->Techioical aiod
E ----->Edgucattioal
R -----> Research
39. What is the command in sar to monitor NIC devices received/transmited packets?
# sar -io DEV 1 5
This will shtw 5 ctiosecgut e tgutpgut each with a tme iioter al tf 1 sec ftr all the etherioet
de ices
40. What is Linux Kernel?
It acts as aio iioterpreter betweeio Liiogux OS aiod its hardware. It is the fguiodameiotal ctmptioeiot tf
Liiogux OS aiod ctiotaiios hardware dri ers ftr the de ices iiostalled tio the system. The kerioel is a
part tf the system which ltads frst aiod it stays tio the memtry.
41. What are the main parameters efect on server performance?
The tioe tf the mtst imptrtaiot task tf aioy Liiogux Admiio iioclgudes perftrmaioce mtioittriioi which
iioclgudes a parameter "Load Average" tr "CPU Load".
42. What is load average?
Ltad A eraie is the algue which represeiots the ltad tio ytgur system ftr a specifc peritd tf
tme. Alst it caio be ctiosidered the ratt tf the iogumber tf act e tasks tt the iogumber tf
a ailable CPUs.
43. How to check?

We caio guse either ttp tr guptme ctmmaiod tt iew the tgutpgut tf the ltad a eraie as shtwio
beltw.
# guptme
00:07:00 gup 4 days 6:14 1 guser ltad a eraie: 0.11 0.14 0.09
# ttp
ttp - 00:07:12 gup 4 days 6:15 1 guser ltad a eraie: 0.09 0.13 0.09
44. What are the three values?

As ytgu caio see three algues represeiotioi the ltad a eraie ctlgumio. These shtw the ltad tio ytgur
system t er a siiioifcaiot peritd tf tme (tioe tr cgurreiot f e aiod ffeeio miiogutes a eraies)..

Ratnakar Page 225


[Pick the date] [LINUX NOTES FOR LEVEL 2]

45. How do you know your system has a high load?

The mtst imptrtaiot qguesttio as iio mtst cases I ha e seeio htw dt ytgu determiioe ytgur system
has hiih ltad.
Does a high value represents high load average and that your system requires atentonn
What is the threshold value for load averagen
How can we conclude if the load average value is good or badn
A Ceiotral Prtcessiioi Uioit iio earlier days gused tt be ha iioi tioly tioe prtcesstr aiod the ctre
ctiocept was iott their iio thtse days. gut with the ad aiocemeiot iio techiotltiy aiod the gurie tf
hiiher speed tt meet gup demaiods tf IT iiodgustry mgultple prtcesstr were iioteirated iio the
same CPU makiioi it mgult-prtcesstr.
Htwe er iiocreasiioi the iot. tf prtcesstr did iiocreased the wtrkiioi speed tf maioy tasks aiod
perftrmaioce bgut it alst leads tt iiocrease iio sise ctmplexity aiod heat issgues. St iio trder tt
ctiotiogue imprt emeiot tf perftrmaioce the ctre ctiocept was iiotrtdguced.
Iiostead tf ha iioi twt CPUs aiod a mttherbtard capable tf htstioi them twt CPUS are takeio
ttiether aiod ctmbiioed tt ftrm a dgual ctre prtcesstr which will gutlise aio iiodi idgual stcket gusiioi
less ptwer aiod sise capable tf perftrmiioi the same amtguiot tf task as dgual prtcesstr CPU.
Botom Line is that Ltad algue depeiods tio the iot. tf ctres iio ytgur machiioe. Ftr example a dgual
ctre is rele aiot tt 2 prtcesstr tr 2 ctres aiod qguad ctre is rele aiot tt 4 prtcesstr tr ftgur ctres as
the maximgum algue ftr ltad.
46. How do I check the no. of cores on my Linux system?

The iioftrmattio which ytgu see guioder /Sprtc/Scpguiioft caio be ctiofgusiioi at tmes. If ytgu rguio the
beltw ctmmaiod
# less /Sprtc/Scpguiioft | irep prtcesstr
prtcesstr :0
prtcesstr :1
prtcesstr :2
prtcesstr :3
prtcesstr :4
prtcesstr :5
St as per the abt e ctmmaiod my system has 16 prtcesstrs iio it. Htwe er it really has 8
prtcesstrs with hyper threadiioi eioabled. The hyper threadiioi preseiots 2 ltiical CPUs tt the
tperatioi system ftr each actgual ctre st it efeect ely dtgubles the iot. tf ltiical CPU iio ytgur
system.
47. How to find if hyper threading is enabled
Lttk tgut ftr "ht" iio the fais secttio iioside cpguiioft with the beltw ctmmaiod
# less /Sprtc/Scpguiioft | irep fais | guioiq | irep -i "ht"
flags : fpgu me de pse tsc msr pae mce cx8 apic sep mtrr pie mca cmt pat pse36 clfgush dts
acpi mmx fxsr sse sse2 ss ht tm syscall iox rdtscp lm ctiostaiot_tsc iotiosttp_tsc pioi mtioittr
ds_cpl mx est tm2 ssse3 cx16 xtpr sse4_1 sse4_2 ptpciot lahf_lm.

Ratnakar Page 226


[Pick the date] [LINUX NOTES FOR LEVEL 2]

The felds we ioeed tt ctmpare tt fiod the iot. tf ctre are "physical id" aiod "core id". Rguio the
beltw ctmmaiod
# less /Sprtc/Scpguiioft | irep "physical id" | strt|guioiq | wc -l
2
# less /Sprtc/Scpguiioft | irep "ctre id" | strt|guioiq | wc -l
4
St the iot. tf ctres wtguld be 2x4 = 8 cores.
48. What do you understand the Load Average?

If the iogumber tf act e tasks gutlisiioi CPU is less as ctmpared tt a ailable CPU ctres theio the
ltad a eraie caio be ctiosidered iotrmal bgut if the iot. tf act e tasks starts iiocreasiioi with
respect tt a ailable CPU ctres theio the ltad a eraie will start risiioi.For example,
# guptme
00:43:58 gup 212 days 14:19 4 gusers ltad a eraie: 6.07 7.08 8.07
49. How to check all the current running services in Linux?
To find the status of any single service :
# ser ice sfpd statgus
sfpd (pid 5909). is rguioioiioi...
To get the status of all the running services :
# ser ice --statgus-all | irep rguioioiioi
acpid (pid 5310). is rguioioiioi...
atd (pid 6528). is rguioioiioi...
aguditd (pid 5012). is rguioioiioi...
A ahi daemtio is iott rguioioiioi
A ahi DNS daemtio is iott rguioioiioi
The Peiasgus CIMB Listeioer is rguioioiioi.
The Peiasgus CIMB Object MBaioaier is rguioioiioi.
crtiod (pid 6242). is rguioioiioi...
dcerpcd (pid 5177). is rguioioiioi...
e eiotltid (pid 5223). is rguioioiioi...
In case you don't use grep you will be able to see all the services on your machine :
# ser ice --statgus-all
NetwtrkMBaioaier is sttpped
acpid (pid 5310). is rguioioiioi...
aioacrtio is sttpped
atd (pid 6528). is rguioioiioi...
aguditd (pid 5012). is rguioioiioi...
aguttmtguiot is sttpped
A ahi daemtio is iott rguioioiioi
A ahi DNS daemtio is iott rguioioiioi

Ratnakar Page 227


[Pick the date] [LINUX NOTES FOR LEVEL 2]

hcid is sttpped
sdpd is sttpped
You can also check the active ports along with their services using :
# ioetstat -iotlp
Act e Iioterioet ctioioecttios (tioly ser ers).
Prtttctl Rec -Q Seiod-Q Ltcal Address Ftreiiio Address State
PID/SPrtiram ioame
tcp 0 0 0.0.0.0:52961 0.0.0.0:* LISTEN
5223/Se eiotltid
tcp 0 0 0.0.0.0:5988 0.0.0.0:* LISTEN
6116/Scimser er
tcp 0 0 0.0.0.0:5989 0.0.0.0:* LISTEN 6116/Scimser er
tcp 0 0 0.0.0.0:678 0.0.0.0:* LISTEN 5160/Srpc.statd
tcp 0 0 0.0.0.0:14247 0.0.0.0:* LISTEN 6460/Sja a
tcp 0 0 127.0.0.1:199 0.0.0.0:* LISTEN
5857/Ssiompd
tcp 0 0 0.0.0.0:135 0.0.0.0:* LISTEN 5177/Sdcerpcd
50. How do you check Linux machine is Physical or Virtual remotely?

There is iot hard aiod fast rgule tt check whether the machiioe is physical tr irtgual bgut stll we dt
ha e stme ctmmaiods which caio be gused ftr the same pgurptse.
The ctmmaiod gused tt iew all the reqguired hardware related iioftrmattio ftr aioy Liiogux
machiioe is
# dmidectde
gut the tgutpgut wtguld be ery ltioi aiod hard tt fiod tgut the specifc details lttkiioi ftr. St let's
ioarrtw it dtwio.
Physical Servers:
# dmidectde -s system-prtdguct-ioame
System x3550 MB2 -[7284AC1]-
Ntw tt iet mtre details abtgut the system
# dmidectde | less (Aiod search ftr "System Iioftrmattio").
System Iioftrmattio
MBaiogufactgurer: I MB
Prtdguct Name: System x3550 MB2 -[7284AC1]-
Versitio: 00
Wake-gup Type: Other
SKU Ngumber: XxXxXxX
Family: System x

Ratnakar Page 228


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Virtual Servers :

# dmidectde -s system-prtdguct-ioame
VMBware Virtgual Plattrm
# dmidectde | less
System Iioftrmattio
MBaiogufactgurer: VMBware Iioc.
Prtdguct Name: VMBware Virtgual Plattrm
Versitio: Ntioe
Wake-gup Type: Ptwer Switch
SKU Ngumber: Ntt Specifed
Family: Ntt Specifed
On a virtual server running VMware you can run the below command to verify :
# lspci | irep -i mware
00:0f.0 VGA ctmpatble ctiotrtller: VMBware SVGA II Adapter
51. How to find the bit size of your linux machine?
# guioame -m
i686
# guioame -m
x86_64
If we iet i386 i586 aiod i686 that siiioifes ytgur machiioe is 32-bit bgut if we
ietx86_64 tr ia64 theio ytgur machiioe will be 64-bit.
# ietctiof LONG_ IT
32
# ietctiof LONG_ IT
64 (Here we iet aio tgutpgut tf bit sise either 32 tr 64).
52. How can you add a banner or login message in Linux?
y editioi these twt fles
/Setc/Sissgue
/Setc/Smttd
53. What is the diference between normal kernel and kernel-PAE?
kerioel iio 32 bit machiioe sgupptrts max tf 4 G RAMB whereas
kerioel PAE iio 32 bit liiogux machiioe sgupptrts tll 64 G RAMB
54. Tell me the command to find all the commands in your linux machine having only 2 words like
ls, cp, cd etc.
# fiod /Sbiio /Ssbiio/Sgusr/Sbiio /Sgusr/Ssbiio -ioame ?? -type f
55. Which file is generally used to configure kickstart?
aioactioda.cfi
56. Which log file will you check for all authentication related messages?
/S ar/Slti/Ssecgure

Ratnakar Page 229


[Pick the date] [LINUX NOTES FOR LEVEL 2]

57. What is the command used to find the process responsible for a particular running file?
# fguser fleioame
# lstf fleioame
58. What is the command to take remote of any Linux machine?
# rdeskttp
59. What are the three values shown in load average section of top command?
It shtws the cgurreiot 5 miio back aiod 15 miio back ltad a eraie algue.
60. How to check all the process running by a particular user?
# ps -gu<guserioame>
61. What is an orphan process?
Aio trphaio prtcess is a prtcess that is stll execgutioi bgut whtse pareiot has died.
62. What is a defunct process?
These are alst termed as stmbie prtcess. These are thtse prtcess wht ha e ctmpleted their
execguttio bgut stll has aio eiotry iio the prtcess table. Wheio a prtcess eiods all tf the memtry
aiod restgurces asstciated with it are de-alltcated st they caio be gused by tther prtcesses.Afer
the stmbie is remt ed its prtcess ideiotfer (PID). aiod eiotry iio the prtcess table caio theio be
regused.
Ztmbies caio be ideiotfed iio the tgutpgut frtm the Uioix ps ctmmaiod by the preseioce tf a "Z" iio
the "STAT" ctlgumio
63. How do you limit maximum connections in your apache server?
Chaioie the beltw parameter algue iioside httpd.ctiof
MBaxClieiots 256
64. Which command do you use to download a file from fp or htp website using CLI?
# wiet path_tt_the_fle
65. What is the default port for ssh? How will you change it to some other random port no.?
SSH ptrt iot. by defagult is 22. Tt chaioie the defagult ptrt iot. we ioeed make reqguired chaioies
iioside sshd_ctiofi fle iio the beltw meiottioed liioe
#Port 22 (Uioctmmeiot the abt e liioe aiod defioe the ioew ptrt iot).
Restart the ser ices ftr chaioies tt take efeect.
66. What is the diference between A record and CNAME record in DNS?
A record :
 It is the Address rectrds alst kiotwio as htst rectrds
 Ptiiots tt the IP address refectioi the dtmaiio
 Used ftr ftrward lttkgup tf aioy dtmaiio ioame
For example:
Ogur website is ctiofigured tio 50.63.202.15 IP st the A rectrd tf my dtmaiio ioame will ptiiot
ttwards that IP.
E ery tme a qguery ftr itliioguxhgub.ctm is made the iioterioet will lttkgup ftr ctioteiots sttred tio
the machiioe with 50.63.202.15 this IP.
CNAME Record :

Ratnakar Page 230


[Pick the date] [LINUX NOTES FOR LEVEL 2]

 It is shtrt abbre iattio ftr Caiotioical Name


 Prt ides aio alias ioame ftr same htstioame
 Helps create sgubdtmaiios
NOTE: Ytgu caioiott create a CNAMBE rectrd ftr the dtmaiio ioame itself (it shtguld be dtioe with A
rectrd).
For example:
golinuxhub.com is a dtmaiio ioame whereas www.golinuxhub.com is a sgub dtmaiio ioame.

28. Kickstart Installation and PXE (Network) Installation

1. What is Kickstart installation?


Iiostallattio tf RedHat Liiogux iio iotio-iioteract e mtde is called the Kickstart iiostallattio.
MBaioy system admiioistrattrs wtguld prefer tt guse aio aguttmated iiostallattio methtd tt iiostall
RedHat Eioterprise Liiogux tio their machiioes. Usiioi kickstart a system admiioistrattr caio
create a siioile fle ctiotaiioiioi the aioswer tt all the qguesttios that wtguld iotrmally asked dguriioi a
typical iiostallattio.
Kickstart fles caio be kept tio a siioile ser er system aiod read by iiodi idgual ctmpguters dguriioi the
iiostallattio. This iiostallattio methtd caio sgupptrt the guse tf a siioile kickstart fle tt iiostall
RedHat Eioterprise Liiogux tio mgultple machiioes makiioi it ideal ftr ioetwtrk aiod system
admiioistrattrs.
The defagult Kickstart iiostallattio fle is anaconda-ks.cfg.
2. What are the minimum requirements for kickstart installation?
(i). RedHat Eioterprise Liiogux - 5 6 tr 7 ISO imaie fle with fgull path.
(ii). Kickstart iiostallattio fle like aioactioda-ks.cfi tr tgut cgusttm kickstart iiostallattio fle.
(iii). Ctpy the O/SS ISO imaie fle by ctiofiguriioi the kickstart.
(i ). A ailability tf iiostallattio media tt remtte systems thrtguih NFS FTP tr HTTP
3. How to setup the Kickstart installation server?
(i). Iiostall the system-config-kickstart packaie by # yum install system-config-kickstart -y
ctmmaiod.
(ii). Create a kickstart iiostallattio fle iio GUI mtde.
# system-config-kickstart (this ctmmaiod will display the kickstart
ctiofigurattio wiiodtw).
(iii). Basic Configuration is the frst tpttio iio the kickstart ctiofigurattio wiiodtw aiod we ha e
tt chttse the ftlltwiioi tpttios iio this.
(a). Select the defagult laioiguaie (ftr example Eioilish)..
(b). Select the Keybtard type (ftr example US Eioilish)..
(c). Select the Time stioe (ftr example Asia/SKtlkata)..

Ratnakar Page 231


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(d). Type the Rttt passwtrd aiod Re-type the same tt ctiofrm the rttt passwtrd.
(e). Select the Tariet Architectgure (x86_64 tr 32 bit).
(i ). Installation Method is the sectiod tpttio.
(a). Iiostallattio MBethtd. (Select aioy tioe tpttio).
(1). Perftrm New Iiostallattio
(2). Upirade aio existioi iiostallattio
(b). Iiostallattio Stgurce. (Select aioy tioe
tpttio).
(1). CD-ROMB/SDVD
(2). NFS
(3). FTP
(4). HTTP
(5). Hard Dri e
( ). Boot Loader options is the ioext tpttio iio kickstart ctiofigurattio.
(a). Select Install New Boot Loader tpttio.
( i). Partition Information is the ioext tpttio.
(a). MBaster ttt Rectrd (Select aioy tioe
tpttio).
(1). Create MBaster ttt Rectrd
(2). Dt iott create MBaster ttt Rectrd
(b). Partttios (Select aioy tioe
tpttio).
(1). Remt e all existioi partttios
(2). Remt e existioi Liiogux partttios
(3). Preser e existioi partttios
(c). Disk Label (Select aioy tioe
tpttio).
(1). Iioitalise the disk label
(2). Dt iott iioitalise the disk label
(d). Select Add bgutttio aiod select MBtguiot ptiiot File system type aiod Sises tt create the
partttios.
( ii). Network Configuration is the ioext tpttio.
(a). Select Add Network Device tt add the NIC de ice ctiofigure the IP address either
DHCP tr Statc aiod select eioable the NIC at bttt tme tr iott.
( iii). Authentication is the ioext tpttio.
Select the agutheiotcattio mechaioism like Shadtw passwtrds NIS LDAP tr Kerberts...
etc.
(ix). Firewall Configuration is the ioext tpttio.
Select whether act ate the SELiiogux tr iott Secgurity Le el aiod Firewall Iioftrmattio.
(x). Display Configuration is the ioext tpttio.

Ratnakar Page 232


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Select the display ctiofigurattio tf the O/SS either GUI tr CLI mtde.
(xi). Package Selection is the ioext tpttio.
Select the reqguired packaies ftr iiostallattio. (we caioiott select the
packaies iio RHEL - 7).
(xii). aiod (xiii). Pre-Installation Scripts aiod Post-Installation Scripts are the last tpttios.
If we ha e aioy Pre-iiostallattio tr Ptst-iiostallattio scripts theio we ha e tt specify the
ltcattios tf thtse.
(xi ). Sa e this fe by select the Save tpttio iio File meiogu.
(x ). Exit frtm the Kickstart Ctiofigurattio wiiodtw by select the Quit tpttio iio File meiogu.
(x i). Opeio the kickstart fle aiod the defagult kickstart fle at tme by the ftlltwiioi ctmmaiod.
# vim -O <kickstart file><anaconda file>
Gt tt packaie secttio iio aioactioda fle ctpy the select the packaies aiod paste them iio
the kickstart fle.
(x ii). Check the kickstart fle ftr syiotax errtrs by # ksvalidator <kickstart file> ctmmaiod.
(x iii). Iiostall the webser er packaie by # yum install htpd* -y ctmmaiod.
(xix). Ctpy the kickstart fle iio Dtcgumeiot Rttt tf the webser er aiod preser er the permissitios.
# cp -p <kickstart file> /var/www/html/
(xx). Restart the webser er deamtios iio RHEL - 6 aiod RHEL - 7.
# service htpd restart (tt restart the webser er deamtio iio RHEL - 6).
# chkconfig htpd on (tt eioable the webser er deamtio at ioext
bttt iio RHEL - 6).
# systemctl restart htpd (tt restart the webser er deamtio iio RHEL -
7).
# systemctl enable htpd (tt eioable the webser er deamtio at ioext
bttt iio RHEL - 7).
(xxi). Add the webser er ser ice tt IPtables aiod Firewall.
In RHEL - 6 :
# setup
Select Firewall ctiofigurattio -----> Select HTTP aiod HTTPS tt the frewall
# service iptables save
# service iptables restart
# chkconfig iptables on
In RHEL - 7 :
# firewall-cmd --permanent --add-service=htp
# firewall-cmd --permanent --add-service=htps
# firewall-cmd --complete-reload
4. How to install on client system using kickstart file?
(i). ttt the clieiot system gusiioi RHEL - 6 DVD aiod press Esc key.
(ii). Theio it prtmpts gus boot : screeio.

Ratnakar Page 233


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(iii). Type the ftlltwiioi iioftrmattio abtgut the kickstart fle its ser er aiod alst assiiio stme IP
address tt the clieiot system tt ctmmguioicate with kickstart ser er.
boot : linux ip=< IP address to the client> netmask=<netmask of that IP> ks=fp://< IP
address of the kickstart server>/<kickstart file name with full path>
(press Eioter key).
* Theio the iiostallattio will ctiotiogue by takiioi the iiostallattio iioftrmattio frtm the kickstart
fle.
5. In how many ways can we install RedHat Linux through network?
(i). FTP
(ii). NFS
(iii). HTTP
(i ). PXE
6. How to install RedHat Linux though FTP?
(i). First ctiofigure the FTP ser er aiod ctpy the eiotre RedHat Liiogux DVD iio that FTP dtcgumeiot
rttt directtry.
(ii). Iiostallattio tf Liiogux thrtguih ioetwtrk reqguires tioe boot.iso imaie tr RHEL DVD.
To make a DVD/Pendrive bootable using boot.iso image :
(a). Dtwioltad the bttt.ist imaie frtm redhat website.
# cdrecord /root/boot.iso (/Srttt/Sbttt.ist is the path tf
bttt.ist imaie).
(b). Ctpy the bttt.ist imaie iiott DVD tr peiodri e.
# dd if=/root/boot.iso of=/dev/sdb1 (/Sde /Ssdb1 is the address tf the
US tr peiodri e).
(iii). ttt the system with the abt e created bttt.ist imaie aiod press Esc key tt iet the
boot : prtmpt.
(i ). Theio execgute the beltw ctmmaiod tt iiostall the O/SS.
boot : linux askmethod (Press Eioter key).
( ). Select the preferred laioiguaie ftr iiostallattio (ftr example Eioilish)..
( i). Select the Keybtard laytgut as US.
( ii). Select the urltpttio ftr the iiostallattio media (ftr example FTP/SNFS/SHTTP)..
( iii). Select IP 4 tr IP 6 tt defioe ioetwtrk setiois aiod select dyioamic tr statc tpttios.
(ix). Assiiio the same raioie IP address aiod ioetmask tt the clieiot system tt ctmmguioicate
with ser er.
(x). Theio specify the FTP ser er IP address aiod path tf the iiostallattio media tt iiostall the
O/SS.
7. How to install RedHat Linux through NFS?
(i). MBake aio eiotry iio /Setc/Sexptrts tt exptrt the RHEL media.
# vim /etc/exports
<iiostallattio media directtry> <ioetwtrk ID>(rw syioc). (sa e aiod
exit this fle).

Ratnakar Page 234


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Example :
/S ar/Sfp/Spgub/Srhel6 172.25.9.0(rw syioc). (If the iiostallattio media is iio
/S ar/Sfp/Spgub/Srhel6).
(ii). Exptrt the abt e NFS shared directtry by # exportfs -rv ctmmaiod.
(iii). Theio restart the NFS ser ice by # service restart nfs ctmmaiod aiod add the NFS tt
IPtables tr frewall.
(i ).Iiostallattio tf Liiogux thrtguih ioetwtrk reqguires tioe boot.iso imaie tr RHEL DVD.
To make a DVD/Pendrive bootable using boot.iso image :
(a). Dtwioltad the bttt.ist imaie frtm redhat website.
# cdrecord /root/boot.iso (/Srttt/Sbttt.ist is the path tf
bttt.ist imaie).
(b). Ctpy the bttt.ist imaie iiott DVD tr peiodri e.
# dd if=/root/boot.iso of=/dev/sdb1 (/Sde /Ssdb1 is the address tf the
US tr peiodri e).
( ). ttt the system with the abt e created bttt.ist imaie aiod press Esc key tt iet the boot
: prtmpt.
( i). Theio execgute the beltw ctmmaiod tt iiostall the O/SS.
boot : linux askmethod (Press Eioter key).
( ii). Select the preferred laioiguaie ftr iiostallattio (ftr example Eioilish)..
( iii). Select the Keybtard laytgut as US.
(ix). Theio select the NFS directory tpttio aiod specify the NFS ser er IP address aiod NFS
shared directtry aiod the iiostallattio will be dtioe.
8. How to install the RedHat Linux through HTTP?
(i). First iiostall the http webser er by # yum install htpd* -y ctmmaiod.
(ii). Ctpy the eiotre RHEL DVD ctioteiots iiott /var/www/html/rhel6 by
# cp -rvpf /media/RHEL/*.* /var/www/html/rhel6
(iii). If iott ptssible tt dt the abt e step2 theio create a liiok betweeio the /S ar/Sfp/Spgub/Srhel6
aiod /S ar/Swww/Shtml by # ln -s /var/fp/pub/rhel6
/var/www/html/rhel6 ctmmaiod.
(i ). Restart the http ser ices aiod add it tt the frewall.
In RHEL - 6 :
# service htpd restart (tt restart the http ser ice iio RHEL -
6).
# chkconfig htpd on (tt eioable the http ser ice at ioext
bttt iio RHEL - 6).
# setup (thrtguih the setgup ctmmaiod add the http ser ice
tt the IP tables).
# service iptables save (tt sa e the iptables ctiofigurattio).
# service iptables restart (tt restart the iptables ser ice).
In RHEL - 7 :

Ratnakar Page 235


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# systemctl restart htpd (tt restart the http ser ice iio RHEL -
7).
# systemctl enable htpd (tt eioable the http ser ice at ioext
bttt iio RHEL - 7).
# firewall-cmd --permanent -add-service=htp (tt add the http ser ice tt the
frewall iio RHEL - 7).
# firewall-cmd -complete-reload (tt reltad the frewall ctiofigurattio).
( ). Iiostallattio tf Liiogux thrtguih ioetwtrk reqguires tioe boot.iso imaie tr RHEL DVD.
To make a DVD/Pendrive bootable using boot.iso image :
(a). Dtwioltad the bttt.ist imaie frtm redhat website.
# cdrecord /root/boot.iso (/Srttt/Sbttt.ist is the path tf
bttt.ist imaie).
(b). Ctpy the bttt.ist imaie iiott DVD tr peiodri e.
# dd if=/root/boot.iso of=/dev/sdb1 (/Sde /Ssdb1 is the address tf the
US tr peiodri e).
( i). ttt the system with the abt e created bttt.ist imaie aiod press Esc key tt iet the
boot : prtmpt.
( ii). Theio execgute the beltw ctmmaiod tt iiostall the O/SS.
boot : linux askmethod (Press Eioter key).
( iii). Select the preferred laioiguaie ftr iiostallattio (ftr example Eioilish)..
(ix). Select the Keybtard laytgut as US.
(x). Select the urltpttio ftr the iiostallattio media aiod specify the http tr https IP address
aiod ltcattio.
Example :
http tr https:/S/S172.25.9.11/Srhel6
(xi). Theio iiostallattio tf RedHat Liiogux will be dtioe thrtguih HTTP.
9. What is PXE installation and what are it's requirements?
Aguttmatc Iiostallattio tf RHEL frtm the Netwtrk is called PXE iiostallattio. This is alst called
as guio-atteioded
iiostallattio. The meaios iotbtdy iioteracttio is reqguired iio the iiostallattio prtcess.
PXE staiods ftr Pre Execution. The PXE dtes iott reqguires a RHEL DVD tr aioy bttt.ist
imaie.
The requirements for PXE server :
(i). Statc ioetwtrk at ser er side.
(ii). DHCP ser er shtguld be ctiofigured tio the ser er.
(iii). FTP ser er shtguld be ctiofigured tio the ser er.
(i ). Ygum ser er shtguld be ctiofigured tio the ser er.
( ). TFTP ser er shtguld be ctiofigured tio the ser er.
( i). Create the kickstart iiostallattio fle.

Ratnakar Page 236


[Pick the date] [LINUX NOTES FOR LEVEL 2]

* If all the abt e 5 ser ers are ctiofigured iio tioe ser er that ser er shtguld be called as PXE
ser er.
10. How to configure the PXE server and how to install RedHat from PXE server?
(a). Pgut the RHEL - 6 DVD iiott the DVD dri e aiod it tt Packaies directtry.
# cd /media/RHEL6/Packages
(b). Iiostall the sfpd packaie tt ctiofigure the FTP ser er.
# rpm -ivh vsfpd*
(c). Ctpy the eiotre RHEL - 6 DVD ctioteiots iiott the /S ar/Sfp/Spgub/Srhel6 directtry.
# cp -rvpf /media/RHEL6/*.* /var/fp/pub/rhel6
(d). Restart eioable the fp ser ice at ioext bttt add the ser ice tt IP tables aiod restart the
IP tables.
# service vsfpd restart
# chkconfig vsfpd on
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --deport 21 -j ACCEPT
# iptables -A OUTPUT -m state --state NEW -m tcp -p tcp --deport 21 -j
ACCEPT
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --deport 20 -j ACCEPT
# iptables -A OUTPUT -m state --state NEW -m tcp -p tcp --deport 20 -j
ACCEPT
# service iptables save
# service iptables restart
# chkconfig iptables on
(e). Ctiofigure the ioetwtrk as statc by # setup ctmmaiod aiod restart the ioetwtrk aiod
NetwtrkMBaioaier.
(f). Ctiofigure the ygum ser er.
# vim /etc/yum.repos.d/linux.repo
[liiogux]
ioame=Liiogux ygum ser er
basegurl=fp:/S/S172.25.9.11/Spgub/Srhel6 (Specify the FTP
ser er IP address).
ipicheck=0
eioabled=1 (sa e aiod
exit the fle).
# yum clean all
# yum repolist
(i). Ctiofigure the DHCP ser er.
# yum install dhcp* -y
# cp -rvpf /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
# vim /etc/dhcp/dhcpd.conf
Gt tt liioe iogumber 47 aiod edit the liioe as beltw.

Ratnakar Page 237


[Pick the date] [LINUX NOTES FOR LEVEL 2]

sgubioet 172.25.9.0 ioetmask 255.255.255.0 {


raioie 172.25.9.50 172.25.9.200
* comment on next two lines
tpttio rtguters 172.25.9.11
tpttio brtadcast-address 172.25.9.255
defagult-lease-tme 600
max-lease-tme 7200
alltw btttioi
alltw btttp
ioext-ser er 172.25.9.11
fleioame "Pxeliiogux.0"
aguthtritat e (sa e aiod
exit this fle).
# service dhcpd restart
# chkconfig dhcpd on
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --deport 67 -j ACCEPT
# iptables -A OUTPUT -m state --state NEW -m tcp -p tcp --deport 68 -j
ACCEPT
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --deport 67 -j ACCEPT
# iptables -A OUTPUT -m state --state NEW -m tcp -p tcp --deport 68 -j
ACCEPT
(h). Ctiofigure the TFTP ser er.
# yum install tftp* syslinux* -y
# vim /etc/xinetd.d/tft
* Gt tt disable=yes liioe aiod make it as no (sa e aiod
exit this fle).
# cp -rvpf /media/RHEL6/isolinux/*.* /var/lib/tftpboot
# mkdir /var/lib/tftpboot/pxelinux.cfg
# cp /var/lib/tftpboot/isolinux.cfg /var/lib/ffpboot/pxelinux.cfg/default
# cp -rvpf /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
# service xinetd restart
# chkconfig xinetd on
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --deport 69 -j ACCEPT
# iptables -A OUTPUT -m state --state NEW -m tcp -p tcp --deport 69 -j
ACCEPT
(i). Create the kickstart fle
# yum install system-config-kickstart -y
# system-config-kickstart (create a kickstart fle aiod sa e it iio
/S ar/Sfp/Spgub directtry).
# ksvalidator /var/fp/pub/ks.cfg

Ratnakar Page 238


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(j). Specify the kickstart fle ltcattio iio pxeliiogux.cfi fle.


# vim /var/lib/tftpboot/pxelinux.cfg/default
* Gt tt liioe 19 aiod edit the liioes as beltw.
meiogu label ^ PXE SERVER
meiogu defagult
kerioel mliiogus
appeiod iioitrd=iioitrd.imi liiogux ks=fp:/S/S172.25.9.11/Spgub/Sks.cfi (sa e aiod
exit this fle).
(k). Restart all the ser ices tioce aiaiio.
# service network restart
# chkconfig network on
# service vsfpd restart
# chkconfig vsfpd on
# service dhcpd restart
# chkconfig dhcpd on
# service xinetd restart
# chkconfig xinetd on

Ratnakar Page 239


[Pick the date] [LINUX NOTES FOR LEVEL 2]

29. Veritas Volume Manager and Veritas Cluster

1. What is the diference between Failing and Failed?


Failing :
Failiioi meaios it is itiioi tt fail. Iio failiioi disk's pri ate reiitio is a ailable aiod pgublic reiitio is
iott a ailable. st we caio rect er the data gusiioi the pri ate reiitio.
Failed :
Failed meaios it is already failed. Iio failed disk the btth pri ate aiod pgublic reiitios are iott
a ailable. St we caioiott iet back the (rect er). data. The tioly thiioi is replace tr
resttre the data frtm backgup.
2. What are the deamons of Veritas Volume Manager?
(a). vxconfigd :
(i). This is the maiio deamtio iio Veritas Vtlgume MBaioaier.
(ii). It maiiotaiios the Vtlgume MBaioaier ctiofigurattio iioftrmattio.
(iii). It always resides iio the pri ate reiitio tf the disk.
(i ). It ctmmguioicate with the kerioel aiod gupdate the Vtlgume states tt ctiofigure the database.
( ). It always starts beftre mtguiotioi the rttt ( /S ). fle system.
(b). vxiod :
(i). This is gused tt maiiotaiio I/SO (iiopgut aiod tgutpgut). tperattios.
(ii). This alst defioes htw maioy I/SO tperattios at a tme.
(c). vxrelocd :
(i). It always mtioittrs the ctiosisteiocy iio the disks aiod iottfy the guser if failed gusiioi (by).
vxnotifyd deamtio.
(ii). It alst reltcate aiod rectiioise the ioew disk.

Ratnakar Page 240


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(d). vxrecoverd :
(i). It passes the ltst data iiott ioew disk.
(ii). It alst iottfy tt the Admiioistrattrs gusiioi (by). xiottfyd deamtio.
(e). vxnotifyd :
(i). It iottfy tt the guser (Admiioistrattr). abtgut failed disks aiod afer rect ery alst it iottfy tt
the Admiioistrattr.
3. How to create the root mirror?
(i). riioi the disk frtm O/SS tt Veritas Vtlgume MBaioaier ctiotrtl gusiioi the Veritas Ad aioced
MBaioaiemeiot tttl # vxdiskadm ctmmaiod (It ii es (displays). tpttios ftr easy
admiioistrattio tf Veritas Vtlgume MBaioaier)..
(ii). Select 2iod tpttio ie. Eiocapsgulattio becaguse tt preser e the existioi data preseiot iio the
disk aiod rebttt the system tt efeect Eiocapsgulattio aiod mtdify the /etc/sysconfig
fle. While Eiocapsgulatioi it asks disk ioame aiod disk irtgup (rttt disk ioame aiod rtttdi)..
(iii). ackgup the / (rttt). /etc/sysconfig directtries.
(i ). Take aiotther disk aiod iioitalise it by # vxdisksetup -i <mirrored root disk name>
ctmmaiod.
( ). Add the abt e iioitalised disk tt the tlgume irtgup ie. rttdi by
# vxdg -g <rootdg> adddisk mirrordisk=<mirrored root disk name>
( i). xmirrtr - -i <rtttdi><triiiioal disk ioame><mirrtred rttt disk ioame> (disk le el
mirrtriioi).
( ii). Ftr iiodi idgual mirrtriioi # vxassist -g <rootdg> mirror <volume name> tr
# vxrootmirr -g <rootdg><volume name> ctmmaiod.

4. What is the service group in Vertias Cluster?


Ser ice irtgup is made gup tf restgurces aiod their liioks which we iotrmally reqguires tt maiiotaiio
the Hiih A ailability ftr the applicattio.
5. What is the use of ' halink ' command?
# halink ctmmaiod is gused tt liiok the depeiodeiocies tf the restgurces.
6. What are the diferences between switchover and failover?
SwitchOver FailOver
(i). Switcht er is the maiogual task. (i). gut Failt er is a aguttmatc task.
(ii). We caio switcht er ser ice irtgups frtm tioliioe (ii). gut the failt er will failt er the ser ice irtgup tt
clguster iotde tt tffliioe clguster iotde iiocase tf the tther iotde wheio Veritas Clguster heartbeat
ptwer tgutaie hardware failgure schedgule liiokdtwio damaied brtkeio becaguse tf stme
shgutdtwio aiod rebttt. disaster tr system hguioi.

7. Which the main configuration file for VCS (Veritas Cluster) and where it is stored?
' main.cf ' is the maiio ctiofigurattio fle ftr VCS aiod it is ltcated iio
/etc/VRTSvcs/conf/config directtry.
8. What is the public region and private region?

Ratnakar Page 241


[Pick the date] [LINUX NOTES FOR LEVEL 2]

wheio we briioi the disk frtm O/SS ctiotrtl tt Vtlgume MBaioaier ctiotrtl iio aioy ftrmat (either
CDS simple tr sliced). the disk is ltiically di ided iiott twt parts.
(a). Private region :
It ctiotaiios Veritas ctiofigurattio iioftrmattio like disk type aiod ioame disk irtgup ioame
irtgupid aiod ctiofidb. The defagult sise is 2048 K .
(b). Public region :
It ctiotaiios the actgual guser's data like applicattios databases aiod tthers.
9. There are five disks on VxVM (Veritas Volume Manager) and all are failed. What are the
steps you follow to get those disks into online?
(i). Check the list tf disks iio Vtlgume maioaier ctiotrtl by # vxdisk list ctmmaiod.
(ii). If the abt e disks are iott preseiot theio briioi them O/SS ctiotrtl tt VxVMB ctiotrtl by
# vxdisksetup -i <disk names> (if data is iott tio thtse disk). tr execgute
# vxdiskadm ctmmaiod aiod select 2iod tpttio ie. eiocapsgulattio methtd if the disks
ha iioi the data.
(iii). E eio thtguih If it is iott ptssible theio check the disks are a ailable at O/SS le el by # fdisk
-l ctmmaiod.
(a). If the disks are a ailable execgute the abt e ctmmaiod tioce aiaiio.
(b). If the disks are iott a ailable theio rectiioise them by scaioioiioi the hardware.
(i ). E eio thtguih if it is iott ptssible theio rebttt the system aiod ftlltw the steps (i). aiod (ii)..
10. What is the basic diference between private disk group and shared disk group?
Private disk group :
The disk irtgup is tioly isible ftr the htst tio which we ha e created it. If the htst is a part tf
the clguster the pri ate disk irtgup will iott be isible tt the tther clguster iotdes.
Shared disk group :
The disk irtgup is sharable aiod isible tt the tther clguster iotdes.
11. How will you create private disk group and shared disk group?
# vxdg init <disk group name><disk media name>=<O/S disk name> (tt create the
pri ate disk irtgup).
# vxdg -s init <disk group name><disk media name>=<O/S disk name>(tt create the shared
disk irtgup).
12. How will you add new disk to the existing disk group?
we caio dt this iio twt ways.
(i). Rguio # vxdiskadm ctmmaiod which will tpeio meiogu dri eio prtiram tt dt aritgus disk
tperattios. Select add disk tpttio aiod ii e disk irtgup ioame aiod disk ioame.
(ii). # vxdg -g <disk group name> adddisk <disk media name>=<O/S disk name>
Example: # xdi -i appsdi adddisk disk02=/Sde /Ssdb
13. How will you grow or shrink the volume/file system? What is the meaning of grow by, grow
to, shrink by and shrink to options?
(i). We caio irtw the tlgume/Sfle system by
# xassist -i appsdi irtwby tr irtwtt 100G apps tl (tr).

Ratnakar Page 242


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# xresise -i appsdi +100G apps tl alltc = <disk ioame>


(ii). We caio shriiok the tlgume/Sfle system by
# xassist -i appsdi shriiokby 20G apps tl
# xassist -i appsdi shriioktt 20G apps tl (tr).
# xresise -i appsdi -10G apps tl (tt shriiok by the sise 10G ).
# xresise -i appsdi 10G apps tl (tt shriiok tt the sise 10G ).
Meanings :
growby :
This will be gused tt irtw the fle system by addiioi ioew sise tt the existioi fle system.
growto :
This will be gused tt irtw the fle system guptt the specifed ioew sise. This will iott be added
the ioew sise tt the existioi tioe.
shrinkby :
This will be gused tt shriiok the fle system by redguciioi the ioew sise frtm the existioi fle
system sise.
shrinkto :
This will be gused tt shriiok the fle system guptt the specifed ioew sise. This will iott be
redguced the fle system ioew sise frtm the existioi tioe.
14. If vxdisk list command gives you disk status as " error ". What are the steps you follow to
make respective disk online?
This issgue is maiioly becaguse tf fabric disctioioecttio. St execgute # vxdisk scandisks
ctmmaiod. Otherwise guiosetgup the disks gusiioi # /etc/vx/bin/vxdiskunsetup aiod setgup the
disks aiaiio gusiioi # /etc/vx/bin/vxdisksetup ctmmaiod.
Note :/etc/vx/bin/vxdiskunsetup will remt e the pri ate reiitio frtm the disk aiod destrty the data. St
backgup the data beftre gusiioi this ctmmaiod.

15. Which are the diferent layouts for vxvm?


(i).mirrtr (ii).stripe (defagult).
(iii). ctiocate (i ). raid 5
( ). stripe-mirrtr ( i). mirrtr-stripe
16. How will you setup and unsetup disks explicitly suing vxvm?
# /Setc/S x/Sbiio/S xdisksetgup (tt setgup the disks).
# /Setc/S x/Sbiio/S xdiskguiosetgup (tt guiosetgup the disks).
17. How will you list the disks which are in diferent disk groups?
# xdisk list tr # xpriiot (tt list frtm cgurreiot disk irtgup tr imptrted
disk irtgup).
# xdisk -t alldis (tt list all the disks which are iio difeereiot
disk irtgups).

18. Define LLT and GAB. What are the commands to create them?

Ratnakar Page 243


[Pick the date] [LINUX NOTES FOR LEVEL 2]

LLT :
(i). LLT meaios Ltw Lateiocy Traiosptrt prtttctl
(ii). It mtioittr the kerioel tt kerioel ctmmguioicattio.
(iii). It maiiotaiio aiod distribgute the ioetwtrk trafc withiio the clguster.
(i ). It guses heartbeat betweeio the iioterfaces.
GAB :
(i). GA meaios Gltbal Attmic rtadcastioi.
(ii). It maiiotaiio aiod distribgute the ctiofigurattio iioftrmattio tf the clguster.
(iii). It guses heartbeat betweeio the disks.
Commands :
# iabctiofi -a (tt check the statgus tf the GA ie. GA is
rguioioiioi tr iott).
If ptrt ' a ' is listeioiioi meaios GA is rguioioiioi ttherwise GA is iott rguioioiioi.
If ptrt ' b ' is listeioiioi meaios I/SO feiociioi is eioabled ttherwise I/SO feiociioi is
disabled.
If ptrt ' h ' is listeioiioi meaios had deamtio is wtrkiioi ttherwise had deamtio is
iott wtrkiioi.
# iabctiofi -c io 2 (tt start the GA iio 2 systems iio the clguster where
2 is seed iot.).
# iabctiofi -gu (tt sttp the GA ).
# cat /Setc/Siabtab (tt see the GA ctiofigurattio iioftrmattio aiod the it
ctiotaiios as ).
iabctiofi -c io x (where x is a iot. ie. 1 2 3 ....etc. ).
# lltctiofi -a (tt see the statgus tf the llt).
# lltctiofi -c (tt start the llt).
# lltctiofi -gu (tt sttp the llt).
# lltstat -io (tt see the trafc statgus betweeio the iioterfaces).
# llttab -a (tt see the clguster ID).
# haclgus -display (tt see all the iioftrmattio tio the clguster).
# cat /Setc/Sllttab (tt see the llt ctiofigurattio aiod the eiotries are as ).
Clguster ID htst ID iioterface MBAC address ...etc.
# cat /Setc/Sllthtsts (tt see the iot. tf iotdes preseiot iio the clguster).
19. How to check the status of the Veritas Cluster?
# hastatgus -sgummary
20. Which command is used to check the syntax of the main.cf?
# hacf - erify /Setc/SVRTS cs/Sctiof/Sctiofi
21. How will you check the status of the individual resources of Veritas Cluster (VCS)?
# hares -state <restgurce ioame>
22. What is the use of # hagrp command?

Ratnakar Page 244


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# hairp ctmmaiod is gused dtiioi admiioistrat e acttios tio ser ice irtgups like tio-liioe ser ice
irtgup tfe-liioe ser ice irtgup aiod switch ...etc.
23. How to switch over the service group?
# hairp -switch <System A><System >
24. How to online the service group in VCS?
# hairp -tioliioe <ser ice irtgup ioame> -sys <System A>
25. What are the steps to follow for switch over the application from System A to System B?
(i). First guiomtguiot the fle system tio System A.
(ii). Sttp the tlgume tio System A.
(iii).Deptrt the disk irtgup frtm System A.
(i ). Imptrt the disk irtgup tt aiotther System .
( ). Start the tlgume tio System .
( i). Fiioally mtguiot the fle system tio System .
26. How many types of clusters available?
(i). Hybrid Clguster.
(ii). Parallel Clguster.
(iii). Failt er Clguster.
27. What is meant by seeding?
Ntrmally we will defioe htw maioy iotdes tt start iio a clguster while btttioi tr explicitly by
execgutioi
# gabconfig -c n 2 ctmmaiod. Here 2 meaios 2 seeds tt start iio a clguster. This iot. is
called seediioi.
28. What is Split brain issue in VCS and how to resolve this?
A Split braiio issgue meaios mgultple systems guse the same exclgusi e restgurces aiod gusgually
resgultioi iio data ctrrgupttio.
Ntrmally VCS is ctiofigured with mgultple iotdes aiod are ctmmguioicates with each tther.
Wheio ptwer ltss tr system crashed the VCS assgumes the system has failed aiod tryiioi tt mt e
ser ice irtgup tt tther system tt maiiotaiio hiih a ailability. Htwe er ctmmguioicattio
(heartbeat). caio alst failed dgue tt ioetwtrk failgures.
If ioetwtrk trafc (ctioioecttio). betweeio aioy twt irtgups tf systems fail simgultaioetgusly a
ioetwtrk partttio tccgurs. Wheio this happeio systems tio btth sides tf the partttio caio restart
the applicattios frtm the tther side ie. resgultioi iio dguplicate ser ices. St the mtst seritgus
prtblem cagused by this aiod efeects the data tio shared disks.
This split braiio issgue iotrmally tccgurs iio VCS 3.5 tt VCS 4.0 ersitios. gut frtm VCS 5.0
tiowards the I/SO feiociioi (ioew featgure). is iiotrtdguced tt miioimise the split braiio issgue. If I/SO
feiociioi is eioabled iio a clguster theio we caio a tid the split braiio issgue.
29. What is Admin wait and Stale Admin wait?
ADMIN-WAIT :
If VCS is started tio system with a alid ctiofigurattio fle aiod tther systems are iio the ADMIN-
WAIT state The ioew system traiosittio tt the ADMIN-WAIT state (tr).

Ratnakar Page 245


[Pick the date] [LINUX NOTES FOR LEVEL 2]

If VCS is started tio system with a stale ctiofigurattio fle aiod if tther systems are iio the
ADMIN-WAIT state the ioew system traiosittio tt the ADMIN-WAIT state.
STALE-ADMIN-WAIT :
The ctiofigurattio fles are iio read-tioly mtde. If aioy chaioies waiots tt make that fle as read-
write mtde. If aioy chaioies tccgurs iio ' main.cf ' fle iio clguster theio the chaioies are iio ' .stale '
hiddeio fle guioder ctiofigurattio directtry. While chaioies tccgurriioi if the system restarted tr
rebttted theio the clguster will start with ' .stale ' fle. St the VCS is started tio a system
with a stale ctiofigurattio fle the system statgus will be STALE- ADMIN-WAIT guiotl aiotther
system iio the clguster starts with a alid ctiofigurattio fle tr ttherwise execgute
# hasys -stale -force <system name> (tr). # hasys -force <system name> tt start
the system ftrcefgully with the ctrrect tr alid ctiofigurattio fle.
30. What is meant by resource and how many types?
Resource is a stfware tr hardware ctmptioeiot maioaied by the VCS.
MBtguiot ptiiots disk irtgups tlgumes IP addresses ....etc. are the Stfware ctmptioeiots.
Disks Iioterfaces (NIC cards). ....etc. are the Hardware ctmptioeiots.
There are twt types tf restgurces aiod they are
(i). Persisteiot Restgurces (we caio pgut them either tio-liioe tr tfe-liioe).
(ii). Ntio-Persisteiot Restgurces (we caio pgut tfe-liioe tioly).
If the restgurce is iio fagulted state theio clear the ser ice irtgup state. Restgurces cab be critcal
tr iotio-critcal. If the restgurce is critcal theio it aguttmatcally failt er if the restgurce is
failed. If the restgurce is Ntio-critcal theio it switch t er aiod we ha e tt maiogually switch t er the
restgurce irtgup tt aiotther a ailable system.
31. What are the dependencies between resources in a Cluster?
If tioe restgurce depeiods tio tther restgurce theio there is a depeiodeiocy betweeio thtse
restgurces.
Example : NIC (Netwtrk Iioterface Card). is hardware ctmptioeiot iotthiioi bgut hardware
restgurce. The IP address is a stfware ctmptioeiot iotthiioi bgut stfware restgurce aiod it
depeiods tio NIC card. The relattioship betweeio NIC aiod IP address is Parent - Child
relattioship. The restgurce which tioe is starts frst that tioe is called Parentresource aiod the
remaiioiioi depeiodeiocy restgurces are called Child resource.
32. What are the minimum requirements for or in VCS?
(i). MBiioimgum twt ideiotcal (same ctiofigurattio). systems.
(ii). Twt switches (Optcal Fibre Chaioioel)..
(iii). MBiioimgum three NIC cards. (Twt NICs ftr pri ate ioetwtrk aiod tioe NIC ftr pgublic
ioetwtrk)..
(i ). Oioe ctmmtio sttraie.
( ). Veritas Vtlgume MBaioaier with liceiose.
( i). Veritas Clguster with liceiose.
33. What are the Veritas Cluster deamons?
(i). had :

Ratnakar Page 246


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(a). It is the maiio deamtio iio Veritas Clguster ftr hiih a ailability.
(b). It mtioittrs the clguster ctiofigurattio aiod whtle clguster eio irtiomeiot.
(c). It iioteracts with all the aieiots aiod restgurces.
(ii). hashadow :
(a). It always mtioittr the had deamtio.
(b). It's maiio fguiocttioality is ltiiiioi abtgut the clguster.
35. What are the main configuration files in a Cluster?
* /Setc/SVRTS cs/Sctiof/Sctiofi/Smaiio.cf aiod
* /Setc/SVRTS cs/Sctiof/Sctiofi/Stypes.cf are the maiio ctiofigurattio fles iio Clguster.
36. What are the main log files in a Cluster?
(i). /S ar/SVRTS cs/Slti/SEioiiioe_A.lti (ltiiiioi abtgut wheio the clguster started wheio
failed wheio failt er
tccgurs wheio switcht er ftrcefgully ...etc. ).
(ii). /S ar/SVRTS cs/Slti/Shashadtw_A.lti (ltiiiioi abtgut the hashadtw deamtio).
(iii). /S ar/SVRTS cs/Slti/Saieiot_A.lti (ltiiiioi btgut aieiots).
37. What are the Cluster components?
(i). Clguster.
(ii). Ser ice irtgups.
(iii).Restgurces.
(i ). Aieiots.
( ). E eiots.
38. What is your role in the Cluster?
Ntrmally we will iet reqguests like
(i). Add a iotde.
(ii). Add a restgurce.
(iii). Add a ser ice irtgup.
(i ). Add a restgurce tt the existioi ser ice irtgup.
( ). Add mtguiot ptiiots.
Aiod stmetmes we iet stme trtgubleshtttioi issgues like
(i). had deamtio is iott rguioioiioi.
(ii). Split bariio issgue.
(iii).If the restgurces are fagulted theio restart the ser ice irtgups aiod mt iioi ser ice irtgups frtm
tioe iotde tt aiotther.
(i ). Clguster is iott rguioioiioi.
( ). Ctmmguioicattio failed betweeio twt iotdes.
( i). GA aiod LLT are iott rguioioiioi.
( ii). Restgurce iott started.
( iii). maiio.cf aiod types.cf fles ctrrgupted.
(ix). I/SO feiociioi (a ltckiioi mechaioism tt a tid the split braiio issgue). is iott eioabled (at disk
le el /S SAN le el)..

Ratnakar Page 247


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(x). Aiod the ltcks are


(a). eioiiioe.ltck
(b). ha.ltck
(c). aieiot.ltck
39. What are the statuses of a service group?
(i). tioliioe
(ii). tffliioe
(iii). partal
* If the iotio-critcal restgurce is failed theio the statgus tf the ser ice irtgup may be iio partal
statgus.
* If the critcal restgurce is failed theio the statgus tf the ser ice irtgup may be iio tffliioe
statgus.
40. How to move the service group from one node to another node manually?
(i). Sttp the applicattio.
(ii). Sttp the database.
(iii).Uiomtguiot the fle system.
(i ). Sttp the tlgume.
( ). Deptrt the disk irtgup.
( i). Imptrt the disk irtgup.
( ii). Start the tlgume.
( iii). MBtguiot the fle system.
(ix). Start the database.
(x). Start the applicattio.
41. How to rename a disk group in VxVM in stepwise?
(i). Sttp the applicattio.
(ii). Sttp the database.
(iii).Uiomtguiot the fle system.
(i ). Sttp the tlgume.
( ). Deptrt the disk irtgup.
( i).Reioame the disk irtgup.
( ii). Imptrt the disk irtgup.
(ix). Start the tlgume.
(x). MBtguiot the fle system.
(xi). Start the database.
(xii). Start the applicattio.
42. How to create a volume with 4 disks?
(i). riioi the disks tt O/SS ctiotrtl by scaioioiioi the Lguios gusiioi the ftlltwiioi the ctmmaiod
# echt "---" > /Ssys/Sclass/Sscsi_htst/S< lguio iot. >/Sscaio (tt scaio the lguio iot.).
(ii). riioi thtse disk frtm O/SS ctiotrtl tt VxVMB ctiotrtl.

Ratnakar Page 248


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(a). If we waiot tt preser e the data theio briioi the disks tt VxVMB ctiotrtl gusiioi
eiocapsgulattio methtd by
# xdiskadm (here we iet the tpttios tt dt this aiod select 2iod tpttio ie.
Eiocapsgulattio).
(b). If we dtio't waiot tt preser e the data theio briioi the disks tt VxVMB ctiotrtl gusiioi
iioitalisattio methtd by # xdisksetgup -i <disk 1 ioame> (ftr example #
xdisksetgup -i /Sde /Ssda).
# xdisksetgup -i <disk 2 ioame> (ftr example # xdisksetgup -i
/Sde /Ssdb).
# xdisksetgup -i <disk 3 ioame> (ftr example # xdisksetgup -i
/Sde /Ssdc).
# xdisksetgup -i <disk 4 ioame> (ftr example # xdisksetgup -i
/Sde /Ssdd).
# xdisk list (tt see VxVMB ctiotrtlled disks).
(iii).Create a disk irtgup.
# xdi iioit <diskirtgup ioame> disk01=/Sde /Ssda (ftr example diskirtgup ioame as
appsdi).
(i ).Addiioi remaiioiioi three disks tt the abt e disk irtgup.
# xdi -i appsdi adddisk disk02=/Sde /Ssdb
# xdi -i appsdi adddisk disk02=/Sde /Ssdc
# xdi -i appsdi adddisk disk02=/Sde /Ssdd
# xdi list <diskirtgup ioame> (tt see all the disks beltiois tt that diskirtgup ftr
example appsdi).
( ). Create the Vtlgume (ftr the reqguested sise aiod reqguested laytgut)..
# xassist -i appsdi make < tlgume ioame><sise> (ftr example tlgume ioame
is apps tl aiod
sise iio T /SG ... etc).
( i). Create a fle system tio that tlgume.
# mkfs -F xfs /Sde /S x/Srdsk/Sappsdi/Sapps tl
( ii). Create the mtguiot ptiiot aiod prt ide the reqguested permissitios tt that mtguiot ptiiot.
# mkdir /Smiot/Sapps
( iii). Start the tlgume.
# x tl -i appsdi start apps tl
(ix).MBtguiot the fle system tio the abt e mtguiot ptiiot.
# mtguiot -F xfs -t <tpttios like rw re> /Sde /S x/Sdsk/Sappsdi/Sapps tl
(where rw meaios read-write aiod re meaios read-tioly).
(x). Pgut the eiotry iiott the "/Setc/Sfstab" fle ftr permaioeiot mtguiot.
* If the tlgume is created ftr clguster dtio't pgut the eiotry iio /Setc/Sfstab fle.
(xi). Aiod fioally seiod the mail tt clieiot tr reqguested perstio

Ratnakar Page 249


[Pick the date] [LINUX NOTES FOR LEVEL 2]

43. What is the diference between Global Cluster and Local Cluster? Have you configured the
Global Cluster?
Local Cluster :
If all the iotdes iio a Clguster are placed iio a same ltcattio that Clguster is called Ltcal Clguster.
Global Cluster :
If all the iotdes iio a Clguster are placed iio difeereiot Getltiical ltcattios that Clguster is called
Gltbal Clguster. The maiio ad aiotaie tf iltbal clguster is hiih a ailability wheio Natgural Calamites
tr disasters tccgurs.

* Nt I ha eio't ctiofigure the Gltbal Clguster.


44. How to start and stop the Cluster?
# hastart (tt start the ltcal iotde iio the Clguster).
# hastart all (tt start all the iotdes iio the Clguster).
# hastart -sys <system tr iotde ioame> (tt start a specifed system tr iotde iio
the Clguster).
# hasys -ftrce <system tr iotde ioame> (tt ftrcefgully start the system iio the
Clguster).
# hasttp (tt sttp the ltcal iotde iio the Clguster).
# hasttp all (tt sttp all the systems iio the Clguster).
# hasttp -sys <system tr iotde ioame> (tt sttp the specifed system tr iotde iio
the Clguster).
45. What is the Service group and Resource?
Service group :
(i). A ctllecttio tr irtgup tf physical aiod ltiical restgurces is called the Ser ice irtgup.
(ii). MBt iioi ser ice irtgup frtm tioe system tt aiotther system meaios mt iioi restgurces frtm
tioe system tt aiotther system.
Resources :
(i). It is a stfware tr hardware ctmptioeiots like diskirtgup tlgume IP address mtguiot
ptiiot are stfware restgurces aiod disk NIC cards are hardware restgurces.
(ii). The algue tf restgurce is kiotwio as Attribgute.
Example : (a). System list is attribgute tf a System A tr System .
(b). Agutt start is the attribgute tf System.
Resource Atribute Value
NIC IP address 192.168.1.1
Diskirtgup diskirtgup ioame appsdi
Disk disk ioame disk01
Iioterface Iioterface ioame eth0

(iii). There are twt types tf restgurces.


(a). Persistent Resource :

Ratnakar Page 250


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Thtse restgurces which we caioiott start tr sttp are called Persisteiot restgurces.
` Stme restgurces we caio start/Ssttp aiod stme tther restgurces we caioiott sttp tr start.
Example : We caioiott start tr sttp the NIC card.
(b). Non - Persistent Resource :
Thtse restgurces which we caio start/Ssttp are called Ntio - Persisteiot Restgurces.
(i ). Restgurces may be critcal tr iotio-critcal. We ioeed tt desiiio the restgurces as critcal tr
iotio-critcal. ie. the cgusttmer will iiosists which is critcal aiod which is iotio-critcal.
( ). If critcal restgurce is failed theio tioly the ser ice irtgup mt ed aguttmatcally frtm tioe
system tt aiotther system. ie. failt er ttherwise if iotio-critcal restgurce is failed
theio we ioeed tt the maiogual mt emeiot tf ser ice irtgup frtm tioe system tt aiotther
system. ie. switcht er.
46. What are the steps you follow to put the volume in a Cluster?
(i). First create the diskirtgup tlgume aiod create the fle system aiod mtguiot aiod guiomtguiot
beftre pgut the tlgume iio a clguster becaguse testioi tf that tlgume is wtrkiioi tr iott.
(ii). Create the ser ice irtgup aiod add the Attribgutes tt it.
# hairp -add <ser ice irtgup>
Example: # hairp -add appssi

Atributes :
# hairp -mtdify appssi system list={ sys A0 sys 0} (tt add sys A aiod sys attribgutes
tt ser ice irtgup).
# hairp -mtdify appssi aguttstart list={ sys A} (tt start the sys A attribgutes
aguttmatcally).
# hairp -mtdify appssi eioabled 1 tr 0 (1 meaios start aiod 0 meaios iott tt start
aguttmatcally).
(iii). Creatioi restgurces aiod addiioi them tt the ser ice irtgup aiod specify their attribgutes.
For file system :
(a). /Smiot/Sapps (the mtguiot ptiiot).
(b). /Sapps tl (the tlgume ioame).
(c). /Sappsdi (the disk irtgup).
# hares -add di-apps diskirtgup appssi (tt add the diskirtgup restgurce tt a
ser ice irtgup).
(where di-apps is restgurce ioame diskirtgup is a keywtrd aiod appssi is a ser ice
irtgup ioame).
# hares -mtdify di-apps diskirtgup appsdi (tt add the diskirtgup attribgute tt a
ser ice irtgup).
# hares -mtdify di-apps eioable 1 (tt eioable the restgurce).
# hares -add di- tlgume tlgume appssi (tt add the tlgume restgurce tt a
ser ice irtgup).

Ratnakar Page 251


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# hares -mtdify di- tlgume tlgume apps tl (tt add the tlgume attribgute tt a
ser ice irtgup).
# hares -mtdify di- tlgume diskirtgup appsdi (tt add the diskirtgup tt the
tlgume).
# hares -mtdify di- tlgume eioable 1 (tt eioable the tlgume restgurce).
# hares -mtdify di- tlgume critcal 1 (tt make the restgurce as critcal).
# hares -add di-miot mtguiot appssi (tt add the mtguiot ptiiot restgurce tt
a ser ice irtgup).
# hares -mtdify di-miot bltckde ice=/Sde /S x/Srdsk/Sappsdi/Sapps tl (tt add the bltck
de ice restgurce
tt a ser ice irtgup).
# hares -mtdify di-miot fstype= xfs (tt add the mtguiot ptiiot attribgutes tt
a ser ice irtgup).
# hares -mtdify di-miot mtguiot=/Smiot/Sapps (tt add the mtguiot ptiiot directtry
attribgute tt a
ser ice irtgup).
# hares -mtdify di-miot fscktpt=% y tr %io (tt add the fsck attribgute either yes
tr iot tt
ser ice irtgup).
(i ). Create liioks betweeio the abt e diskirtgup tlgume aiod mtguiot ptiiot restgurces.
# hares -liiok pareiot-res child-res
# hares -liiok di-appdi di- tlgume
# hares -liiok di- tlgume di-miot
47. What is meant by freezing and unfreezing a service group with persistent and evacuate
options?
Freezing :
If we waiot tt apply patches tt the system iio a clguster theio we ha e tt freese the ser ice irtgup
becaguse frst sttp the ser ice irtgup if it is critcal the ser ice irtgup will mt e aguttmatcally tt
aiotther system iio Clguster. St we dtio't waiot tt mt e the ser ice irtgup frtm tioe system tt
aiotther system we ha e tt freese the ser ice irtgup.
Unfreeze :
Afer ctmpletioi the task the ser ice irtgup shtguld be guiofreesed becaguse if the is crashed tr
dtwio aiod the restgurces are critcal theio the ser ice irtgup caioiott mt e frtm system 1 tt
system 2 dgue tt freesed the ser ice irtgup aiod resgults iio iott a ailable tf applicattio. If
guiofreesed the ser ice irtgup afer maiioteioaioce the ser ice irtgup caio mt e frtm system 1 tt
system 2. St if system 1 failed the system2 is a ailable aiod applicattio alst a ailable.
Persistent option :
If the ser ice irtgup is freesed with persisteiot tpttio theio we caio sttp tr dtwio tr restart
the system. St there is iot ltss tf data aiod afer restarted the system the ser ice irtgup is remaiios
iio freesed state tioly.

Ratnakar Page 252


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Example : # hasys -freese -persisteiot <system ioame>


# hasys -guiofreese -persisteiot <system ioame>
Evacuate :
If this tpttio is gused iio freesed ser ice irtgup system if the system dtwio tr restarted the
persisted iioftrmattio is e acguated ie. beftre freese all the ser ice irtgups shtguld be mt ed
frtm system 1 tt aiotther system 2.
48. What are the layouts are available in VxVM and how they will work and how to configure?
(i). There are 5 laytguts a ailable iio VxVMB. They are RAID-0 RAID-1 RAID-5 RAID-0+1 aiod
RAID-1+0.
RAID-0 :
We caio ctiofigure RAID-0 iio twt ways.
(a). Stripped (defagult)..
(b). Ctiocateioattio.
Stripped :
(i). Iio this miioimgum twt disks reqguired tt ctiofigure.
(ii). Iio this the data will write tio btth the disks parallelly. ie. tioe liioe iio tioe disk aiod 2iod liioe tio
2iod disk ...etc.
(iii). Iio this the data writioi speed is fast.
(i ). Iio this there is iot redguiodaiocy ftr data.
Concatenation :
(i). Iio this miioimgum tioe disk is reqguired tt ctiofigure.
(ii). Iio this the data will write iio frst disk aiod afer flliioi tf frst disk theio it will write tio 2iod
disk.
(iii).Iio this the data writioi speed is less.
(i ). Iio this alst there is iot redguiodaiocy ftr data.
RAID-1 :
(I). It is iotthiioi bgut mirrtriioi.
(ii). Iio this miioimgum 4 disks are reqguired tt ctiofigure.
(iii).Iio this same data will be writteio tio disk1 aiod disk 3 disk 2 aiod disk4.
(i ). If disk 1 failed theio we caio rect er the data frtm disk3 aiod if disk 2 failed theio we caio
rect er the data frtm disk 4. St there is iot data ltss tr we caio miioimise the data
ltss.
( ). Iio this half tf the disk space may be wasted.
RAID-5 :
(i). It is iotthiioi bgut stripped with distribguted parity.
(ii). Iio this miioimgum 3 disks reqguired tt ctiofigure.
(iii).Iio this tioe liioe will write tio disk 1 aiod 2iod liioe write tio disk 2 aiod the parity bit will write
tio disk3. The parity bit will write tio 3 disk simgultaioetgusly. If disk 1 failed theio we caio
rect er the data frtm disk2 aiod parity bit frtm disk 3. St iio this data will be mtre
secgured.

Ratnakar Page 253


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(i ). Iio this disk gutlisattio is mtre wheio ctmpared tt RAID-1 ie. 1/S3 rd tf disk space may be
wasted.
( ). This RAID-5 will be ctiofigured ftr critcal applicattios like aiokiioi Fiioaiocial SAX aiod
Iiosguraioce...etc. becaguse the data mgust be mtre secgured.
Creating a volume with layout :
# xassist -i <diskirtgup ioame> make < tlgume ioame><sise iio G /ST >
laytgut=<mirrtr/Sraid 5/Sraid 1>
Example : # xassist -i appsdi make apps tl 50G laytgut=raid 5 (the defagult is
RAID-5 iio VxVMB).

Logs :
* If the laytgut is mirrtr theio lti is DRL.
* If the laytgut is RAID-5 theio the lti is RAID-5 lti.
* The maiio pgurptse tf the lti is fast rect ery tperattio.
* We ha e tt specify whether the lti is reqguired tr iott iio all types tf laytguts except RAID-5
becaguse the ltiiiioi is defagult iio RAID-5.
* If we waiot tt ctiofigure RAID-5 withtgut ltiiiioi theio
# xassist -i <diskirtgup ioame> make < tlgume ioame> 50G iotlti laytgut=raid 5
* If the laytgut is tther thaio RAID-5 theio
# xassist -i <diskirtgup ioame> make < tlgume ioame> 50G lti laytgut=mirrtr
* If we waiot tt add the lti tt the existioi tlgume theio
# xassist -i <diskirtgup ioame> addlti ltitype=drl tr raid5
* If we waiot tt remt e the lti frtm the existioi tlgume theio
# xassist -i <diskirtgup ioame> rmlti < tlgume ioame>
49. What is read policy and how many types of read policies available?
Read ptlicy meaios htw the disk tr tlgume shtguld be read wheio accessiioi the data.
Types of read policies :
(i). Select
(ii). Prefer
(iii).Rtguiod Rtbiio
* y defagult the read ptlicy is Rtguiod Rtbiio.
# x tl -i <diskirtgup ioame> rdptl = < select/Sprefer/Srtguiodrtbiio < tlgume ioame>
50. What is your role in VxVM?
Ntrmally we iet reqguests frtm applicattio de eltpmeiot prtdgucttio aiod QA petple like
(i). Create a tlgume.
(ii). Iiocrease the tlgume.
(iii).Decrease the tlgume.
(i ). Prt ide Redguiodaiocy by implemeiotioi RAID-1 tr RAID-5.
( ). Prt ide the reqguired permissitios.
( i). Pgut the tlgume iio the Virtgual machiioe.

Ratnakar Page 254


[Pick the date] [LINUX NOTES FOR LEVEL 2]

( ii). Pgut the tlgume iio the Clguster.


( iii). Prt ide hiih a ailability tt the applicattios aiod databases.
(ix). Stmetmes destrty tr remt e the tlgume.
(x). ackgup aiod resttre the data wheioe er ioecessary.
Aiod stmetmes we iet stme trtgubleshtttioi issgues like
(i). Vtlgume is iott started.
(ii). Vtlgume is iott accessible.
(iii). MBtguiot ptiiot deleted.
(i ). File system crashed.
( ). Oioe disk failed iio a tlgume.
( i). Vtlgume maioaier deamtios are iott rguioioiioi.
( ii). Vtlgume maioaier ctiofigurattio fles missed tr deleted.
( iii). VxVMB liceiosiioi issgues.
(ix). Diskirtgup iott deptrtioi aiod iott imptrtioi.
(x). Vtlgume is started deamtios are rguioioiioi bgut gusers caioiott accessiioi the data.
(xi). Disk are iott ditected.
(xii). Hardware aiod stfware errtrs.
51. What is meant by snap backup and how to take the snap backup?
(i). Sioap backgup meaios takiioi backgup gusiioi sioapshtts.
(ii). Iio 24X7/S365 days rguioioiioi ser ers iotrmally we take sioap backgup.ie. iot dtwiotme alltwed.
(iii). The abt e said ser ers are called CV ( gusiioess Ctiotioguity Vtlgumes)..
Backup :
(i). First sttp the Applicattio.
(ii). Sttp the Database.
(ii). Uiomtguiot the fle system.
(iii).Sttp the tlgume.
(i ).Deptrt the diskirtgup.
( ). Imptrt the diskirtgup.
( i).Jtiio the sioap diskirtgup.
( ii). Syiociioi the data.
( iii). Take the backgup.
(ix). Split the sioap diskirtgup.
(x). Deptrt the diskirtgup.
(xi).Imptrt the diskirtgup.
(xii). Start the tlgume.
(xiii). MBtguiot the fle system.
(xi ). Start the Database.
(x ). Start the Applicattio.
52. What are the steps you follow to rename a diskgroup?
(i). Sttp the Applicattio.

Ratnakar Page 255


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(ii). Sttp the Database.


(iii). Uiomtguiot the fle system.
(i ). Sttp the tlgume.
( ). Deptrt the diskirtgup.
( i). Reioame the diskirtgup.
( ii). Imptrt the diskirtgup by
# vxdg -n <new diskgroup name> import <old diskgroup name> ctmmaiod.
( iii). Start the tlgume.
(ix). MBtguiot the fle system.
(x). Start the Database.
(xi). Start the Applicattio.
53. How to install VxVM? What version of Veritas you are using and how to know the veritas
version?
(i). Iiostall the eritas sgupplied packaies gusiioi # rpm tr # yum ctmmaiods.
(ii). Execgute the ctmmaiod #vxinstall tt iiostall VxVMB ie. eioable the system tt guse tlgume
maioaier.
(iii). #vxinstall will alltw gus tt eiocapsgulate tr iott eiocapsgulate the rttt disk.
(i ). Always guse tpttio 2 ie. Cgusttm iiostallattio becaguse if tpttio 1 is gused ie. Qguick
iiostallattio it takes all the disks ftr rtttdi.

License :
(i). All the liceioses are sttred iio /etc/vx/licenses directtry aiod we caio take backgup tf this
directtry aiod resttre it back if we ioeed reiiostall the ser er.
(ii). Remt iioi VxVMB packaie will iott remt e the iiostalled liceiose.
(iii).Tt iiostall liceiose # vxlicinst ctmmaiod is gused.
(i ). Tt see the VxVMB liceiose iioftrmattio by # vxlicrep ctmmaiod.
( ). Tt remt e the VxVMB liceiose by # vxkeyless set NONE ctmmaiod.
( i).The liceiose packaies are iiostalled iio /opt/VRTSvlic/bin/vxlicrep directtry.
( ii). The liceiose keys are sttred iio /etc/vx/licenses/lic directtry.
( iii). We caio see the liceioses by execgutioi the beltw ctmmaiods
# cat /etc/vx/licenses/lic/key tr
# cat /opt/VRTSvlic/bin/vxlicrep | grep "License key"
(ix). Tt see the featgures tf liceiose key by # vxdctl license ctmmaiod.
Version :
(i). We are gusiioi VxVM6.2 ersitio.
(ii). tt kiotw the ersitio tf VxVMB by # rpm -qa VRTSvxvm ctmmaiod.
54. What are the available formats to take the control of disks from O/S to veritas in VxVM?
We caio take the ctiotrtl tf disks frtm O/SS tt eritas iio 3 ftrmats.
(i). CDS (Crtss plattrm Data Shariioi aiod the defagult ftrmat iio VxVMB)..
(ii). Sliced.

Ratnakar Page 256


[Pick the date] [LINUX NOTES FOR LEVEL 2]

(iii). Simple.
(i). CDS :
(a). We caio share the data betweeio difeereiot Uioix fa tgurs.
(b). The pri ate aiod pgublic btth reiitios are a ailable iio 7th partttio.
(c). The eiotre space is iio 7th partttio.
(d). St there is a chaioce tt ltss the data becaguse if the disk is failed ie. partttio 7 is
ctrrgupted tr damaied theio the data may be ltst.
(e). This is the defagult iio eritas tlgume maioaier.
(ii). Sliced :
(a). It is always gused ftr rttt disk tioly.
(b). Iio this ftrmat we caioiott share the data betweeio difeereiot Uioix fa tgurs. Ntrmally sliced
is gused ftr rttt disk aiod cds is gused ftr data.
(c). Pri ate reiitio is a ailable at 4th partttio aiod pgublic reiitio is a ailable at 3rd partttio.
(d). St if pgublic reiitio is failed we caio rect er the data frtm pri ate reiitio ie. miioimisiioi
the data ltss.
(iii). Simple :
(a). This ftrmat is iott gusiioi widely iotw becaguse it is a ailable iio tld VxVMB 3.5
(b). Iio this pri ate aiod pgublic reiitios are a ailable at 3rd partttio.
Specifying the format while setup :
# xdisksetgup -i /Sde /Ssda (tt setgup the disk aiod this is defagult ftrmat ie.
CDS ftrmat).
# xdisksetgup -i /Sde /Ssdb ftrmat =<sliced /S simple> (tt specify sliced tr
simple ftrmat).
55. In how many ways can we manage VxVM?
(I). Ctmmaiod liioe tttl.
(ii). GUI ( ea tttl).
(iii). # xdiskadm ctmmaiod (it ii es the tpttios tt maioaie the disks).
30. RedHat Cluster

1. How can you define a cluster and what are its basic types?
A clguster is twt tr mtre ctmpguters (called iotdes tr members). that wtrk ttiether tt perftrm a
task. There are ftgur majtr types tf clgusters:
 Sttraie
 Hiih a ailability
 Ltad balaiociioi
 Hiih perftrmaioce
2. What is Storage Cluster?
 Sttraie clgusters prt ide a ctiosisteiot fle system imaie acrtss ser ers iio a clguster alltwiioi
the ser ers tt simgultaioetgusly read aiod write tt a siioile shared fle system.

Ratnakar Page 257


[Pick the date] [LINUX NOTES FOR LEVEL 2]

 A sttraie clguster simplifes sttraie admiioistrattio by limitioi the iiostallattio aiod patchiioi tf
applicattios tt tioe fle system.
 The Hiih A ailability Add-Oio prt ides sttraie clgusteriioi iio ctiojguiocttio with Red Hat GFS2
3. What is High Availability Cluster?
 Hiih a ailability clgusters prt ide hiihly a ailable ser ices by elimiioatioi siioile ptiiots
tf failureaiod by failiioi t er ser ices frtm tioe clguster iotde tt aiotther iio case a iotde
bectmes iiotperat e.
 Typically ser ices iio a hiih a ailability clguster read aiod write data ( ia read-write mtguioted
fle systems)..
 A hiih a ailability clguster mgust maiiotaiio data iioteirity as tioe clguster iotde takes t er ctiotrtl
tf a ser ice frtm aiotther clguster iotde.
 Ntde failgures iio a hiih a ailability clguster are iott isible frtm clieiots tgutside the clguster.
 Hiih a ailability clgusters are stmetmes referred tt as failt er clgusters.
4. What is Load Balancing Cluster?
 Ltad-balaiociioi clgusters dispatch ioetwtrk ser ice reqguests tt mgultple clguster iotdes tt
balaioce the reqguest ltad amtioi the clguster iotdes.
 Ltad balaiociioi prt ides ctst-efeect e scalability becaguse ytgu caio match the iogumber tf
iotdes acctrdiioi tt ltad reqguiremeiots. If a iotde iio a ltad-balaiociioi clguster bectmes
iiotperat e the ltad-balaiociioi stfware detects the failgure aiod redirects reqguests tt tther
clguster iotdes.
 Ntde failgures iio a ltad-balaiociioi clguster are iott isible frtm clieiots tgutside the clguster.
 Ltad balaiociioi is a ailable with the Ltad alaiocer Add-Oio.
5. What is a High Performance Cluster?
 Hiih-perftrmaioce clgusters guse clguster iotdes tt perftrm ctiocgurreiot calcgulattios.
 A hiih-perftrmaioce clguster alltws applicattios tt wtrk iio parallel thereftre eiohaiociioi the
perftrmaioce tf the applicattios.
 Hiih perftrmaioce clgusters are alst referred tt as ctmpgutattioal clgusters tr irid ctmpgutioi.
6. How many nodes are supported in Red hat 6 Cluster?
A clguster ctiofigured with qdiskd sgupptrts a maximgum tf 16 iotdes. The reastio ftr the limit is
becaguse tf scalability iiocreasiioi the iotde ctguiot iiocreases the amtguiot tf syiochrtiotgus I/SO
ctioteiottio tio the shared qgutrgum disk de ice.
7. What is the minimum size of the Quorum Disk?
The miioimgum sise tf the bltck de ice is 10 MBeiabytes.

8. What is the order in which you will start the Red Hat Cluster services?
In Red Hat 4 :
# ser ice ccsd start
# ser ice cmaio start
# ser ice feioced start
ser ice cl md start (If CLVMB has beeio gused tt create clgustered tlgumes).

Ratnakar Page 258


[Pick the date] [LINUX NOTES FOR LEVEL 2]

# ser ice ifs start


# ser ice rimaioaier start
In RedHat 5 :
# ser ice cmaio start
# ser ice cl md start
# ser ice ifs start
# ser ice rimaioaier start
In Red Hat 6 :
# ser ice cmaio start
# ser ice cl md start
# ser ice ifs2 start
# ser ice rimaioaier start
9. What is the order to stop the Red Hat Cluster services?
In Red Hat 4 :
# ser ice rimaioaier sttp
# ser ice ifs sttp
# ser ice cl md sttp
# ser ice feioced sttp
# ser ice cmaiosttp
# ser ice ccsd sttp
In Red Hat 5 :
# ser ice rimaioaier sttp
# ser iceifssttp
# ser ice cl md sttp
# ser icecmaio sttp
In Red Hat 6 :
# ser ice rimaioaiersttp
# ser ice ifs2 sttp
# ser ice cl mdsttp
# ser ice cmaio sttp
10. What are the performance enhancements in GFS2 as compared to GFS?
 etter perftrmaioce ftr hea y gusaie iio a siioile directtry
 Faster syiochrtiotgus I/SO tperattios
 Faster cached reads (iot ltckiioi t erhead).
 Faster direct I/SO with prealltcated fles (prt ided I/SO sise is reastioably larie sguch as 4MB
bltcks).
 Faster I/SO tperattios iio ieioeral
 Faster Execguttio tf the df ctmmaiod becaguse tf faster stats calls
 Imprt ed atme mtde tt redguce the iogumber tf write I/SO tperattios ieioerated by atme
wheio ctmpared with GFS

Ratnakar Page 259


[Pick the date] [LINUX NOTES FOR LEVEL 2]

 GFS2 sgupptrts the ftlltwiioi featgures.


 exteioded fle attribgutes (xattr).
 the lsattr(). aiod chattr(). attribgute setiois ia staiodard itctl(). calls
 ioaiotsectiod tmestamps
 GFS2 guses less kerioel memtry.
 GFS2 reqguires iot metadata ieioerattio iogumbers.
 Alltcatioi GFS2 metadata dtes iott reqguire reads. Ctpies tf metadata bltcks iio mgultple
jtgurioals are maioaied by re tkiioi bltcks frtm the jtgurioal beftre ltck release.
 GFS2 iioclgudes a mguch simpler lti maioaier that kiotws iotthiioi abtgut guioliioked iiotdes tr
qgutta chaioies.
 The ifs2_irtw aiod ifs2_jadd ctmmaiods guse ltckiioi tt pre eiot mgultple iiostaioces rguioioiioi
at the same tme.
 The ACL ctde has beeio simplifed ftr calls like creat(). aiod mkdir()..
 Uioliioked iiotdes qgutta chaioies aiod stats chaioies are rect ered withtgut remtguiotioi the
jtgurioal.
11. What is the maximum file system support size for GFS2?
 GFS2 is based tio 64 bit architectgure which caio thetretcally acctmmtdate aio 8 E fle
system.
 Htwe er the cgurreiot sgupptrted maximgum sise tf a GFS2 fle system ftr 64-bit hardware is
100 T .
 The cgurreiot sgupptrted maximgum sise tf a GFS2 fle system ftr 32-bit hardware ftr Red Hat
Eioterprise Liiogux Release 5.3 aiod later is 16 T .
NOTE: It is better tt ha e 10 1T fle systems thaio tioe 10T fle system.
12. What is the journaling filesystem?
 A jtgurioaliioi flesystem is a flesystem that maiiotaiios a special fle called a jtgurioal that is
gused tt repair aioy iioctiosisteiocies that tccgur as the resgult tf aio imprtper shgutdtwio tf a
ctmpguter.
 Iio jtgurioaliioi fle systems e ery tme GFS2 writes metadata the metadata is ctmmitted tt
the jtgurioal beftre it is pgut iiott place.
 This eiosgures that if the system crashes tr ltses ptwer ytgu will rect er all tf the metadata
wheio the jtgurioal is aguttmatcally replayed at mtguiot tme.
 GFS2 reqguires tioe jtgurioal ftr each iotde iio the clguster that ioeeds tt mtguiot the fle system.
Ftr example if ytgu ha e a 16-iotde clguster bgut ioeed tt mtguiot tioly the fle system frtm
twt iotdes ytgu ioeed tioly twt jtgurioals. If ytgu ioeed tt mtguiot frtm a third iotde ytgu caio
always add a jtgurioal with the ifs2_jadd ctmmaiod.
13. What is the default size of journals in GFS?
Wheio ytgu rguio mkfs.ifs2 withtgut the sise attribgute ftr jtgurioal tt create a GFS2 partttio by
defagult a 128MB sisejtgurioal is created which is eiotguih ftr mtst tf the applicattios
Iio case ytgu plaio tio redguciioi the sise tf the jtgurioal it caio se erely afeect the
perftrmaioce. Sgupptse ytgu redguce the sise tf the jtgurioal tt 32MB it dtes iott take mguch fle

Ratnakar Page 260


[Pick the date] [LINUX NOTES FOR LEVEL 2]

system act ity tt fll aio 32MB jtgurioal aiod wheio the jtgurioal is fgull perftrmaioce sltws becaguse
GFS2 has tt wait ftr writes tt the sttraie.
14. What is a Quorum Disk?
 Qgutrgum Disk is a disk-based qgutrgum daemtio qdiskd that prt ides sgupplemeiotal heguristcs
tt determiioe iotde ftioess.
 With heguristcs ytgu caio determiioe facttrs that are imptrtaiot tt the tperattio tf the iotde iio
the e eiot tf a ioetwtrk partttio
Ftr a 3 iotde clguster a qgutrgum state is preseiot guiotl 2 tf the 3 iotdes are act e i.e. mtre thaio
half. gut what if dgue tt stme reastios the 2iod iotde alst sttps ctmmguioicatioi with the 3rd
iotde? Iio that case guioder a iotrmal architectgure the clguster wtguld disstl e aiod sttp wtrkiioi.
gut ftr missitio critcal eio irtiomeiots aiod sguch sceioarits we guse qgutrgum disk iio which aio addittioal
disk is ctiofigured which is mtguioted tio all the iotdes with qdiskd ser ice rguioioiioi aiod a tte
algue is assiiioed tt it.
St sgupptse iio abt e case I ha e assiiioed 1 tte tt qdisk st e eio afer 2 iotdes sttps
ctmmguioicatioi with 3rd iotde the clguster wtguld ha e 2 ttes (1 qdisk + 1 frtm 3rd iotde).
which is stll mtre thaio half tf tte ctguiot ftr a 3 iotde clguster. Ntw btth the iioact e iotdes wtguld
be feioced aiod ytgur 3rd iotde wtguld be stll gup aiod rguioioiioi beiioi a part tf the clguster.
15. What is rgmanager in Red Hat Cluster and its use?
 This is a ser ice termed as Restgurce Grtgup MBaioaier
 RGMBaioaier maioaies aiod prt ides failt er capabilites ftr ctllecttios tf clguster restgurces
called ser ices restgurce irtgups tr restgurce trees
 it alltws admiioistrattrs tt defioe ctiofigure aiod mtioittr clguster ser ices. Iio the e eiot tf a
iotde failgure rimaioaier will reltcate the clgustered ser ice tt aiotther iotde with miioimal
ser ice disrgupttio.
16. What is luci and ricci in Red Hat Cluster?
 luci is the ser er ctmptioeiot tf the Ctioia admiioistrattio gutlity
 Ctioia is aio iioteirated set tf stfware ctmptioeiots that prt ides ceiotralised ctiofigurattio
aiod maioaiemeiot tf Red Hat clgusters aiod sttraie
 lguci is a ser er that rguios tio tioe ctmpguter aiod ctmmguioicates with mgultple clgusters aiod
ctmpguters ia ricci

 ricci is the clieiot ctmptioeiot tf the Ctioia admiioistrattio gutlity
 ricci is aio aieiot that rguios tio each ctmpguter (either a clguster member tr a staiodaltioe
ctmpguter). maioaied by Ctioia
 This ser ice ioeeds tt be rguioioiioi tio all the clieiot iotdes tf the clguster.
17. What is cman in Red Hat Cluster?
 This is aio abbre iattio gused ftr Clguster MBaioaier.
 CMBAN is a distribguted clguster maioaier aiod rguios iio each clguster iotde.
 It is resptiosible ftr mtioittriioi heartbeat qgutrgum ttioi aiod ctmmguioicattio betweeio
clguster iotdes.

Ratnakar Page 261


[Pick the date] [LINUX NOTES FOR LEVEL 2]

 CMBAN keeps track tf clguster qgutrgum by mtioittriioi the ctguiot tf clguster iotdes.
18. What are the diferent port no. used in Red Hat Cluster?
IP Port no. Protocol Component
5404,5405 UDP ctrtsyioc/Scmaio
11111 TCP ricci
21064 TCP dlm (Distribguted Ltck MBaioaier).
16851 TCP MBtdclgustered
8084 TCP lguci
4196,4197 TCP rimaioaier

19. How does NetworkManager service afects Red Hat Cluster?


 The guse tf NetwtrkMBaioaier is iott sgupptrted tio clguster iotdes. If ytgu ha e iiostalled
NetwtrkMBaioaier tio ytgur clguster iotdes ytgu shtguld either remt e it tr disable it.
# ser ice NetwtrkMBaioaier sttp
# chkctiofi NetwtrkMBaioaier tfe
 The cmaio ser ice will iott start if NetwtrkMBaioaier is either rguioioiioi tr has beeio ctiofigured
tt rguio with the chkctiofi ctmmaiod
20. What is the command used to relocate a service to another node?
# clgus cadm -r ser ice_ioame -m iotde_ioame
21. What is split-brain condition in Red Hat Cluster?
 We say a clguster has qgutrgum if a majtrity tf iotdes are ali e ctmmguioicatioi aiod airee tio
the act e clguster members. Ftr example iio a thirteeio-iotde clguster qgutrgum is tioly
reached if se eio tr mtre iotdes are ctmmguioicatioi. If the se eioth iotde dies the clguster
ltses qgutrgum aiod caio iot ltioier fguiocttio.
 A clguster mgust maiiotaiio qgutrgum tt pre eiot split-braiio issgues.
 If qgutrgum was iott eioftrced qgutrgum a ctmmguioicattio errtr tio that same thirteeio-iotde
clguster may caguse a sitguattio where six iotdes are tperatioi tio the shared sttraie while
aiotther six iotdes are alst tperatioi tio it iiodepeiodeiotly. ecaguse tf the ctmmguioicattio
errtr the twt partal-clgusters wtguld t erwrite areas tf the disk aiod ctrrgupt the fle
system.
 With qgutrgum rgules eioftrced tioly tioe tf the partal clgusters caio guse the shared sttraie
thgus prttectioi data iioteirity.
 Qgutrgum dtesio't pre eiot split-braiio sitguattios bgut it dtes decide wht is dtmiioaiot aiod
alltwed tt fguiocttio iio the clguster.
 qgutrgum caio be determiioed by a ctmbiioattio tf ctmmguioicatioi messaies ia Etherioet aiod
thrtguih a qgutrgum disk.
22. What are Tie-breakers in Red Hat Cluster?
 Tie-breakers are addittioal heguristcs that alltw a clguster partttio tt decide whether tr iott
it is qgutrate iio the e eiot tf aio e eio-split - pritr tt feiociioi.
 With sguch a te-breaker iotdes iott tioly mtioittr each tther bgut alst aio gupstream rtguter
that is tio the same path as clguster ctmmguioicattios. If the twt iotdes ltse ctiotact with

Ratnakar Page 262


[Pick the date] [LINUX NOTES FOR LEVEL 2]

each tther the tioe that wiios is the tioe that caio stll piioi the gupstream rtguter.That is why
e eio wheio gusiioi te-breakers it is imptrtaiot tt eiosgure that feiociioi is ctiofigured ctrrectly.
 CMBAN has iot iioterioal te-breakers ftr aritgus reastios. Htwe er te-breakers caio be
implemeioted gusiioi the API.
23. What is fencing in Red Hat Cluster?
 Feiociioi is the disctioioecttio tf a iotde frtm the clguster's shared sttraie.
 Feiociioi cguts tfe I/SO frtm shared sttraie thgus eiosguriioi data iioteirity.
 The clguster iiofrastrguctgure perftrms feiociioi thrtguih the feioce daemtio fenced.
 Wheio CMBAN determiioes that a iotde has failed it ctmmguioicates tt tther clguster-
iiofrastrguctgure ctmptioeiots that the iotde has failed.
 fenced wheio iottfed tf the failgure feioces the failed iotde.
24. What are the various types of fencing supported by High Availability Add On?
Power fencing — A feiociioi methtd that guses a ptwer ctiotrtller tt ptwer tfe aio iiotperable
iotde.
storage fencing — A feiociioi methtd that disables the Fibre Chaioioel ptrt that ctioioects sttraie
tt aio iiotperable iotde.
Other fencing — Se eral tther feiociioi methtds that disable I/SO tr ptwer tf aio iiotperable
iotde iioclgudiioi I MB ladeceioters PAP DRAC/SMBC HP ILO IPMBI I MB RSA II aiod tthers.
25. What are the lock states in Red Hat Cluster?
A ltck state iiodicates the cgurreiot statgus tf a ltck reqguest. A ltck is always iio tioe tf three states:
Granted — The ltck reqguest sgucceeded aiod attaiioed the reqguested mtde.
Converting — A clieiot attempted tt chaioie the ltck mtde aiod the ioew mtde is iioctmpatble
with aio existioi ltck.
Blocked — The reqguest ftr a ioew ltck ctguld iott be iraioted becaguse ctiofictioi ltcks exist.
A ltck's state is determiioed by its reqguested mtde aiod the mtdes tf the tther ltcks tio the
same restgurce.
26. What is DLM lock model?
 DLMB is a shtrt abbre iattio ftr Distribguted Ltck MBaioaier.
 A ltck maioaier is a trafc ctp wht ctiotrtls access tt restgurces iio the clguster sguch as access
tt a GFS fle system.
 GFS2 guses ltcks frtm the ltck maioaier tt syiochrtioise access tt fle system metadata (tio
shared sttraie).
 CLVMB guses ltcks frtm the ltck maioaier tt syiochrtioise gupdates tt LVMB tlgumes aiod tlgume
irtgups (alst tio shared sttraie).
 Iio addittio rimaioaier guses DLMB tt syiochrtioise ser ice states.
 withtgut a ltck maioaier there wtguld be iot ctiotrtl t er access tt ytgur shared sttraie aiod
the iotdes iio the clguster wtguld ctrrgupt each tther's data.

Ratnakar Page 263


[Pick the date] [LINUX NOTES FOR LEVEL 2]

31. Examples of top command

ttp is tioe tf the tttl ftr mtioittriioi system gusaie aiod alst tt make aioy chaioie ftr imprt iioi
system perftrmaioce.
Introduction:
The ttp prtiram prt ides a dyioamic real-tme iew tf a rguioioiioi system. It caio display system
sgummary iioftrmattio as well as a list tf tasks cgurreiotly beiioi maioaied by the Liiogux kerioel. The
types tf system sgummary iioftrmattio shtwio aiod the types trder aiod sise tf iioftrmattio displayed
ftr tasks are all guser ctiofigurable aiod that ctiofigurattio caio be made persisteiot acrtss restarts.
1. Without any arguments :

# ttp
ttp - 17:51:07 gup 1 day 2:56 27 gusers ltad a eraie: 5.33 29.71 28.33

Ratnakar Page 264


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Tasks: 1470 tttal 1 rguioioiioi 1469 sleepiioi 0 sttpped 0 stmbie


Cpgu(s).: 0.0%gus 0.1%sy 0.0%ioi 99.9%id 0.0%wa 0.0%hi 0.0%si 0.0%st
MBem: 264114424k tttal 253006956k gused 11107468k free 66964k bgufeers
Swap: 33554424k tttal 3260k gused 33551164k free 245826024k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND


1960 deepak 15 0 30452 3220 1540 R 2.3 0.0 0:00.78 ttp
2457 rttt 11 -5 0 0 0 S 2.3 0.0 11:36.93 kacpid
2493 pmartprd 16 0 1397m 289m 9.8m S 0.3 0.1 18:36.07 pmrepaieiot
4639 pmartprd 15 0 787m 54m 4080 S 0.3 0.0 5:19.55 pmser er
14402 rttt RT 0 151m 5256 2872 S 0.3 0.0 1:41.40 mgultpathd
17886 rttt 10 -5 0 0 0 S 0.3 0.0 0:07.41 ktiodemaiod/S11
Geioerally we guse ttp withtgut aioy arigumeiots bgut the maiic is mtstly dtioe frtm the ttp
ctmmaiod liioe which mgust tf gus skip. Well beftre takiioi ytgu tt that part let me explaiio ytgu the
aritgus system related featgures which are shtwio by ttp ctmmaiod.

NOTE: Ytgu caio eioable tr disable the marked blgue liioe by pressiioi "l" tioce ttp is rguioioiioi.

top - 17:51:07 up 1 day, 2:56, 27 users, load average: 5.33, 29.71, 28.33
Tasks: 1470 tttal 1 rguioioiioi 1469 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.0%gus 0.1%sy 0.0%ioi 99.9%id 0.0%wa 0.0%hi 0.0%si 0.0%st
MBem: 264114424k tttal 253006956k gused 11107468k free 66964k bgufeers
Swap: 33554424k tttal 3260k gused 33551164k free 245826024k cached

Explanation: This liioe tells ytgu abtgut the guptme tf ytgur system altioi with ltad a eraie algue.
NOTE: Ytgu caio eioable/Sdisable the marked blgue liioe by pressiioi "t".

ttp - 17:51:07 gup 1 day 2:56 27 gusers ltad a eraie: 5.33 29.71 28.33
Tasks: 1470 total, 1 running, 1469 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 0.1%sy, 0.0%ni, 99.9%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
MBem: 264114424k tttal 253006956k gused 11107468k free 66964k bgufeers
Swap: 33554424k tttal 3260k gused 33551164k free 245826024k cached

Explanation: This liioe ii es gus a brief detail tf all the tasks rguioioiioi/Ssleepiioi/Ssttpped cgurreiotly
iio the system altioi with the CPU Usaie

Value Meaning
us guser cpgu tme (tr). % CPU tme speiot iio guser space
sy system cpgu tme (tr). % CPU tme speiot iio kerioel space
ni guser ioice cpgu tme (tr). % CPU tme speiot tio ltw pritrity prtcesses
id idle cpgu tme (tr). % CPU tme speiot idle
wa it wait cpgu tme (tr). % CPU tme speiot iio wait (tio disk).
hi hardware irq (tr). % CPU tme speiot ser iciioi/Shaiodliioi hardware iioterrgupts

Ratnakar Page 265


[Pick the date] [LINUX NOTES FOR LEVEL 2]

si stfware irq (tr). % CPU tme speiot ser iciioi/Shaiodliioi stfware iioterrgupts
steal tme - - % CPU tme iio iio tlguiotary wait by irtgual cpgu while hyper istr is ser iciioi
st
aiotther prtcesstr (tr). % CPU tme sttleio frtm a irtgual machiioe

NOTE: Ytgu caio eioable/Sdisable the marked blgue liioe by pressiioi "m".

ttp - 17:51:07 gup 1 day 2:56 27 gusers ltad a eraie: 5.33 29.71 28.33
Tasks: 1470 tttal 1 rguioioiioi 1469 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.0%gus 0.1%sy 0.0%ioi 99.9%id 0.0%wa 0.0%hi 0.0%si 0.0%st
Mem: 264114424k total, 253006956k used, 11107468k free, 66964k bufers
Swap: 33554424k total, 3260k used, 33551164k free, 245826024k cached

Explanation: The ioext liioe shtws ytgur memtry(RAMB aiod swap). gusaie aiod capacity.
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
13916 stmprd 18 0 903m 129m 9936 S 51.4 0.1 3:07.01 ja a
13921 stmprd 18 0 901m 128m 9936 S 49.8 0.0 3:02.92 ja a
13825 stmprd 18 0 951m 190m 9932 S 49.5 0.1 3:07.13 ja a
13856 stmprd 20 0 978m 197m 9936 S 49.2 0.1 3:05.89 ja a
13853 stmprd 18 0 921m 150m 9932 S 48.5 0.1 3:09.14 ja a
13875 stmprd 18 0 907m 132m 9940 S 48.5 0.1 3:09.49 ja a
13937 stmprd 25 0 926m 165m 9936 S 48.2 0.1 3:10.31 ja a
13919 stmprd 18 0 917m 153m 9936 S 47.5 0.1 3:05.92 ja a
13879 stmprd 25 0 921m 160m 9936 S 47.2 0.1 3:08.43 ja a
13908 stmprd 25 0 901m 131m 9932 S 47.2 0.1 3:12.23 ja a
13905 stmprd 25 0 907m 137m 9932 S 46.6 0.1 2:59.85 ja a
The lef secttios shtws ytgu the details tf the prtcess rguioioiioi altioi with the beltw details.
Fields/Column Description
PID Prtcess Id
USER The efeect e guser ioame tf the task's twioer
PR The pritrity tf the task
The ioice algue tf the task. A ioeiat e ioice algue meaios hiiher pritrity whereas a
NI ptsit e ioice algue meaios ltwer pritrity. Zert iio this feld simply meaios pritrity will
iott be adjgusted iio determiioiioi a task's dispatchability
The task's share tf the elapsed CPU tme siioce the last screeio gupdate expressed as a
%CPU
perceiotaie tf tttal CPU tme.
%MEM A task's cgurreiotly gused share tf a ailable physical memtry
TIME+ Tttal CPU tme the task has gused siioce it started
The statgus tf the task which caio be tioe tf:
'D' = guioiioterrguptble sleep
S
'R' = rguioioiioi
'S' = sleepiioi

Ratnakar Page 266


[Pick the date] [LINUX NOTES FOR LEVEL 2]

'T' = traced tr sttpped


'Z' = stmbie
RES The iotio-swapped physical memtry a task has gused
SHR The amtguiot tf shared memtry gused by a task
Command Display the ctmmaiod liioe gused tt start a task tr the ioame tf the asstciated prtiram

2. Arrange Tasks with High to Low CPU Usage :

Press "P" tr "shif+p" tioce ttp is rguioioiioi tt arraioie all the tasks with High to Low CPU
Usage as shtwio beltw.
ttp - 18:03:00 gup 1 day 3:08 27 gusers ltad a eraie: 12.54 32.34 32.75
Tasks: 1485 tttal 3 rguioioiioi 1482 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 41.2%gus 0.8%sy 0.0%ioi 56.6%id 1.4%wa 0.0%hi 0.0%si 0.0%st
MBem: 264114424k tttal 258863028k gused 5251396k free 76308k bgufeers
Swap: 33554424k tttal 3256k gused 33551168k free 250950544k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
9663 stmprd 22 0 902m 301m 9888 S 2578.3 0.1 2:27.04 ja a
32117 etlprd 18 -1 32416 5908 1716 R 6.2 0.0 0:04.84
cleaiogup_dirfle
10053 rttt 18 -1 27100 1936 1460 S 4.9 0.0 0:00.15 ps
5456 pmartprd 16 0 1182m 130m 8560 S 3.9 0.1 38:39.72
pmser er
17492 deepak 16 0 30592 3388 1544 R 3.6 0.0 0:17.11 ttp
2843 pmartprd 15 0 730m 48m 4052 S 3.3 0.0 4:40.33
pmser er
2457 rttt 11 -5 0 0 0 S 2.9 0.0 11:42.39
kacpid
3731 tdmsprd 15 0 370m 49m 32m S 2.3 0.0 0:00.64
pmdtm.trii
3. Arrange Tasks with High to Low Memory Usage.

Press "M" tr "shif+m"tioce ttp is rguioioiioi tt arraioie all the tasks with High to Low Memory
Usage as shtwio beltw.

ttp - 18:04:26 gup 1 day 3:09 27 gusers ltad a eraie: 37.12 34.56 33.44
Tasks: 1676 tttal 1 rguioioiioi 1675 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 2.3%gus 76.7%sy 0.0%ioi 19.7%id 1.3%wa 0.0%hi 0.0%si 0.0%st
MBem: 264114424k tttal 262605184k gused 1509240k free 77924k bgufeers
Swap: 33554424k tttal 3256k gused 33551168k free 252198368k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND

Ratnakar Page 267


[Pick the date] [LINUX NOTES FOR LEVEL 2]

1852 pmartprd 18 0 2005m 319m 4776 S 6.9 4.1 28:34.32


ja a
2493 pmartprd 16 0 1397m 289m 9.8m S 0.0 4.0 18:37.79
pmrepaieiot
20557 etlprd 15 0 911m 201m 3024 S 0.0 3.0 17:09.02
pmdtm.trii
18778 rttt RT 0 286m 188m 156m S 0.0 2.1 13:24.98
aisexec
5456 pmartprd 15 0 1182m 130m 8560 S 6.2 1.1 38:40.58
pmser er
16004 etlprd 14 -1 179m 83m 2636 S 0.0 0.1 9:41.36 db2bp
11272 stmprd 25 0 906m 67m 9736 S 99.7 0.0 0:48.11 ja a
4. Change the nice value (priority) of any task

Tt guioderstaiod what is ioice algue ftlltw the beltw liiok


What is nice and how to change the priority of any process in Linux?
Press "r" wheio ttp is rguioioiioi tio the termiioal. Ytgu shtguld iet a prtmpt as shtwio beltw
iio blgue ctltr.

ttp - 18:08:38 gup 115 days 8:44 4 gusers ltad a eraie: 0.03 0.03 0.00
Tasks: 325 tttal 2 rguioioiioi 323 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.1%gus 6.4%sy 0.0%ioi 93.3%id 0.3%wa 0.0%hi 0.0%si 0.0%st
MBem: 49432728k tttal 2063848k gused 47368880k free 310072k bgufeers
Swap: 2097144k tttal 0k gused 2097144k free 1297572k cached
PID to renice: 1308 [Hit Eioter]
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
5359 rttt 39 19 0 0 0 R 100.1 0.0 94:31:35
kipmi0
1308 deepak 16 0 29492 2292 1512 S 0.7 0.0 0:00.33 ttp
6116 rttt 15 0 369m 30m 11m S 0.7 0.1 77:24.97 cimser er

Gi e the PID whtse ioice algue has tt be chaioied aiod hit "Eioter". Theio ii e the nice value ftr
the PID
ttp - 18:08:38 gup 115 days 8:44 4 gusers ltad a eraie: 0.03 0.03 0.00
Tasks: 325 tttal 2 rguioioiioi 323 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.1%gus 6.4%sy 0.0%ioi 93.3%id 0.3%wa 0.0%hi 0.0%si 0.0%st
MBem: 49432728k tttal 2063848k gused 47368880k free 310072k bgufeers
Swap: 2097144k tttal 0k gused 2097144k free 1297572k cached
Renice PID 1308 to value: -1 [Hit Eioter]
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND

Ratnakar Page 268


[Pick the date] [LINUX NOTES FOR LEVEL 2]

5359 rttt 39 19 0 0 0 R 100.1 0.0 9431:35


kipmi0
1308 deepak 16 0 29492 2292 1512 S 0.7 0.0 0:00.33 ttp
6116 rttt 15 0 369m 30m 11m S 0.7 0.1 77:24.97 cimser er

Verify the changes :


ttp - 18:09:06 gup 115 days 8:45 4 gusers ltad a eraie: 0.13 0.06 0.01
Tasks: 325 tttal 1 rguioioiioi 324 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.0%gus 0.1%sy 0.0%ioi 99.8%id 0.1%wa 0.0%hi 0.0%si 0.0%st
MBem: 49432728k tttal 2063276k gused 47369452k free 310072k bgufeers
Swap: 2097144k tttal 0k gused 2097144k free 1297588k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
1308 deepak 15 -1 29492 2292 1512 S 0.7 0.0 0:00.42 ttp
5359 rttt 34 19 0 0 0 S 0.7 0.0 9431:42
kipmi0
1 rttt 15 0 10352 692 580 S 0.0 0.0 0:02.16 iioit
2 rttt RT -5 0 0 0 S 0.0 0.0 0:02.37
miirattio/S0
3 rttt 34 19 0 0 0 S 0.0 0.0 0:00.00 kstfirqd/S

5. Kill any task

Press "k" tio the termiioal wheio ttp is rguioioiioi. Ytgu shtguld iet a prtmpt as shtwio beltw
iio blgue ctltr
ttp - 18:09:31 gup 115 days 8:45 4 gusers ltad a eraie: 0.08 0.05 0.01
Tasks: 325 tttal 1 rguioioiioi 324 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.1%gus 0.1%sy 0.0%ioi 99.8%id 0.1%wa 0.0%hi 0.0%si 0.0%st
MBem: 49432728k tttal 2062036k gused 47370692k free 310072k bgufeers
Swap: 2097144k tttal 0k gused 2097144k free 1297596k cached
PID tt kill:1308
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
5359 rttt 34 19 0 0 0 S 1.3 0.0 9431:42
kipmi0
6460 rttt 24 0 179m 30m 3976 S 1.0 0.1 79:04.77
ja a
1308 deepak 15 -1 29492 2292 1512 S 0.7 0.0 0:00.49
ttp
1434 rttt 15 0 29492 2288 1516 R 0.7 0.0 0:00.13
ttp

Ratnakar Page 269


[Pick the date] [LINUX NOTES FOR LEVEL 2]

ttp - 18:09:31 gup 115 days 8:45 4 gusers ltad a eraie: 0.08 0.05 0.01
Tasks: 325 tttal 1 rguioioiioi 324 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.1%gus 0.1%sy 0.0%ioi 99.8%id 0.1%wa 0.0%hi 0.0%si 0.0%st
MBem: 49432728k tttal 2062036k gused 47370692k free 310072k bgufeers
Swap: 2097144k tttal 0k gused 2097144k free 1297596k cached
Kill PID 1308 with siiioal [15]: [Hit Eioter ftr defagult]
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
5359 rttt 34 19 0 0 0 S 1.3 0.0 9431:42
kipmi0
6460 rttt 24 0 179m 30m 3976 S 1.0 0.1 79:04.77
ja a
1308 deepak 15 -1 29492 2292 1512 S 0.7 0.0 0:00.49
ttp
6. View all the processes running by a user

Press "u" tio the termiioal wheio ttp is rguioioiioi. Ytgu shtguld iet a prtmpt as shtwio beltw
iio blgue ctltr
ttp - 18:12:24 gup 115 days 8:48 4 gusers ltad a eraie: 0.06 0.05 0.00
Tasks: 328 tttal 1 rguioioiioi 327 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.0%gus 0.4%sy 0.0%ioi 99.6%id 0.0%wa 0.0%hi 0.0%si 0.0%st
MBem: 49432728k tttal 2063268k gused 47369460k free 310072k bgufeers
Swap: 2097144k tttal 0k gused 2097144k free 1297660k cached
Which guser (blaiok ftr all).: deepak [Hit Eioter]
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
1729 rttt 15 0 29488 2196 1432 R 2.0 0.0 0:00.01
ttp
1 rttt 15 0 10352 692 580 S 0.0 0.0 0:02.16
iioit
2 rttt RT -5 0 0 0 S 0.0 0.0 0:02.37
miirattio/S0
3 rttt 34 19 0 0 0 S 0.0 0.0 0:00.00
kstfirqd/S0
4 rttt RT -5 0 0 0 S 0.0 0.0 0:00.00
watchdti/S0

ttp - 18:12:41 gup 115 days 8:48 4 gusers ltad a eraie: 0.04 0.05 0.00
Tasks: 328 tttal 1 rguioioiioi 327 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.0%gus 0.1%sy 0.0%ioi 99.9%id 0.0%wa 0.0%hi 0.0%si 0.0%st
MBem: 49432728k tttal 2062356k gused 47370372k free 310072k bgufeers

Ratnakar Page 270


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Swap: 2097144k tttal 0k gused 2097144k free 1297672k cached


PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
1561 deepak 17 0 3984 780 468 S 0.0 0.0 0:00.00
maio
1564 deepak 19 0 8704 964 816 S 0.0 0.0 0:00.00
sh
1566 deepak 23 0 8704 464 316 S 0.0 0.0 0:00.00
sh
1571 deepak 16 0 8452 892 712 S 0.0 0.0 0:00.01
less
31328 deepak 15 0 110m 2348 1264 S 0.0 0.0 0:00.20
sshd
31329 deepak 16 0 27676 2564 1816 S 0.0 0.0 0:00.02
bash
31422 deepak 15 0 109m 2360 1260 S 0.0 0.0 0:00.14
sshd
31423 deepak 15 0 27548 2500 1784 S 0.0 0.0 0:00.02
bash
7. Change delay between terminal refresh

y defagult the ttp termiioal is set ftr agutt refresh afer e ery 3 seconds bgut if ytgu waiot ytgu caio
chaioie it as per ytgur reqguiremeiot.
Press "d" wheio ttp is rguioioiioi. Ytgu shtguld iet a prtmpt as shtwio beltw iio blgue ctltr.
ttp - 18:14:55 gup 115 days 8:50 4 gusers ltad a eraie: 0.01 0.04 0.00
Tasks: 328 tttal 1 rguioioiioi 327 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.0%gus 0.1%sy 0.0%ioi 99.9%id 0.0%wa 0.0%hi 0.0%si 0.0%st
MBem: 49432728k tttal 2063828k gused 47368900k free 310072k bgufeers
Swap: 2097144k tttal 0k gused 2097144k free 1297728k cached
Chaioie delay frtm 3.0 tt: 2.0 [Hit Eioter]
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
5359 rttt 34 19 0 0 0 S 0.7 0.0 9431:58
kipmi0
1795 rttt 15 0 29492 2300 1524 R 0.3 0.0 0:00.20
ttp
1 rttt 15 0 10352 692 580 S 0.0 0.0 0:02.16
iioit
Verify the chaioies. Ytgu mgust see the screeio bgufeer ietioi refresh mguch earlier tr jgust tt erify
ytgu caio prt ide a hiiher algue tf delay aiod tbser er the refresh rate tio the termiioal

Ratnakar Page 271


[Pick the date] [LINUX NOTES FOR LEVEL 2]

8. No. of task to be displayed

y defagult this tpttio is set tt guiolimited that is the reastio ytgur termiioal is fgully ct ered with list
tf tasks wheio ytgu rguio the ttp ctmmaiod. Aioy htw ytgu caio list the iot tf tasks tt be isible tioce
ytgu rguio ttp ctmmaiod.
Press "n"wheio ttp is rguioioiioi. Ytgu shtguld iet a prtmpt as shtwio beltw iio blgue ctltr
ttp - 18:18:07 gup 115 days 8:54 4 gusers ltad a eraie: 0.01 0.03 0.00
Tasks: 328 tttal 1 rguioioiioi 327 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.0%gus 0.2%sy 0.0%ioi 99.7%id 0.1%wa 0.0%hi 0.0%si 0.0%st
MBem: 49432728k tttal 2063348k gused 47369380k free 310072k bgufeers
Swap: 2097144k tttal 0k gused 2097144k free 1297804k cached
MBaximgum tasks = 0 chaioie tt (0 is unlimited).: 2 [Hit Eioter]
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
5359 rttt 34 19 0 0 0 S 2.3 0.0 9432:08
kipmi0
1795 rttt 15 0 29492 2304 1528 R 0.7 0.0 0:00.65
ttp
1 rttt 15 0 10352 692 580 S 0.0 0.0 0:02.16
iioit
2 rttt RT -5 0 0 0 S 0.0 0.0 0:02.37
miirattio/S0

ttp - 14:48:40 gup 116 days 5:24 3 gusers ltad a eraie: 0.05 0.04 0.00
Tasks: 318 tttal 1 rguioioiioi 317 sleepiioi 0 sttpped 0 stmbie
Cpgu(s).: 0.0%gus 0.1%sy 0.0%ioi 99.9%id 0.0%wa 0.0%hi 0.0%si 0.0%st
MBem: 49432728k tttal 2051952k gused 47380776k free 310176k bgufeers
Swap: 2097144k tttal 0k gused 2097144k free 1293800k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
5359 rttt 34 19 0 0 0 S 1.0 0.0 9502:15
kipmi0
25009 prasadee 15 0 29492 2280 1516 R 0.3 0.0 0:01.88
ttp

9. View live individual CPU processor performance :


y defagult ttp ctmmaiod shtws ytgu the a eraie tf all the a ailable CPUs iio the machiioe.
Iio case ytgu waiot tt see reptrt tf all the iiodi idgual CPUs press "1" tioce ytgu are rguioioiioi ttp
ctmmaiod aiod ytgu will iet tt see stmethiioi like beltw
ttp - 00:00:58 gup 215 days 13:36 5 gusers ltad a eraie: 4.07 4.04 4.00
Tasks: 339 tttal 5 rguioioiioi 334 sleepiioi 0 sttpped 0 stmbie

Ratnakar Page 272


[Pick the date] [LINUX NOTES FOR LEVEL 2]

Cpgu0 : 0.0%gus 0.2%sy 0.0%ioi 99.8%id 0.0%wa 0.0%hi 0.0%si 0.0%st


Cpgu1 : 0.0%gus 0.4%sy 0.0%ioi 99.6%id 0.0%wa 0.0%hi 0.0%si 0.0%st
Cpgu2 : 0.0%gus 0.1%sy 0.0%ioi 99.5%id 0.4%wa 0.0%hi 0.0%si 0.0%st
Cpgu3 : 0.1%gus 0.2%sy 0.0%ioi 99.8%id 0.0%wa 0.0%hi 0.0%si 0.0%st
Cpgu4 : 0.5%gus 0.1%sy 0.0%ioi 99.4%id 0.0%wa 0.0%hi 0.0%si 0.0%st
Cpgu5 : 0.2%gus 0.4%sy 0.0%ioi 99.4%id 0.0%wa 0.0%hi 0.0%si 0.0%st
Cpgu6 : 0.0%gus 0.5%sy 0.0%ioi 99.5%id 0.0%wa 0.0%hi 0.0%si 0.0%st
Cpgu7 : 0.1%gus 1.4%sy 0.0%ioi 98.5%id 0.0%wa 0.0%hi 0.0%si 0.0%st
MBem: 49432728k tttal 11891852k gused 37540876k free 7996596k bgufeers
Swap: 2097144k tttal 0k gused 2097144k free 1850540k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
23102 rttt 25 0 23724 2024 1168 R 100.1 0.0 64446:36
p s
23338 rttt 25 0 23724 2028 1168 R 100.1 0.0 64444:22
p s
23959 rttt 25 0 23724 2016 1168 R 100.1 0.0
135691:00 p s
28698 rttt 25 0 23724 2024 1168 R 99.3 0.0
128828:38 p s
5359 rttt 34 19 0 0 0 S 0.8 0.0 17610:33
kipmi0
10. Add a new field in top output :

y defagult ytgu see limited set tf tgutpgut wheio ytgu guse the ttp ctmmaiod. gut apart frtm thtse
there are a tther list tf feld which caio be added tt the ttp tgutpgut. Tt iew all the list f feld
which caio be added ftlltw the beltw steps.Rguio ttp ctmmaiod aiod theio
Press "f" which will take ytgu the list tf a ailable felds guioder ttp ctmmaiod.
All the feld iioitals stated iio LOCK letters are isible by defagult wheio ytgu issgue ttp
ctmmaiod. Tt add a ioew feld press the feld iioital as shtwio iio the frst ctlgumio.
* A: PID = Prtcess Id 0x00000001 PF_ALIGNWARN
* E: USER = User Name 0x00000002 PF_STARTING
* H: PR = Pritrity 0x00000004 PF_EXITING
* I: NI = Nice algue 0x00000040 PF_FORKNOEXEC
* O: VIRT = Virtgual Imaie (kb). 0x00000100 PF_SUPERPRIV
* Q: RES = Resideiot sise (kb). 0x00000200 PF_DUMBPCORE
* T: SHR = Shared MBem sise (kb). 0x00000400 PF_SIGNALED
* W: S = Prtcess Statgus 0x00000800 PF_MBEMBALLOC
* K: %CPU = CPU gusaie 0x00002000 PF_FREE_PAGES (2.5).
* N: %MBEMB = MBemtry gusaie (RES). 0x00008000 debgui fai (2.5).

Ratnakar Page 273


[Pick the date] [LINUX NOTES FOR LEVEL 2]

* MB: TIMBE+ = CPU Time hguiodredths 0x00024000 special threads (2.5).


b: PPID = Pareiot Prtcess Pid 0x001D0000 special states (2.5).
c: RUSER = Real guser ioame 0x00100000 PF_USEDFPU (thrgu 2.4).
d: UID = User Id
f: GROUP = Grtgup Name
i: TTY = Ctiotrtlliioi Tty
j: P = Last gused cpgu (SMBP).
* P: SWAP = Swapped sise (kb).
l: TIMBE = CPU Time
r: CODE = Ctde sise (kb).
s: DATA = Data+Stack sise (kb).
gu: ioFLT = Paie Fagult ctguiot
: ioDRT = Dirty Paies ctguiot
y: WCHAN = Sleepiioi iio Fguiocttio
s: Flais = Task Flais <sched.h>
* X: COMBMBAND = Ctmmaiod ioame/Sliioe
Ftr example tt add "swap" feld press "p" (iio small letters).. As sttio as ytgu press "p" it shtguld
tgurio iiott bltck letter iottfyiioi that it has beeio added tt ttp tgutpgut.Oioce dtioe hit eioter aiod it will
take ytgu back tt ttp tgutpgut
Ytgu shtguld see stmethiioi like beltw screeio
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+
COMMAND
20472 prasadee 15 0 30748 2412 1620 R 0.8 0.0 0:00.43 27m ttp
22568 rttt 17 0 296m 5300 3536 S 0.4 0.1
3:00.30 291m e eiotltid
1 rttt 15 0 10348 644 544 S 0.0 0.0 2:28.66 9704 iioit
2 rttt RT -5 0 0 0 S 0.0 0.0 0:38.59
0 miirattio/S0
3 rttt 34 19 0 0 0 S 0.0 0.0 0:00.43
0 kstfirqd/S0
4 rttt RT -5 0 0 0 S 0.0 0.0 0:00.00
0 watchdti/S0
5 rttt RT -5 0 0 0 S 0.0 0.0 0:28.64
0 miirattio/S1
6 rttt 34 19 0 0 0 S 0.0 0.0 0:00.67
0 kstfirqd/S1
7 rttt RT -5 0 0 0 S 0.0 0.0 0:00.00
0 watchdti/S1
8 rttt RT -5 0 0 0 S 0.0 0.0 0:28.00
0 miirattio/S2

Ratnakar Page 274


[Pick the date] [LINUX NOTES FOR LEVEL 2]

9 rttt 34 19 0 0 0 S 0.0 0.0 0:00.73


0 kstfirqd/S2

Ratnakar Page 275

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy