Linux All Commands
Linux All Commands
Page 1
RED-HAT LINUX 6/7
Page 2
RED-HAT LINUX 6/7
What is a user?
In Linux, a user is one who uses the system.
Page 3
RED-HAT LINUX 6/7
privileges
Page 4
RED-HAT LINUX 6/7
10. What is the syntax of the adduser command with full options?
adduser -u <uid> -g <gid> -G <secondary group> -c <comment> -d
<home directory> -s <shell><user name>
Example : # adduser -u 700 -g 700 -G linux -c "oracle user" -d
/home/ram -s /bin/bash ram
Page 5
RED-HAT LINUX 6/7
12. What is the syntax of the userdel command with full options?
# userdel <options><user name>
The options are,
-f -----> forcefully delete the user even if the user is logged in.
home directory, mail and message directories are also deleted.
Recursively means files in the user's home directory will be deleted.
and his home directory was also deleted but the other files belonging to that user
should be deleted manually.
16. What is the syntax of the usermod command with full options?
usermod <options><user name>
The options are, -L -----> lock the password
h unlock the password
creates duplicate user modify the user's
id same as other user
Page 6
RED-HAT LINUX 6/7
modify user id
/ modify group id
modify or add the secondary group
-c -----> modify comment
-d -----> modify home directory
modify user's login shell
modify user's login name
modify the user's home directory and
the old home directory
19. What are the uses of .bash_logout, .bash_profile and .bashrc files?
.bash_logout: is a user's logout ending program file. It will execute first
whenever the user is logged out.
.bash_profile: is the user's login startup program file. It will execute first.
whenever the user is logged in. It consists of the user's environment
variables.
.bashrc: This file is used to create the user's custom commands and to
specify the umask values for that user's only.
21. What is the command to check how many groups the user belongs to?
# groups <user name>
Page 7
RED-HAT LINUX 6/7
27. ﻛﻴﻒ ﻳﻤﻜﻦ ﺍﺳﺘﻌﺎﺩﺓ ﻣﻠﻒ/etc/gshadow ﻋﻦ ﻃﺮﻳﻖ ﺍﻟﺨﻄﺄ؟ ﺣﺬﻓﻪ ﺗﻢ ﺇﺫﺍ
# grpconv (it creates the /etc/gshadow file from /etc/group file)
Page 8
RED-HAT LINUX 6/7
Page 9
RED-HAT LINUX 6/7
So, one editor is specially available for opening this file, i.e., # visudo and all
normal users cannot execute this command. Only root user can run this
command.
Once this file is opened, nobody can open this file again on another terminal.
because the 'The file is busy' message is displayed on the terminal for security
reasons.
Page 10
RED-HAT LINUX 6/7
33. How to assign the password to a normal user by themselves during their first login.
to the system?
Whenever the user is created and that user is trying to log in to the
system, it will ask for the password. If the root user is not assigned the password to
that user, then that normal user can assign the password by his own using the
following commands.
# useradd <user name> (to create the user)
# passwd -S <user name> to see the status of the password of that
user. if root user is not
assigned the password then the
password status is locked
# passwd -d <user name> (then delete the password for that user)
# chage -d 0 <user name> (it will change the password age policy)
# su - <user name> (Try to switch to that user then it will
display the following
message
Page 11
RED-HAT LINUX 6/7
Page 12
RED-HAT LINUX 6/7
Page 13
RED-HAT LINUX 6/7
# lspci (to list all the PCI slots present in the system)
# du -sh /etc/ (to see the size of the /etc on the disk in KBs
or MBs
# ls -l (to see the long listing of the files and
directories)
d rwx rwx rwx . 2 root root 6 Dec 17 18:00 File name
d type of file
rwx -----> owner permissions
rwx -----> group permissions
rwx -----> permissions for others
. No ACL permissions applied
root ----> owner of the file
root ----> group ownership
6 size of the file
Dec 7 18:00 -----> Date and Time of the created or modified
File name -----> File name of that file
# ls -ld <directory name> (to see the long listing of the directories)
# stat <file name/directory name> (to see the statistics of the file or
directory
35. What are permission types available in Linux and their numeric
representations?
There are mainly three types of permissions available in Linux and those
are,
read ----- r ----- 4 null permission ------ 0
Page 14
RED-HAT LINUX 6/7
36. What is the syntax of the chmod command with all options?
chmod <options><file/dir name> (to change the owner or
permissions of the file/dir The options are, -c ----->
changes
silent (forcefully)
verbose
-R -----> recursive (including subdirectories and files)
To change the permissions the syntax is,
# chmod <who> <what> which Invalid input format.
name or directory>
user (u) add (+) read (4) or (r)
" group(g) remove(-) write (2) or (w)
"
other (o) equal (=) execute (1) or (x) "
37. What is the syntax of the chown command with full options?
# chown <options><file name or directory> (to change the
ownership of the file or directory
The options are, -c -----> changes
silent (forcefully)
verbose
no difference
-R -----> recursive (including sub directories and
files)
-H -----> symbolic link to a directory (command line
argument
-L ------> symbolic link to a directory (all)
do not traverse
Page 15
RED-HAT LINUX 6/7
38. What is the syntax of the chgrp command with full options?
chgrp <options><file name or directory> (to change group)
ownership of the file directory
The options are, -c -----> changes
silent (forcefully)
verbose
no difference
-R -----> recursive (including subdirectories and
files)
-H -----> symbolic link to a directory
-L do not
traverse
Page 16
RED-HAT LINUX 6/7
Page 17
RED-HAT LINUX 6/7
Page 18
RED-HAT LINUX 6/7
RHEL - 7 :
Restart the system.
(ii) Using arrow keys select 1st line and press 'e' to edit.
Go to Linux 16 line press End key or Ctrl + e to go to the end of the
line and give one space.
(iv) Then type as rd.break console=tty1 selinux=0
(v) Then press Ctrl + x to start the computer in single user mode.
(vi) After starting, we get the switch_root:/# prompt, and then type
as follows.
(vii)# mount -o remount, rw /sysroot and press Enter and then
type as follows.
(viii)# chroot /sysrootpress Enter.
Page 19
RED-HAT LINUX 6/7
Page 20
RED-HAT LINUX 6/7
54. How to find the users who are logged in and how to terminate them?
fuser -cu (to see who is logged in)
#fuser -ck <user login name> (to kill the specified user)
Page 21
RED-HAT LINUX 6/7
59. What is the syntax to assign read and write permissions to a particular
user, group and other?
# setfacl -m u : <user name> : <permissions><file or directory>
# setfacl -m g : <user name> : <permissions><file or directory>
# setfacl -m o : <user name> : <permissions><file or directory>
60. What is the syntax to assign read and write permissions to a particular
user, group and other at a time?
# setfacl -m u : <user name> : <permissions>, g : <user name> :
o <permissions><file or directory>
Useful commands :
# setfacl -x u : <user name><file or directory name> (to remove the
ACL permissions from the user
# setfacl -x g : <user name><file or directory name>(to remove the
ACL permissions from group
setfacl -x o : <user name><file or directory name> (to remove the
ACL permissions from others
Remove all access control lists from a file or directory (to remove all the ACL permissions)
61. How will you lock a user, if he enters wrong password 3 times?
The pam_tally.so module maintains a count of attempted accesses and can reset.
Count on success, can deny access if too many attempts fail. Edit
/etc/pam.d/system-auth file, enter:
(i) # vi /etc/pam.d/system-auth
Modify as follows:
auth required pam_tally.so no_magic_root
account required pam_tally.so deny=3 no_magic_root
lock_time=180
Where,
Page 22
RED-HAT LINUX 6/7
Page 23
RED-HAT LINUX 6/7
Page 24
RED-HAT LINUX 6/7
# edquota -p <user name 1> <user name 2> (to apply user name 1
quotas to user name 2, ie., no
need to edit the quota editor for user name 2)
Page 25
RED-HAT LINUX 6/7
Here we can specify the block level quota or file level quotas.
Group quota can be applicable to all the users of that specified.
group.
(save and exit the above quota editor)
Page 26
RED-HAT LINUX 6/7
1. What is partition?
A partition is a contiguous set of blocks on a drive that are treated as
independent disk.
2. What is partitioning?
Partitioning means to divide a single hard drive into many logical drives.
Page 27
RED-HAT LINUX 6/7
Page 28
RED-HAT LINUX 6/7
Page 29
RED-HAT LINUX 6/7
device_name
backup or not><fsck value>
Whenever the system reboots, mount the partitions according to entries in
/etc/fstab file. So, these types of mountings are permanent even after the
system is rebooted.
# mount -a to mount the partitions without rebooting
14. What are the differences between the ext2, ext3, ext4, and xfs file systems?
S.N
Ext2 Ext3 Ext4
o.
Stands for Second Stands for Third Stands for Fourth
Extended file Extended file Extended file
system. system. system.
2. Does not having Supports Supports
Journaling feature. Journaling feature. Journaling feature.
3. Max. file size can Max. file size can Max. file size can
be from 16 GB to 2 be from 16 GB to 2 be from 16 GB to
TB. TB. 16 TB.
4. Max. file system Max. file system Max. file system
size can be from 2 size can be from 2 size can be from 2
TB to 32 TB TB to 32 TB TB to 1 EB
1EB = 1024 Peta
bytes.
16. The partitions are not mounting even though there are entries in
/etc/fstab. How to solve this problem?
Page 30
RED-HAT LINUX 6/7
First check if there are any wrong entries in the /etc/fstab file. If all are okay then
unmount all the partitions by
executing the below command,
umount -a
Then mount again all the partitions by executing the below
command
# mount -a
17. When trying to unmount it is not unmounting, how to troubleshoot
this one?
Sometimes the directory reflects an error while unmounting because,
(i) you are in the same directory and trying to unmount it, check with#
pwd command.
(ii) some users are present or accessing the same directory and using the
contents in it, check this with
# fuser -cu <device name> (to check the users who are
accessing that partition
lsof <device name> (to check the files which are open in that
mount point
# fuser -ck <opened file name with path> to kill that opened
files)
Now we can unmount that partition using # umount <mount point>
Page 31
RED-HAT LINUX 6/7
Page 32
RED-HAT LINUX 6/7
27. How to check the integrity of a file system or consistency of the file
system?
Using the fsck <device or partition name> command, we can check the integrity.
of the file system.
But before running the fsck command, first unmount that partition and
then run the fsck command.
Page 33
RED-HAT LINUX 6/7
28. What is an fsck check or what are the phases of the fsck?
(a) First it checks blocks and sizes of the file system
Second it checks file system path names.
(c) Third, it checks file system connectivity.
(d) Fourth, it checks file system reference counts (nothing but inode
numbers)
1 (e) Finally it checks file system occupied cylindrical groups
29. Why the file system should be unmounted before running fsck
command?
If we run fsck on mounted file systems, it leaves the file systems in
unusable state and also deletes the data. So, before running the fsck
command the file system should be unmounted.
31. How to extend the root file system which is not on LVM?
By using # gparted command we can extend the root partition,
otherwise we cannot extend the file systems which is not on LVM.
34. How to know which file system occupies more space and the top 10 files
systems?
# df -h <device or partition name> | sort -r | head -10
Page 34
RED-HAT LINUX 6/7
39. How to find how many disks are attached to the system?
# fdisk -l (to see how many disks are attached to the system)
42. How to create the file systems with the user specified superblock
reserve space?
# mkfs.ext4 -m <no.><partition name> (to format the partition with
<no.>% of reserve space to superblock)
Whenever we format the file system, by default it reserves 5%.
partition space for Superblock.
Page 35
RED-HAT LINUX 6/7
Important Commands :
# umount -a (to unmount all the file systems except ( / ) root file)
system
# mount -a (to mount all the file systems that have entries in
/etc/fstab file
# fsck -A (to run fsck on all file systems)
# fsck -AR -y (to run fsck without asking any questions)
# fsck -AR -t ext3 -y (to run fsck on all ext3 file systems)
# fsck -AR -t no ext3 -y (to run fsck on all file systems except ext3 file
systems)
# fsck -n /dev/sdb1 (to see the /dev/sdb1 file system report without
running fsck)
tune2fs -l /dev/sdb1 (to check whether the journaling is there or not)
# tune2fs -j /dev/sdb1 (to convert ext2 file system to ext3 file system)
Page 36
RED-HAT LINUX 6/7
# journalctl (It tracks all the log files between two different timings and by
default saved in /run/log)
*/run/logis mounted on tmpfs file system. ie., if system is rebooted, the
whole information in that location will be deleted or erased.
We can change the location of the /run/log to another like
/var/log/journalby
# create directory -p /var/log/journal to make a directory in /var/log
location
change owner to root : systemd-journal /var/log/journal (to change the group)
ownership of /var/log/journal)
# chmod g+s /var/log/journal (to set the sgid on /var/log/journal)
Page 37
RED-HAT LINUX 6/7
Page 38
RED-HAT LINUX 6/7
Create a mount point to mount the above created LVM file system by,
# create directory /mnt/<directory name>
(vii) Temporarily mount the LVM on the above created mount point by,
# mount /dev/<volume group name>/<logical volume name><mount
point>or
Mount the LVM on the mount point permanently by,
# vim /etc/fstab
/dev/<VG name>/<LV name> /mnt/<directory> <file system type>
defaults 0 0
Esc+:wq!
# mount -a
Page 39
RED-HAT LINUX 6/7
# df -hT (to see the mounted partitions with file system types)
4. How to see the details of the Physical Volumes?
# pvs (displays all physical volumes with less details)
pvdisplay (displays all physical volumes with more details)
# pvdisplay <physical volume name> (displays the details of the
specified physical volume
pvscan (to scan all the physical volumes)
#pvscan <PV name> (to scan the specified physical volume)
5. How to see the details of the Volume Groups?
# vgs (displays all volume groups with less details)
vgdisplay (displays all volume groups with more details)
# vgdisplay <VG name> (displays the specified volume group with more
details
# vgscan (to scan all the volume groups)
# vgscan <VG name> (to scan the specified volume group)
6. How to see the details of the Logical Volumes?
lvs (displays all logical volumes with less details)
lvdisplay (displays all logical volumes with more details)
# lvdisplay <LV name> (displays the specified logical volume details)
lvscan (to scan all the logical volumes)
# lvscan <LV name> (to scan the specified logical volume)
7. How to extend the Volume Group?
Extending the volume group is actually adding a new physical volume to the
volume group.
To extend the volume group we need to create a new partition using # fdisk
command and make sure that its partition id should be 8e, save the changes
and update the partition table by # partprobe
Create a physical volume on the newly created partition using # pvcreate
command.
Add the partition to the volume group using the # vgextend command
# fdisk /dev/sdb
Command (m for help) : n
First cylinder: press Enter for default one
Last cylinder: +500M create 500MB partition
Command (m for help) : t (to change the partition id)
Select the partition: type the partition number
Specify the Hexa code: 8e
Command (m for help) : w (to save the changes)
# partprobe /dev/sdb1
pvcreate /dev/sdb1
Page 40
RED-HAT LINUX 6/7
Page 41
RED-HAT LINUX 6/7
Unsupported command for translation. (to check the size of the file)
system
10. How to move or migrate the logical volume data from one physical
volume to another physical volume?
There might be a situation where the physical volume might be failing and it is
required to be replaced. In such cases, we need to migrate or move the logical
volume data from the failed physical volume new physical volume and isolate
remove the failed physical volume.
First access the mount point of the failing physical volume and check the data
in it.
Verify the size of the physical volume by #pvs or #pvdisplay
</dev/vgname/lvname>command.
Unmount the file system of that physical volume by# umount <file system
mount point
Add a new physical volume and the size should be the same size or higher than that.
failing physical volume.
Migrate the physical volume contents to the new physical volume using #
pvmove <old PV><new PV>
Mount back the logical volume, access the mount point and verify the data in
it.
Remove the failed physical volume by #vgreduce <vgname><pvname>
command.
Example: # cd <file system mount point>
ls
# pvs <pvname> or # pvdisplay <pvname>
unmount <file system mount point>
pvcreate <device or partition name>
#vgextend <vgname><pvname>
# pvmove <old pvname><new pvname>
mount -a
# vgreduce <vgname><failed pvname>
# cd <file system mount point>
# ls
11. How to delete or remove the logical volume?
To delete or remove the logical volume, first unmount the file system by
umount <mount point>
Remove the entry in the /etc/fstab file.
Remove the logical volume by # lvremove
/dev/vgname/lvname> command.
Page 42
RED-HAT LINUX 6/7
Page 43
RED-HAT LINUX 6/7
Check the volume group backup list by # vgcfgrestore --list <volume group>
name>command.
Then remove the logical volume by # lvremove </dev/vgname/lvname>
command.
Copy the backup file that was made before the volume group was removed.
from the above backup list and paste it in this command# vgcfgrestore -f
<paste the above copied file name><vgname>
The logical volume is created automatically after restoring the volume group.
but the volume group and logical volumes both will be in inactive state. So,
check the state of the volume group by #vgscan and the logical volume state by
lvscan commands.
Then activate that volume group by # vgchange -ay <volume group
name>commandand activate the logical volume by #lvchange -ay <logical
volume name>command.
Mount the logical volume file system using the # mount -a command.
# unmount <file system mount point>
# vgcfgrestore --list <volume group name> (copy the
backup file from the list
# lvremove </dev/vgname/lvname>
# vgcfgrestore -f <paste the above copied file><volume
group name
vgscan (to check the status of)
the volume group
# lvscan (to check the
status of the logical volume
# vgchange -ay <volume group name> (activate the
volume group if it is in inactive state
# lvchange -ay <logical volume name> (activate the
logical volume if it is in inactive state
Note: The option a means active VG or LV and option
ymeans yes.
# mount -a
15. How to change the volume group name and other parameters?
vgrename <existing volume group name> <new volume group name>
(to rename the volume group)
By default, unlimited logical volumes can be created per volume group.
But we can control this limit by
# vgchange -l <no.><volume group> (to limit max. no. of logical
volumes to the specified number
Page 44
RED-HAT LINUX 6/7
16. How to change the logical volume name and other parameters?
# lvrename <existing lvname><new lvname> (to rename the logical
volume)
# lvchange -pr <logical volume> to put the logical volume into
read only mode)
lvs (to see the logical volume permissions)
lvchange -prw <logical volume> (to put the logical volume into
read and write mode
20. What are the locations of the logical volume and volume groups?
# cd /etc/lvm/backup (the logical volumes backup location)
# cd /etc/lvm/archive (the volume groups backup location)
Page 45
RED-HAT LINUX 6/7
23. How to extend the logical volume to max. disk space and half of the
disk space?
# lvextend -l +100% FREE <logical volume> (to extend the logical)
volume by adding the
volume group's total available space
# lvextend -l 50% <vgname><lvname> (to extend the logical
volume by adding the 50%
free space of the volume group
24. How to check on which physical volume the data is writing in the
logical volume?
# lvdisplay -m ( to check on which physical volume the data is
currently writing from all logical volumes
lvdisplay -m <lvname> (to check on which physical volume
the data is writing from the
Specified logical volume
Page 46
RED-HAT LINUX 6/7
26. How to scan and detect the LUNs over the network?
# ls /sys/class/fc_host (to check the available fibre)
channels
# echo "---" > /sys/class/scsi_host/<lun no.>/scan (to scan and
detect the luns over the network
30. What is RAID? What is the use of RAID and how many types are there?
Available RAIDs?
RAID stands for Redundant Array of Independent Disks.
It provides fault tolerance, load balancing using stripping, mirroring and
parity concepts.
Page 47
RED-HAT LINUX 6/7
31. How many types of software RAIDs are available and what are their requirements?
(i) RAID - 0 ---- Striping ---- Minimum 2 disks required
RAID - 1 ---- Mirroring ---- Minimum 2 disks required
(iii) RAID - (1+0) --- Mirroring + Stripping ---- Minimum 4 disks
required
RAID - (0+1) Stripping + Mirroring ---- Minimum 4 disks
required
(v) RAID - 5 ---- Stripping with parity ---- Minimum 3 disks required
1 2
3 4
5 6
Disk - 1
Disk - 2
If the Disk - 1 is /dev/sdb and the Disk - 2 is /dev/sdc then,
# mdadm -Cv /dev/md0 -n 2 /dev/sdb /dev/sdc -l 0 (to create
the RAID - 0 using disk - 1 and disk - 2)
# cat /proc/mdstat (to check the RAID - 0 is
created or not
mkfs.ext4 /dev/md0 (to create the ext4 file
system on the RAID - 0)
# create directory /mnt/raid0 (to create the RAID - 0
mount point
# mount /dev/md0 /mnt/raid0 (to mount RAID - 0 on
the mount point
Page 48
RED-HAT LINUX 6/7
Page 49
RED-HAT LINUX 6/7
2 1+2
1
3 4
3+4
5+6 5
6 Disk - 1
Disk - 2 Disk - 3
If the Disk - 1 is /dev/sdb, the Disk - 2 is /dev/sdc and Disk - 3 is
/dev/sddthen,
# mdadm -Cv /dev/md0 -n 2 /dev/sdb /dev/sdc -l 5 (to create
the RAID - 5 using disks - 1, 2 and 3)
# cat /proc/mdstat (to check if RAID - 5 is created or not)
not
mkfs.ext4 /dev/md0 (to create the ext4 file system on
the RAID - 5)
# mkdir /mnt/raid5 (to create the RAID - 5 mount
point
Page 50
RED-HAT LINUX 6/7
36. How will you troubleshoot if one of the eight disks failed in LVM?
First unmount the file system and add the new disk with the same size as the
failed disk to the volume group. Then move the data from failed
physical volume to newly added physical volume and then remove the
failed physical volume from the volume group. And finally mount the file
system.
38. How to inform the client and then troubleshoot if the disk is full?
First check which files are accessing more disk space by #du -h | sort -r
command. if any temporary and junk files are present remove them from
the disk to make room for new or updated data. Then inform the actual
situation to the client, take the permission from the client to get
Page 51
RED-HAT LINUX 6/7
the lun from storage and extend the file system by adding that lun to
the LVM.
40. I have four disks each 1TB in RAID - (1+0). So, total how much di
space can I utilize in that RAID–
(1+0)? RAID - (1+0) means Mirroring + Stripping. It requires 4 disks.
i.e., 2 disks for mirroring and the remaining 2 disks for stripping. And 5 - 10%
disk space is used for superblock information. So, finally we can utilize
2TB - 2TB X 10% disk space in that RAID - (1+0).
41. If two disks failed in RAID - (1+0), can we recover the data?
The RAID - (1+0) requires a minimum of 4 disks and it uses Mirroring +
Stripping. If one disk fails, we can
recover the data, but if two disks have failed we cannot recover the
data.
42. How many types of disk space issues can we normally get?
Disk is full.
(ii) Disk is failing or failed.
(iii) File system corrupted or crashed.
O/S is not recognizing the remote luns when scanning, ...etc.
Page 52
RED-HAT LINUX 6/7
one file system and the link file may be on another file system. If we
edit any file, the linked files are also updated automatically. When we
create a soft link file, the permissions are full permissions. The soft link
file and the original file inode numbers are different. The size of the soft link
file is same as the length of the original file name. The soft link can be
created by
# ln -s <original file or directory><link file or directory with path>
(to create a soft link)
# ln -s /root/script /root/Desktop/script (to create a link file for
the script and stored on root Desktop
Page 53
RED-HAT LINUX 6/7
Examples:
# find / -name <file name> (to search for file names in /)
directory
find / -name <file name> -type f (to find file names)
only
find / -name <directory name> -type d (to find directories
with small letters only
find / -iname <file/directory name> -t d (to search for small or
capital letter files/directories
#find / -empty (to search empty files or
directories)
Page 54
RED-HAT LINUX 6/7
Page 55
RED-HAT LINUX 6/7
Page 56
RED-HAT LINUX 6/7
Page 57
RED-HAT LINUX 6/7
9. What is an IP address?
Every Computer will be assigned an IP address to identify each one to
communicate in the network. The IP address sub components are Classes of
an IP address, Subnet masks and Gateway.
Classes of IP address:
The IP addresses are further divided into classes. The classes are A, B, C,
D, E and the ranges are given below.
Default Subnet Classless Inter
Class Start End
mask Domain Routing
Class A 0.0.0.0 127.255.255.255 255.0.0.0 /8
Class B 128.0.0.0 191.255.255.255 /16
Class C 192.0.0.0 223.255.255.255 255.255.255.0 /24
Class D 224.0.0.0 239.255.255.255
Class E 240.0.0.0 255.255.255.255
Page 58
RED-HAT LINUX 6/7
Page 59
RED-HAT LINUX 6/7
Static Network.
Dynamic Network.
Static Network :
In this way we assign the IP address and hostname manually. Once we
configure the IP address, it will not change.
Dynamic Network :
In this way we assign the IP address and hostname dynamically. This
means the IP address will change at every boot.
19. How to assign the static IP address to the NIC card?
In RHEL - 6 :
# setup
(Move the cursor to Network configuration and press Enter key)
(Move the cursor to Device configuration and press Enter key)
(Select the NIC adapter i.e., eth0 and press Enter key)
(Assign the above IP address and other details as per our requirements)
and move the cursor to 'OK' and press
Enter key)
(Move the cursor to "Save" to save the changes in device configuration)
and press Enter key)
Once again move the cursor to the "Save & Quit" button and press Enter
key)
Finally move the cursor to 'Quit' button and press Enter key to quit the
utility
Then restart the network service and check for the IP address by #
service network restart command
(If the change is not reflected with the above service, then restart the)
network manager by
service
NetworkManager restart command
# ifconfig (to see the IP address of the NIC card)
# ping < IP address > (to check whether the IP is pinging or
not)
In RHEL - 7 :
# nmcli connection show to see all the network
connections
# nmcli device show (to see the network details if already)
configured manually or dynamically
# nmcli connection add con-name "System eth0" ifname eth0 type
ethernet (to add the network connection)
Page 60
RED-HAT LINUX 6/7
21. What are the differences between Dynamic and Static configuration?
information?
Dynamic configuration information Static configuration information
<NIC device name> Device =<NIC device name>
02:8a:a6:30:45 02:8a:a6:30:45
Bootproto=DHCP Bootproto=none (means static network)
Onboot=yes (yes means whenever we
restart the system this connection will be Onboot=yes
activated and no means whenever we
Page 61
RED-HAT LINUX 6/7
RHEL - 7 :
# hostname <fully qualified domain name> (to set the
hostname temporarily
hostnamectl set-hostname <fully qualified domain name> (to set
the hostname permanently)
# systemctl restart network (to update the
hostname in the network
# systemctl enable network (to enable the
connection at next reboot)
23. How to troubleshoot if the NIC is not working?
(a) First check if the NIC card is present or not using the # ifconfig command.
(b) If present, then check the status of the NIC card is enabled or
disabled by clicking on the System menu on the status bar, then select
Network Connections menu.
(c) Click on the IPV4 settings tab, select the device eth0 or any other and
Select Enable button, then Apply and OK.
(d) Open /etc/sysconfig/network-scripts/ifcfg-eth0 file check
Userctl=yes or no. If it is yes make it as no, then check Onboot= yes or
If it is no, make it yes and save that file.
Page 62
RED-HAT LINUX 6/7
If not present then check the status of the NIC card is enabled or
disabled by clicking on the System menu on the status bar, then select
Network Connections menu.
(f) Click on the IPV4 settings tab, select the device eth0 or any other and
select Enable button, then Apply and OK.
(g) Using # setup(in RHEL - 6) or # nmcli (in RHEL - 7) commands
assign the IP address to the system and restart the network service
by# service network restart(in RHEL - 6) or# systemctl restart network
(in RHEL - 7) commands and enable the service at next reboot by
chkconfig network on (in RHEL - 6) or enable systemctl
network(in RHEL - 7) commands.
(h) Then bring up the connection by # ifconfig eth0 up (in RHEL - 6) or #
nmcli connection up <connection name> commands.
(i) Even though it is not working, it may be the fault in the NIC card. If so,
contact the hardware vendor by taking the permissions from higher
authorities.
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:
Collection of multiple NIC cards and make them as a single connection
(virtual) NIC card is called bonding.
It is nothing but backup of NIC cards.
In RHEL - 6 it is called Bonding or Bridging.
In RHEL - 7 it is called Teaming or Link aggregation.
There are 3 types of backup in Bonding or Teaming.
(a) Mode 0 -----> Round Robin
(b) Mode 1 -----> Active backup
(c) Mode 3 Broadcasting
Mode 0 :
It provides load balancing and fault tolerance.
Data will be shared by both NIC cards in round robin.
If one NIC card fails, then another NIC card will be activated to communicate.
with the server
So, there are load balancing and fault tolerance features.
Mode 1 :
Active backup means only one NIC card is activated at a time and another one is
in down state.
So, there is no load balancing.
Page 63
RED-HAT LINUX 6/7
But if one NIC card fails, another NIC card will be activated.
automatically.
Mode 3 :
In this mode broadcasting is done.
In this, the same data will be transferred through two NIC cards.
So there is no load balancing.
But if one NIC card fails, then the second NIC card will be activated.
automatically.
So, all the 3 modes only support fault tolerance, but round robin is
the only one mode that provides load balancing.
Requirements to configure:
(i) Minimum two NIC cards.
(ii) One IP address.
(iii) Connection type is bond (in RHEL - 6) and team (in RHEL -
not the ethernet type.
Here there is no need to assign the IP addresses for two NIC cards and we
Are you giving only one IP address to bond or team.
Bonding configuration: (in RHEL - 6)
(i) # vim /etc/sysconfig/network-scripts/ifcfg-bond0
bond0
<IP address>
TYPE=ethernet
NETMASK=255.225.225.0 or <IP address class netmask>
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
yes
mode0 or mode1 or mode3 miimon=50
(Save and exit this file)
(ii) vim /etc/sysconfig/network-scripts/ifcfg-eth1
eth1
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
bond0
yes (Save and exit this
file
vim /etc/sysconfig/network-scripts/ifcfg-eth2
eth2
ONBOOT=yes
Page 64
RED-HAT LINUX 6/7
BOOTPROTO=none
USERCTL=no
bond0
yes (Save and exit this
file)
(iv) To add virtual NIC cards eth1 and eth2:
# setup -----> Networking -----> Device configuration ----->
New Device -----> eth1
eth1
eth1 (save and exit
this setup)
# setup -----> Networking -----> Device configuration ----->
New Device -----> eth2
eth2
Device : eth2 save and exit
this setup)
(v) Adding bond0 connection :
# setup -----> Networking -----> Device configuration ----->
New Device -----> bond0
bond0
bond0
IP address : <IP address>
Netmask: 255.255.255.0
Default gateway : <gateway IP address> (save and exit)
this setup)
ifdown bond0
ifdown eth1
ifdown eth2
ifup bond0
# service NetworkManager stop
service network restart
# chkconfig network on
# service NetworkManager restart
cat /proc/net/bonding/bond0 (to check
the bonding information
watch -n 1 cat /proc/net/bonding/bond0 (to check the
bonding information for every 1 minute
echo "eth1" >
/sys/devices/virtual/net/bond0/bonding/active_slave (to put the eth1 NIC in
active state
Page 65
RED-HAT LINUX 6/7
Teaming configuration :
(i) Add the team0 connection by
# nmcli connection add con-name team0 ifname team0 type
team
config ' { "runner" : { "name" : "roundrobbin" or
activebackup or broadcasting
(ii) Add the two NIC cards one by one to the above created connection
by
# nmcli connection add con-name port1 ifname eth1 type
team-slave master team0
nmcli connection add con-name port2 ifname eth2 type
team-slave master team0
(iii) Assign the static IP address to the team0 connection by
#nmcli connection modify team0 ipv4.addresses <IP
address>/<netmask> ipv4.method static
Up the connection by
# nmcli connection up team0
(v) To see the team0 connection up details by
teamdctl team0 state
To check the connection communication by
# ping -I team0 <IP address>
(vii) To disable one NIC card in team0 by
nmcli connection down port1
(viii) teamdctl team0 state (to check the team0 NIC card up or down
details
25. What is the difference betweenTCPandUDPprotocol?
TCP is a connection-oriented protocol and contains the information of
sender as well as receiver.
HTTP, FTP, Telnet
TCP is slower than UDP due to its error checking mechanism.
UDP protocols are connectionless; packets have no information about where they are going.
are going. These types of ports are generally used for broadcasting.
For example: DNS, DHCP
UDP is faster
26. What are the benefits of NIC Teaming?
(i) Load balancing
(ii) Fault Tolerance
Failover
27. Mention all the network configuration files you would check to
Configure your ethernet card?
Page 66
RED-HAT LINUX 6/7
(i) /etc/sysconfig/network-scripts/ifcfg-eth*
(ii) /etc/sysconfig/network
(iii) /etc/resolve.conf
(iv) /etc/nsswitch.conf
28. What is the use of /etc/resolve.conf?
It contains the details of nameserver, i.e., details of your DNS server.
which helps us connect to the Internet.
29. What is the use of the /etc/hosts file?
To map any hostname to its relevant IP address.
30. What is the command to check all the open ports of your machine?
#nmap localhost
31. What is the command to check all the open ports of a remote machine?
nmap <IP address or hostname of the remote system>
32. What is the command to check all the listening ports and services of
your machine?
#netstat -ntulp
33. How can you make a service run automatically after boot?
#chkconfig <service name> on
34. What are the 6 run levels of Linux? And how can you configure your
script to run only when the system boots intoGUIand not to any other
runlevel?
0 Power off
1 Single user
2 Multi user without network
3 Multiuser with network
4 Development purpose
5 GUI
6 Restart
# chkconfig --level 5 service_name on
# chkconfig --level 1234 service_name off
35. What is a 3 way handshake protocol? Give an example of it.
SYN - system 1 sends SYN signal to remote system.
SYN-ACK - the remote system receives the syn signal and sends the ack signal.
ACK - system again receives ack signal from remote system and
Connection is established.
For example: When you ping a machine, you are sending a SYN signal.
which is ACK by the remote machine then it sends a SYN ACK signal back to
the host machine. Then the host machine receives SYN ACK and sends the
ACK signal back to confirm the same.
36. What are the possible ways to check if your system is listening to port
Page 67
RED-HAT LINUX 6/7
67?
# nmap localhost | grep 67
# netstat -ntulp | grep 67
37. Explain about IPV6?
Its length is 128 bits. Its netmask is 64
# nmcli connection modify "System eth0" ipv6.addresses
2005:db8:0:1::a00:1/64 ipv6.method static
to add the IPV6 version of IP address
to the connection 'System eth0'
# nmcli connection modify "System eth0" ipv4.addresses
172.25.5.11/24 172.25.5.254
172.25.254.254 ipv4.dns-search example.com ipv4.method static
ipv6. addresses 2005:ac18::45/64
ipv6.method static (to assign ipv4 and ipv6 IP)
addresses to 'System eth0 connection'
# nmcli connection down "System eth0" (to down the "System
eth0" connection)
# nmcli connection up "System eth0" (to activate the "System eth0")
connection)
38. How to troubleshoot if the network is not reachable?
(i) First check whether the network cable is connected or not by # ethtool
<NIC device name> command. if connected then check the IP address is
assigned or not by # ifconfig <NIC device name> command.
(ii) Then check the system uptime with the # uptime command.
(iii) Then check the network services status by # service network
status and # service NetworkManager status commands.
(iv) Then check the network service at Run Level by # Chkconfig --
list network command.
(v) Then check whether the source network and destination network
are in the same domain or not.
(v) Then finally check the routing table by using the # route -n command.
Page 68
RED-HAT LINUX 6/7
Page 69
RED-HAT LINUX 6/7
Page 70
RED-HAT LINUX 6/7
Page 71
RED-HAT LINUX 6/7
Page 72
RED-HAT LINUX 6/7
Page 73
RED-HAT LINUX 6/7
5. Managing SELinux
Page 74
RED-HAT LINUX 6/7
1. What is SELinux?
It is a type of security that enhances the security that allows users.
and administrators more control over which users and applications can access
which resources, such as files, Standard Linux access controls etc.
It is mainly used to protect internal data (not from external data) from
system services. In real time, SELinux is disabled and instead of this, IP tables are
used. It protects all the services, files and directories by default if SELinux is
enabled.
2. In how many ways can we implement the SELinux? Explain them.
We can implement SELinux mainly in 2 modes.
(i) Enabled
(ii) Disabled (default mode)
Enabled :
Enabled means enabling the SELinux policy and this mode of SELinux is
divided into two parts.
Enforcing
(b) Permissive
Disabled:
Disabled means disabling the SELinux policy.
3. What is Enforcing mode in SELinux?
Enforcing means SELinux is on. It checks SELinux policy and stores a log.
No one can access the services by default, but we can change the policy whenever.
we needed.
4. What is Permissive mode in SELinux?
SELinux is on and it doesn't check SELinux policy and stored the log.
Everybody can access the services by default and we can also change the
SELinux policy. It is also called debugging mode or troubleshooting mode.
this mode SELinux policies and rules are applied to subjects and objects but
actions are not affected.
5. What is Disabled mode in SELinux?
SELinux is turned off and no warning and log messages will be generated.
and stored.
6. What are Booleans?
Booleans are variables that can either be set as true or false. Booleans
enhance the effect of SELinux policies implemented by the System
Administrators. A policy may protect certain demons or services by applying
various access control rules.
7. What is SELinux policy?
The SELinux policy is the set of rules that guide the SELinux security.
engine. It defines types for file objects and domains for process. It uses roles to
Page 75
RED-HAT LINUX 6/7
Limit the domains that can be entered and the user identities to specify the role.
that can be attained.
8. What are the required files for SELinux?
# vim /etc/selinux/config It is the main file for SELinux.
# vim /etc/sysconfig/selinux -----> It is a link file to the above file.
# vim /var/log/audit/audit.log -----> SELinux log messages will be
stored in this file.
9. What is the command to see the SELinux mode?
getenforce (to check the SELinux mode)
10. What is the command to set the SELinux mode temporarily?
# setenforce 0 or 1 (to set the SELinux mode. Where '0' ----->
permissive and ' 1 ' -----> Enforcing
Note: (i) To change the SELinux mode from Permissive to Enforcing or
Enforcing to Permissive modes the system restart is not required.
(ii) To change Enforcing mode to Disabled mode or Disabled
mode to Enforcing mode the system restart is required.
(iii) The above commands change the SELinux mode
temporarily only. To make the selinux changes permanently then
open /etc/selinux/config and go to ,
SELINUX=Enforcing or Permissive or Disabled
save and exit this file
11. What is the command to see the SELinux policy details?
sestatus (to see the SELinux policy details)
Other useful commands:
# ls -Z <file name> (to see the SELinux context of the file)
# ls -ldZ <directory name> (to see the SELinux context of the
directory
# ps -efZ | grep <process name> (to see the SELinux context of the
process running on the system
# ps -efZ | grep http (to see the SELinux context of the http
process running on the system
# chcon -t <argument> <file/directory name> to change
SELinux context of the file or directory
# chcon -t public_content_t /public (to change the
SELinux context of the /publicdirectory)
# chcon -R public_content_t /public (to change the
SELinux context of the /publicdirectory and
its contents
# restorecon -v <file/directory name> (to restore the
previous SELinux context of the file/directory
Page 76
RED-HAT LINUX 6/7
Page 77
RED-HAT LINUX 6/7
Kernel
Init
Runlevel
BIOS :
BIOS stands for Basic Input and Output System. Whenever we power on
the system, the system runs itself diagnostic checks and detects all the
connected input and output peripherals. This process is called POST (Power On Self Test)
Self Test). If any errors found it displays on the screen. Then BIOS locates
the booting disk in the system and locates and loads the Primary boot
loader nothing but MBR (Master Boot Record) into the memory. So, in
In simple terms, the BIOS loads the MBR into memory and executes it.
MBR.
MBR :
MBR stands for Master Boot Record. It is located in the 1st sector of the
bootable disk (it may be /dev/hda or /dev/sda). The size of the MBR is 512
bytes and it contains three components.
(i) Primary boot loader information and its size is 446 bytes.
(ii) Partition table information and its size is 64 bytes.
(iii) MBR validation check and its size is 2 bytes. Its main purpose is
whether the MBR is valid or not.
The primary boot loader contains the secondary boot loader nothing but
GRUB or LILO (in old systems).
Then the primary boot loader locates and loads the secondary boot loader.
into memory.
So, in simple terms the MBR loads and executes the GRUB boot loader.
GRUB or LILO:
GRUB stands for Grand Unified Boot loader. LILO stands for Linux Loader
and is used in old Linux systems. If we have multiple kernel images installed in
our system, we can choose which one to be executed. GRUB displays a
splash screen, waits for a few seconds. If we do not enter anything, it loads
the default kernel image as specified in the grub configuration file. GRUB has
the knowledge of the file system (the old LILO didn't understand the system).
GRUB configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to
this). This file contains kernel and initrd images. So, in simple terms GRUB
just loads and executes kernel and initrd images.
Kernel :
Kernel initializes itself and loads the kernel modules and mounts the root
file system as specified in the "root=" in grub.conf and then kernel executes the
/sbin/initprogram. Since init was the 1st program to be executed by Linux
kernel, it has the process ID (PID) of 1. We can see this id by # ps -ef | grep
Page 78
RED-HAT LINUX 6/7
initcommand. initrd stands for initial RAM Disk. initrd is used by kernel as
temporary file system until kernel is booted and the real root the file system is
mounted. It also contains necessary drivers compiled inside which helps it to
access the hard drive partitions and other hardware.
init level :
In this init program reads the /etc/inittab file and puts the system into
specified run level. init identifies the default run level from /etc/inittabfile
and we can change this default run level whenever we need.
You can find the default run level by # grep "initdefault" /etc/inittab
command on our system. Normally the
The default run level in Linux is 3 in CLI (Command Line Interface) mode and
5 in GUI (Graphical User Interface) mode.
Run Level Programs :
The following run levels are available in Linux systems.
0 halt or shutdown the system
1 Single user mode
2 Multi user without NFS
3 -----> Full multi user mode but no GUI and only CLI mode
4 Unused
5 Full multi user mode with GUI (X11 system)
6 reboot the system
Whenever we start the Linux system is booting we can see various
services getting started. Those services are located in different run levels
programs executed from the run level directory as defined by our default run
level. Depending on our default init level setting, the system will execute
the programs from one of the following directories.
Run level 0 -----> /etc/rc.d/rc0.d
Run level 1 -----> /etc/rc.d/rc1.d
Run level 2 -----> /etc/rc.d/rc2.d
Run level 3 -----> /etc/rc.d/rc3.d
Run level 4 -----> /etc/rc.d/rc4.d
Run level 5 -----> /etc/rc.d/rc5.d
Run level 6 -----> /etc/rc.d/rc6.d
The above directories are also having symbolic links available for those
directories under /etc/rc0.d, /etc/rc1.d, ....etc., So, the /etc/rc0.d is linked
to /etc/rc.d/rc0.d
Booting procedure in RHEL - 7:
Up to the kernel, the booting process is the same as the above.
is the GRUB configuration file in RHEL - 7.
systemd is the initial process in RHEL - 7 and its process ID is 1.
Page 79
RED-HAT LINUX 6/7
linux16 reads the root (/) file system and then initrd16 process will
mount the root ( / ) file system in read-only write mode and starts the
systemd process. And the systemd process will read the /etc/fstab file and
mount all the file systems. Then it reads the file
/etc/systemd/system/default.targetfile and brings the system into the
Default run level according to the scripts, the processes will start or stop.
2. How to check the current run level of the system?
Unable to translate as the input does (to
not contain
see thetranslatable
currenttext.
run level of the system)
3. How to change the default run level?
First open the /etc/inittab file by # vim /etc/inittab command and
go to the last line and change the run level number as we required and then reboot
the system by# init 6 command. After rebooting the system check the
current run level by # who -r command.
4. How to start the graphical interface if the system is in run level 3
now?
startx (it changes the run level 3 to 5 and reboots the
system
5. How to troubleshoot if the boot disk is not available?
(i) First, check if the hard disk is present in the system or not. If not
connect the hard disk and restart the system.
(ii) If the hard disk is present, then go to BIOS and find the location of
the hard disk.
(iii) Check the boot priority in the BIOS. If boot priority is not the hard disk
then change it to hard disk and restart the system.
Even though the system is not started, boot the system with
CDROM in single user mode and open the /boot/grub/grub.conf file
and see the hard disk name and partition number. Normally it should be
/dev/hda1 (if the hard disk is an IDE hard disk) or /dev/sda1 (if the
hard disk is SATA or SCSI). If the hard disk name and partition
If the number is different from the original, then change it and reboot the system.
system with hard disk.
(v) If the GRUB is corrupted then reboot the system with CDROM in
single user mode and restore the grub information from the
recent backup and then restart the system with hard disk.
6. How to reboot the production server?
(i) In general the production servers will not be rebooted frequently
because the end users will suffer if the production servers are in
down state. If any changes made to the system like grub, selinux policy, default
run level is changed and if kernel patches are applied the system
reboot is required.
Page 80
RED-HAT LINUX 6/7
(ii) If any inconsistency is in the root (/) file system, then take the business
approval from higher authorities, make a plan for proper schedule
also inform the different teams, like the application team, to stop the application,
Database team to stop the databases, QC team to stop the testing.
monitoring people to ignore the alerts from this server and others
teams if any and then reboot the system with CD-ROM in single user mode and
then run the #fsck command on that file system.
(iii) If the operating system disk is corrupted or damaged, then reboot the system.
temporarily with the mirror disk then fix that problem and again
boot the system with original disk.
7. What is the difference between the # reboot and # init 6 commands?
Both commands are used to restart or reboot the system.
The reboot command will not send the kill signals to the system and it will
kill all the running processes and services forcefully and then restart the
system.
# init 6 command will send the kill signals to the system and it will stop
all the processes and services one by one and then restart the system.
8. What is a console port and how to connect to the console port?
The console port is used to connect to the system even when the system is not active.
booted with the main O/S. This port is used to connect the system for
troubleshooting purpose only. We can connect the console port as same as
Connect to the system's LAN port and it is also assigned an IP address, username.
and password to connect to the console.
There are different types of console ports for different types of servers.
They are given below.
Server Name Name of the Console port Expansion name
DELL Remote Access
Controllers
i-DRAC ---> Integrated DELL
DELL DRAC or i-DRAC
Remote Access
Controllers
IBM Power
HMC Hardware Management Console
series
HP ILO Integrated Light Out
Page 81
RED-HAT LINUX 6/7
and boot with CDROM in single user mode and mount the root ( / ---> O/S) file
system on temporary mount point.
(iii) Check any wrong entries in the cron jobs i.e., crontab editor see any
Are there reboot scripts or not? If found remove those entries and
reboot the system.
(iv) If the above is not resolved, then check the memory (RAM).
(v) If the RAM module is not working, the system gets a panic and it may
continuously reboots.
(vi) If the RAM module is working then check the RAM size whether
the sufficient RAM that is required to run the application is available or
not. If not there then increasing the RAM size may resolve this issue.
(vii) Check the "/var/log/messages" file for any messages regarding
continuous rebooting.
(viii) Even though there is sufficient RAM, there may not be enough swap space.
sufficient to run all the services and applications then system
get panic and may continuously reboots. If so, then increasing the swap size
may resolve this issue.
10. What is TCP handshaking?
The procedure that takes place between two TCP/IP nodes to establish a
connection. Known as the Synchronization, Synchronize
Acknowledgement and Acknowledgement handshake.
For example, if computer A transmits a Synchronize packet to computer B
B, which sends back a Synchronize- Acknowledge packet to compute A.
Computer A then transmits an Acknowledge packet to computer B and the
connection is established. This whole above said process is called the TCP
handshaking.
11. How many links will be created when we create the directory?
Whenever we create any directory, two links will be created.
12. What are the differences between run level 2 and run level 3?
Run Level 2 :
(i) It supports multiuser operations.
(ii) Multiple users can access the system.
(iii) All the system daemons will run except NFS and some others.
network service related daemons.
(iv) So, without NFS we can use all other services.
Run Level 3
(i) It also supports multi-user operations.
(ii) Multiple users can access the system.
(iii) All the system daemons including NFS and other network related
service daemons will run.
Page 82
RED-HAT LINUX 6/7
Page 83
RED-HAT LINUX 6/7
(xiii) Install the new grub on the boot device ie., may be /dev/sda2 by
# grub-install <device name>
command (For example # grub-install /dev/sda2).
(xiv) If it shows no error reported that means we have successfully
recovered the grub.
(xv) Then type # exit command and again type # exit or # reboot
command to reboot the system.
18. What are Modules or Kernel Modules? How to find the Kernel?
Modules?
The drivers in the Linux system are known as Modules or Kernel Modules.
These modules are assigned by kernel depending on the hardware.
Hardware can only be communicated with and can work efficiently when the proper
module is loaded in the kernel. we can find the kernel modules by # ls
/etc/lib/modulescommand.
All the kernel modules in the system will end with ".ko"
extension. So, we can see all the modules in the system by # find / -
name *.kocommand.
19. What other commands related to kernel modules?
# lsmod (to list all the currently
loaded modules
# lsmod |grep -i <module name> (to check whether the
whether a particular module is loaded or not
# lsmod |grep -i fat (to check the fat module is
loaded or not
There might be a situation where our module is not working properly, in
In that case, we have to remove that. module and re-install it again by,
# modprobe -r <module name> (to remove the
specified module
# modprobe -r fat to remove the fat module
# modprobe <module name> (to install or re-install the
module)
# modprobe fat (to install or re-install the
module)
# modinfo <module name> (to see the specified module)
information
uname (to see which O/S is)
present in the system
Unix name -s (to see which O/S kernel this is)
either Linux or Unix
Page 84
RED-HAT LINUX 6/7
Page 85
RED-HAT LINUX 6/7
7. Job Automation
Page 86
RED-HAT LINUX 6/7
Page 87
RED-HAT LINUX 6/7
Options Explanation
* Is treated as a wildcard. Meaning any possible value.
Is treated as every 5 minutes, hours, days or months. Replacing the 5 with
*/ 5
any numerical value will change this option.
Treated as an OR, so if placed in the hours, this could mean at 2, 4 or 6 o-
2, 4, 6
clock
Treats for any value between 9 and 17. So if placed in the day of the month.
9-17 this would be days 9 through 17 or if put in hours, it would be between
9 AM and 5 PM.
6. How to check the assigned cron jobs of the currently logged-in user?
# crontab -l -u <user name> (to check the specified
user's assigned cron jobs
# crontab -l -u raju (to check the raju user's)
assigned cron jobs
# crontab -l (to check the root user's
assigned cron jobs
7. How to allow or deny cron jobs for a user?
For allow For deny
(i) Open /etc/cron.allow file. (i) Open /etc/cron.deny file.
(ii) Put the entries of the user names (ii) Put the entries of the user names
whom do we whom do we
want to allow the cron jobs. want to deny the cron jobs.
Page 88
RED-HAT LINUX 6/7
(iii) If all the above are ok, then see whether the user who is executing
The cron job has permissions to execute the cron jobs or not i.e., check
the user entries in /etc/cron.allow and /etc/cron.deny files.
If all are ok, again put the job entry in crontab and execute it.
12. How to schedule the cron task or job?
(i) Open one shell script file.
(ii) Enter all the commands which are required to complete the task
or job.
(iii) If the job requires more CPU and more memory, then schedule
those jobs at night time or non-peak hours (generally night time is the
non-peak time.
(iv) Then open the crontab editor by # crontab -e <user name>
command and then put the entries as below,
<minutes><hours><day of the month><month of the year><day of
the week><script name with path>
(v) Save and exit from the crontab editor.
13. How to add an at job and delete the at job?
Adding :
(i) at <time> to enter the job
(ii) Before that, open a file in vim and enter the job commands in that.
file and save as xxxx.sh (some name with extension must be as .sh)
(iii) Enter the above saved file name within the at job editor.
(iv) Press Ctrl + d to exit from the editor.
(v) Then the system will assign a job ID to that job. We can see the list.
of at jobs by# atq command.
Delete :
(i) See the job id for the job we want to delete using the # atq command.
and note that job id.
(ii) Then delete that job by # at -r <job id> command.
14. How to know currently scheduled at jobs?
# atq (to see the currently scheduled at jobs)
15. How to allow or deny job access for a user?
For allow For deny
(i) Open /etc/at.allow file. (i) Open /etc/at.deny file.
(ii) Put the entries of the user names (ii) Put the entries of the user names
whom do we whom do we
want to allow the at jobs. want to deny the at jobs.
Page 89
RED-HAT LINUX 6/7
Page 90
RED-HAT LINUX 6/7
Page 91
RED-HAT LINUX 6/7
Page 92
RED-HAT LINUX 6/7
where 58 minutes
15 -----> 15 hours (at 15:58)
every day
58 */2 * * * <commands>
58 minutes
Every 2 hours
every day
(iv) 00 */2 * * * sync ; echo "---" >
/sys/class/scsi_hosts/host2/scan
(v) @reboot <mail command> (every reboot, one mail will
be sent to the root
(vi) @monthly <command> (every month the command will be
executed
(vii) @yearly <command> (every year the specified
command will be executed
(viii) @reboot /usr/sbin/ or /bin/sh /root/coss.sh (every reboot
the specified script file will be
executed
If the system is scheduled for a job, but at that time the system is
under down then anacroncommand is
responsible for those pending jobs to be executed.
# cat /etc/anacron is the configuration file for anacron jobs.
# anacron (anacron is used to execute the pending cron)
jobs
# vim /etc/rc.local (to execute the cron pending jobs)
automatically whenever the system is rebooted)
Open the above file and go to the last line and type as, anacronthen
save and exit this file to execute the pending jobs automatically whenever the
System is rebooted.
Page 93
RED-HAT LINUX 6/7
Page 94
RED-HAT LINUX 6/7
We cannot give the trusting in telnet. We can give the trusting in ssh.
(e) By snooping or sniffing technologies (e) By snooping or sniffing technologies
we can see we cannot
the data like system or hostname, see the data like system name or
login name hostname
password and other data. name, password and other data.
So, there is no security. So, there is a security
(f) # telnet <IP address of the remote
(f) # ssh<IP address of the remote system>
(provide login name and password)
(provide login name and password)
Page 95
RED-HAT LINUX 6/7
5. In how many ways can we connect to the remote host through ssh?
Through ssh we can connect to the remote host by two methods.
(i) Command Line Interface (CLI).
Example: # ssh <IP address of the remote system> (provide
login name and password
Graphical User Interface (GUI).
Open the VNS server window and provide remote access.
hostname, login name and password.
6. What are the requirements for ssh?
(i) Remote systems IP address.
(ii) Remote systems user name and password
(iii) A proper network i.e., our local and remote systems should be in the
same network.
(iv) Open ssh package to configure the ssh.
7. In how many ways can we connect to the remote system?
(i) telnet (ii) ssh
rlogin rcp
(v) ftp (vi) scp
sftp (viii) tftp
8. What is the syntax for ssh?
# ssh <IP address of the remote system> -l <user name>
# ssh <user name>@<IP address of the remote system>
ssh <user name>@<remote hostname with fully qualified domain>
name
After executing any of the above commands, it may ask for a user name.
and password. Then type user name and
passwords to connect the remote systems.
9. How to configure SSH with key-based authentication or explain the
ssh trusting?
(i) SSH key-based authentication is used to access the remote system.
without asking any passwords.
(ii) For that, first we have to generate the public and private keys by
executing# ssh-keygen command on our system. Then the public and
private keys are generated in /home/<user name>/.ssh location. ie., .ssh
directory in users home directory. And the keys are id_rsa(private key)
andid_rsa.pub(public key).
(iii) Then copy the public key id_rsa.pub on the remote system by
executing the below command.
# ssh-copy-id -i <user name>@<IP address of the
remote system
Page 96
RED-HAT LINUX 6/7
(iv) Go to the remote system and check whether the above key is copied.
or not by # cat /home/<user name>/.ssh/authorized_keys file. And the
The private key should be in our system.
(v) Whenever we are trying to establish a connection the public key on
remote system should be matched with the private key on our system.
Otherwise, no connection is established.
If both public and private keys are matched then connection will be
established and first time it will ask the password. Once the connection is
established, next time onwards it won't ask any passwords.
ssh <user name>@<remote hostname or IP address>
(first time it will ask for the password)
The authentication is done through the public and private keys, so
this type of authentication is called keybased authentication.
10. How to prevent remote login for the root user or how to configure it
SSH to prevent remote login for root?
(i) The location of the ssh configuration file is /etc/ssh/sshd_config
(ii) Open the configuration file by # vim /etc/ssh/sshd_config
-----> go to line no. 42(in RHEL - 6) or
-----> go to line no. 48(in RHEL - 7) PermitRootLogin yes
and uncomment that line and type as "no" in place of "yes" and save
exit this file.
(iii) Then restart or reload the sshd daemon by
# service sshd restart (to restart the sshd)
daemon or service in RHEL - 6)
# systemctl restart sshd (to restart the sshd
daemon or service in RHEL - 7)
# chkconfig sshd on (to enable the sshd
daemon at next reboot in RHEL - 6)
systemctl enable sshd (to enable the sshd daemon
at next reboot in RHEL - 7)
service sshd reload (to reload the sshd
daemon in RHEL - 6)
systemctl reload sshd (to reload the sshd daemon
in RHEL - 7)
(iv) Then no root user can access our system remotely through ssh
service.
11. How to allow the remote users to run GUI commands through ssh?
(i) Open the ssh configuration file by # vim /etc/ssh/sshd_config
-----> ve a la línea número 109 en RHEL - 6 o
-----> go to line no. 117 in RHEL - 7 X11 Forwarding no
Page 97
RED-HAT LINUX 6/7
Page 98
RED-HAT LINUX 6/7
Page 99
RED-HAT LINUX 6/7
Page 100
RED-HAT LINUX 6/7
Page 101
RED-HAT LINUX 6/7
Page 102
RED-HAT LINUX 6/7
user is there then check whether the client user's password is locked, account
expired and any other or not, if locked then remove the lock, if client account is
expired then activate that account, assign the password and make the
ssh trusting between client and server systems.
19. How to copy the file from our system to a remote system?
# scp <source file name with full path><IP address of the remote
system>:<destination location>
Example: ssh /root/script1 192.168.1.1:/root/script1 (to copy)
/root/script1 file into 192.168.1.1 system)
ssh -r /root/raju/ 192.168.1.1:/root/raju/ (to copy
/root/raju directory to remote system
scp means secure copy to copy the files or directories from local
system to remote system.
Page 103
RED-HAT LINUX 6/7
(i) If the user has sudo permissions, then log in as a sudo user.
(ii) If no sudo permissions then boot with CDROM in single user mode
and start the system. Then provide the root password to root user if there
there is no root password.
Even though if it is not possible then finally break the root password.
Page 104
RED-HAT LINUX 6/7
1. What is swap?
Swap space in Linux is used when the amount of physical memory
(RAM) is full. If the system needs more memory resources and the RAM is full,
Inactive pages in the memory are moved from RAM to swap space. It helps the
machines that have a small amount of RAM should not be considered
a replacement for more RAM. Swap is located on the hard disks which have
slower access time than Physical memory.
2. What is the recommended swap space?
Generally the recommended swap space is double the RAM size, but the
The following table shows the actual amount.
Apart from the below recommendation, a basic rule is applied to create
the swap partition.
If the RAM size is less than or equal to 2 GB, then the size of the swap
= 2 X RAM size.
If the RAM size is more than 2 GB, then the size of the swap = 2 GB +
RAM size.
Amount of RAM in the Recommended Amount of
System Swap Space
4 GB or less Min. 2 GB
4 GB - 16 GB Min. 4 GB
16 GB - 64 GB Min. 8 GB
64 GB - 256 GB Min. 16 GB
256 GB - 512 GB Min. 32 GB
Page 105
RED-HAT LINUX 6/7
Page 106
RED-HAT LINUX 6/7
Page 107
RED-HAT LINUX 6/7
Page 108
RED-HAT LINUX 6/7
First take a backup of all the system and then remove the previous one.
Reinstall the current operating system and restore the backup from
backup disks or tapes. So, it is very easy and non-risky job.
Page 109
RED-HAT LINUX 6/7
Page 110
RED-HAT LINUX 6/7
Page 111
RED-HAT LINUX 6/7
Page 112
RED-HAT LINUX 6/7
end tool for rpm. It is used to resolve the dependency that cannot be done by
rpm. The yum command has access to the repository where the packages are.
available and can install, update/upgrade, remove and query the packages
automatically.
9. What are the important files that are related to yum?
/etc/yum.conf-----> is the yum configuration file.
/etc/yum.repos.d -----> is the directory which contains the yum
repository configuration file.
is the yum repository
configuration file.
/var/lib/yum -----> is the directory which contains the yum
databases.
/var/log/yum.log-----> is the file which stores the yum log messages.
10. How to set up the yum server?
(i) Insert the RHEL DVD, go to that directory and install the vsftpd
package by # rpm -ivh vsftpd*
(ii) Go to /var/ftp/pubdirectory and create the rhel6 directory by # mkdir
rhel6
(iii) Go to the DVD mounted directory and copy all the DVD content into
/var/ftp/pub/rheldirectory by
# cp -rvpf /media/DVD/ /var/ftp/pub/rhel6
(iv) Restart the vsftpd service by # service vsftpd restart command.
(v) Then enable the vsftpd service by # chkconfig vsftpd on
command.
(vi) Go to /etc/yum.repos.directory and create one yum repository
file by # vim linux.repocommand.
(vii) In the above file the contents are as below,
linux (Linux repo id)
yum repo server (yum server name)
baseurl=file:///var/ftp/pub/rhel6 or baseurl=ftp://<IP
address of the system>/pub/rhel6
gpgcheck=0 (0 means during installation)
will not ask any signature keys of yum packages, If it is
1, then it will ask for the signature keys while installing the packages)
1 (if multiple repositories are
there, then enable this only
(save and exit this file)
(viii) # yum clean all (to clean the old one update)
the new repository
Page 113
RED-HAT LINUX 6/7
Page 114
RED-HAT LINUX 6/7
Page 115
RED-HAT LINUX 6/7
(a) For example, the monitoring team should ignore alerts from that.
server if the system hangs or rebooted.
(b) DBA team if database stopped or crashed or system failed.
(c) Application team if the application effects while patching.
(viii) If the server is in a cluster, then move the service group and resources
to another systems manually called switch over.
(ix) Inform the Application team to stop the application and
database team to stop the database.
(x) If the server is in a cluster, there is no need for a reboot (no downtime).
else down time needed to reboot.
(xi) Check if the root disk is in a normal file system or VxVM.
(xii) If a mirror disk is present, split the mirror disk from the original disk and boot.
in single user mode and add the patch by# rpm -ivh <patch name>
command.
(xiii) Then reboot the system and do not attach the mirror disk to avoid
any unexpected situations or problems and put that server under test
up to 1 week or 10 days depending on the company's policy.
(xiv) After the test period, if there are no problems raised then attach the
system in live mode and also with mirror disk to sync the data to
update the system.
(xv) Then we inform the Application, Database, Monitoring and other
teams who are dealing with that server to test application, database,
monitoring and others see the status.
(xvi) Then finally close the issue or CRQ.
17. After installation of the package or patch if the package or patch is
removed then what will happen?
(i) If the kernel patch is removed, then the system will hang and for
others there is no effect.
(ii) If the package is removed, then the application that belongs to that
removed package will effect.
18. Do we need to reboot the system after applying the patch or not?
(i) If the patch is a kernel patch or a clustered patch then only the
System reboot is required.
(ii) If the patch is a normal patch, then there is no need for a reboot.
required.
19. If the package is not installing. How to troubleshoot?
(i) Check the package pre-requisites to install the package.
(ii) If the pre-requisites do not match our system, then the
The package will not be installed due to operating system compatibility issues.
Page 116
RED-HAT LINUX 6/7
(iii) If there is no sufficient space in the system, the package will not be
installed.
If the package is not properly downloaded, then the package will not
be installed.
20. If the patch is not applied successfully what will you do?
(i) Check whether the patch is installed properly or not by # rpm
qa <patch name>command.
(ii) Check the /var/log/yum.log file to verify or see why the patch is not
successfully installed.
If it is possible to resolve those issues, resolve and remove that.
patch with # rpm -e <patch name> command.
(iv) If any reboots are required to take effect, then reboot the system.
(v) Again add that patch by # rpm -ivh <patch name> command.
(vi) Then check the patch by # rpm -qa <patch name> command
Page 117
RED-HAT LINUX 6/7
Page 118
RED-HAT LINUX 6/7
Page 119
RED-HAT LINUX 6/7
Examples:
# tar -cvf /root/etc.tar /etc/* (to copy all the files and
directories from /etc and make a single file
and place in the /root/etc.tar file)
# tar -tvf /root/etc/tar (to long listing the contents
of the /root/etc.tar file)
tar -xvf /root/etc.tar -C /root1/ (to extract and copy)
the files in /root1/ location
# tar -xf /root/etc.tar (to list the contents of the)
tar file
Page 120
RED-HAT LINUX 6/7
Page 121
RED-HAT LINUX 6/7
Page 122
RED-HAT LINUX 6/7
Page 123
RED-HAT LINUX 6/7
Page 124
RED-HAT LINUX 6/7
Taking a backup from the last full backup or last cumulative or differential
backup
12. Which file will update when backing up with the dump command?
/etc/dumpdatesfile will be updated when backing up with dump
command.
13. What are the dump devices?
(i) Tape drives
(ii) Disks (local disks)
(iii) Luns (network disks)
14. What is a snapshot?
(i) The point-in-time copy of the file system is called the snapshot.
(ii) It provides an online backup solution for the file system.
We can take a backup while the file system is mounted and it is in
multi-user mode.
(iv) It occupied only as much disk space as the file system ie., being
captured.
(v) We can also create backup, delete, query temporary (read-only)
snap shots using fssnap command.
15. What are the differences between tar and cpio commands?
(i) By tar we can take backup up to 80GB size of file systems, but
using cpio there is no limit.
(ii) In tar, the backup is in archive format, i.e., in compressed state.
but in cpio there is no compression.
(iii) In both types, only a full backup is possible.
16. How to take a backup on production servers?
(i) Normally in a backup environment we have 3 servers.
(a) Master server (production servers -- 1 or 2 units).
(b) Media server (backup server -- 1 or 2 units).
(c) Client server (Normal system)
(ii) Backups can be taken in types.
(a) Application Backup (Normally application users will take these
types of backups
File system Backup (O/S backup, System Administrators will
take these types of backups)
(c) Database Backup (DBA users will take these types of backups)
(iii) Normally backup is automated through some backup tools like
Veritas Net Backup, IBM Tivoli and Autosys.
(iv) Using the cron tool, we can also take backups. However, cron will not inform the
failed backup. The other tools will inform by sending messages like why the
Backup has failed, when and where it failed, etc.
Page 125
RED-HAT LINUX 6/7
Page 126
RED-HAT LINUX 6/7
Page 127
RED-HAT LINUX 6/7
Page 128
RED-HAT LINUX 6/7
If there are two chrony services in a system, we cannot start both services at the same time.
In these scenarios, we use mask and unmask commands.
mask sshd (to hide the sshd service
temporarily i.e., we cannot start the services
when we mask any service)
# systemctl unmask sshd (to unhide the sshd service)
i.e., we can start the service again)
We can also use RHEL - 6 commands like # service and #
chkconfig, but these two commands will
internally call the # systemctl commands only. So, in RHEL - 7 #
The systemctl command is the recommended
one.
# systemctl --failed --type=service to check all the failed
services)
# systemctl --failed --type=process (to check all the failed)
processes
In RHEL - 6 service names end with 'd' only, but in RHEL - 7 the
service names ends with d.service and these
are all text files only. So, in RHEL - 7 we can open and see all the system services
and read their contents.
(to see the active process in the system)
top It will show a dynamic real-time view of a running system.
i.e., a summary of processes or
threads currently managed by the Linux kernel
kill It sends the specified signal to the specified process or
process group)
pkill It will send the specified signal to each process instead of
listing them on standard output
# pstree (to show all the running processes as a tree structure.
The tree is rooted either pid or init)
nice to run a program with modified scheduling priority
i.e., it runs the process with an
adjustable niceness
renice to alter the scheduling priority of one or more
running processes
pgrep (to list the process id's which matches with the pgrep
argument
RHEL - 6 commands :
# service <service name> status (to check the status of)
the service)
Page 129
RED-HAT LINUX 6/7
Page 130
RED-HAT LINUX 6/7
Page 131
RED-HAT LINUX 6/7
Linux kernel is used to communicate with the processes by their process ID's
(PIDs). Daemon is a process running in the background. These are handled by
the system and process are handled by the users.
The first process in RHEL - 6 is init and it starts at boot time.
The process ID is 1, whereas in RHEL 7 the first process is systemd, and it starts.
at boot time. To manage or to see the processes there are two commands.
(i) ps and (ii) top
# ps :
It is just a snapshot of the current status of the processes. It gives only
one terminal information not all the terminals information.
top
Using the top command, we can monitor the processes continuously.
by default, it will refresh the data every 3 seconds.
2. How many processes are generally run on Linux and explain them?
There are generally three types of processes that run on Linux. They are,
(i) Interactive Processes
(ii) System Process or daemon
(iii) Automatic or batch.
Interactive Processes :
Interactive processes are those processes that are invoked by a user and
can interact with the user. For example # vi or # vim are the interactive
processes. Interactive processes may be run in foreground or background. The
The foreground process is the process that we are currently interacting with and is
using the terminal as its stdin (standard input) and stdout (standard output).
The background process is not interacting with the user and can be in one of
two states, i.e., paused or running.
System Processes or daemons:
Daemon refers to processes that are running on the computer and
provides services but do not interact with the console. Most server software is
implemented as a daemon. For example, Apache, Samba, sshd are the
deamons. Any process can become a daemon as long as it is run in the
background and does not interact with the user.
Automatic processes:
Automatic processes are not connected to a terminal and these are
queued into a spooler area where they wait to be executed on a FIFO (First In -
First Out) basis. Such tasks can be executed using one of two criteria.
At a certain date and time: done using the 'at' command.
When the total system load is low enough to accept extra jobs: done
using the "cron" command. By default, tasks are put in a queue where they
Page 132
RED-HAT LINUX 6/7
wait to be executed until the system load is lower than 0.8 and cron job
Processing is also used for optimizing system performance.
3. What is a parent process?
The process which starts or creates another process is called the
parent process. Every process will have a parent process except initd
process. The initd process is the parent process to all the remaining processes in
Linux system because it is the first process which gets started by the
kernel at the time of booting and its PID
is 1. Only after the initd process starts, the remaining processes are
called by it, and hence it is responsible for all the remaining processes in the
system. The parent process is identified by PPID (parent process ID).
4. What is a child process?
A process that is started or created by the parent process is called a child.
process and it is identified by PID.
Useful # ps commands :
# ps -a it displays all the terminal processes
information
# ps -au it displays all the terminal processes
information with user names
ps -aux it displays all the terminal processes
information including background
processes with user names
? (question mark) if it appears in the tty column, it indicates that it is a
background process.
# ps -ef it displays the total processes
information with parent process ID (PPID)
ps -P <process id> (it displays the process name if we know
the process ID (pid)
# pidof<process name> to see the process ID of the specified
process)
# pidof initd (to see the process ID of the initd
process
# pstree to display the parent and child
processes structure in tree format
# ps -u <user name> (to display all the processes of the)
specified user
# ps -u raju to display all the processes of the user
raju
# ps -G <group name> to display all the processes that are
running by a particular group
Page 133
RED-HAT LINUX 6/7
Page 134
RED-HAT LINUX 6/7
Page 135
RED-HAT LINUX 6/7
The processes which are running without parent processes are called orphan processes.
Orphan processes. Sometimes the parent process closes without the child knowing.
processes. But the child processes are running at that time. These child
Processes are called orphan processes.
9. What is a Zombie process?
When we start the parent process, it will start some child processes. After
Sometimes the child processes will die because they do not know the parent.
processes. These parent processes (which are running without child
Processes) are called Zambie processes. These are also called as defunct.
processes.
10. How to set the priority for a process?
Processes priority means managing processor time. The processor or
The CPU will perform multiple tasks at the same time. Sometimes we can have
enough room to take on multiple projects and sometimes we can only focus on
one thing at a time. Other times something important pops up and we want to
devote all of our energy into solving that problem while putting less important
tasks on the back burner.
In Linux we can set guidelines for the CPU to follow when it is looking at
all the tasks it has to do. These guidelines are called niceness or nice value.
The Linux niceness scale goes from -20 to 19. The lower the number the more
priority that task gets. If the niceness value is higher number like 19 the task
will be set to the lowest priority and the CPU will process it whenever it gets a
chance. The default nice value is 0.
By using this scale we can allocate our CPU resources more
appropriately. Lower priority programs that are not important can be set to a
higher nice value, while the higher priority programs like daemons and services
can be set to receive more of the CPU's focus. We can even give a specific user
a lower nice value for all his/her processes so we can limit their ability to slow
down the computer's core services.
There are two options to reduce/increase the value of a process. We can
either do it using the nice or renice commands.
Examples :
# nice -n <nice value range from -20 to 19><command> (to set a
priority to a process before starting it
nice -n 5 cat > raju (to set the
medium priority to cat command
# ps -elf (to check the nice)
value for that command)
To reschedule the nice value of existing process, first check the PID of
that process by # ps -elfcommand
Page 136
RED-HAT LINUX 6/7
and then change the niceness of that command by # renice <nice value (-20
to 19)>< PID > command.
renice 10 1560 (to reschedule)
the PID 1560)
11. What is the top command and what does it show?
topis a command to see the processes states and statuses information
continuously until we quit by pressing 'q'. By default, the top command will
refresh the data for every 3 seconds.
When we need to see the running processes on our Linux in real time, the
The top command will be very useful. Besides the running processes, the top
command also displays other information like free memory both physical and
swap.
The first line shows the current time, 'up 1 day' shows how long the
The system has been up for 3 users.
0.00, 0.23" the load average of the system 1, 5 and 15 minutes.
The second line shows the number of processes and their current states.
The third line shows CPU utilization details like % of the users processes.
% of the system processes, % of available CPU and % of CPU waiting time for
I/O (input and output).
The fourth and fifth lines show the total physical memory in the
system
memory
swap memory and cached swap memory, ... etc.,
From the sixth line onwards, the fields are as follows.
PID Process ID
USER Owner of the process i.e., which user executed that process
PR Dynamic Priority
NI Nice value, also known as base value
VIRT Virtual size of the task includes the size of processes executable
binary
RES The size of RAM currently consumed by the task and not included
the swap portion
SHR Shared memory area by two or more tasks
S Task Status
% CPU The % of CPU time dedicated to run the task and it is
dynamically changed
% MEM The % of memory currently consumed by the task
TIME+ The total CPU time the task has been used since it started.
sign means it is displayed with hundredth of a second
Page 137
RED-HAT LINUX 6/7
Page 138
RED-HAT LINUX 6/7
(ii) Then inform those users who executed that process though.
mail, message or raising the ticket.
If those users are not available or not responding to our mail then
we have to change the priority of that process using # renice
command.
(iv) Before changing the process priority level, we have to get or take
approval from our team lead or project manager.
13. How to check the WWN number of LUN?
(i) First install the sysutilspackage to execute the commands to know
the wwn number by executing command,
# yum install sysutils -y
(ii) # systool -c fs_host -v |grep "port-name" (to check
the wwn number
14. How to remove the page caches and other caches?
# sysnc ; echo 2 > /proc/sys/vm/drop_caches (to remove the)
page caches
# sysnc ; echo 3 > /proc/sys/vm/drop_caches (to remove all)
types of caches like dent cache,
page caches and others)
15. What is 'sosreport' and how to generate it?
Sosreport is a command in Linux (RHEL / CentOS) which collects system
configuration and diagnostic information of your linux box like running
kernel version, loaded modules, and system and service configuration files. This
command also runs external programs to collect further information, and
Stores this output in the resulting archive.
Sosreport is required when you open a case with Red Hat for
technical support. Redhat support Engineers will require sosreport of your
server for troubleshooting purpose.
To run sosreport, sospackage should be installed. Sos package is part of
default installation in most of linux. If for any reason this package is no
installed, then use the below yum command to install the sos package:
# yum install sos -y
Generate the sosreport:
Open the terminal and type sosreport command:
sosreport
This command will normally complete within a few minutes. Depending
on local configuration and the options specified in some cases the
The command may take longer to finish. Once completed, sosreport will generate a
compressed a file under /tmpfolder. Different versions use different
Page 139
RED-HAT LINUX 6/7
compression schemes (gz, bz2, or xz). The file should be provided to Redhat
support representative (normally as an attachment to an open case).
Note: sosreport requires root permissions to run.
Different Options used in sosreport command:
The sosreport command has a modular structure and allows the user to
enable and disable modules and specify module options via the command
line. To list available modules (plug-ins) use the following command:
# sosreport -l
To turn off a module, include it in a comma-separated list of modules
passed to the -n/–skip-plugins option. For instance to disable both
the kvmand and modules:
# sosreport -n kvm,amd
Individual modules may provide additional options that may be specified
via the-k option. For example on Red Hat Enterprise Linux 5 installations the
sos rpm module collects 'rpm -Va' output by default. As this may betime-
consuming the behaviour may be disabled via:
# sosreport -k rpm.rpmva=off
16. What is the command to see the complete information on virtual
memory?
vmstat is the command to get complete information on virtual
memory like number of processes, memory usage, paging memory
block I/O (input/output), traps, disk and CPU activity.
# vmstat 2 10 It will give the report for every 2
seconds up to 10 times)
The fields are, r how many waiting processes
b how many processes are busy
swapd how much virtual memory used
how much memory is freely available
buffer-----> how much temporary memory using
caching how much caching is still in use
swapin -----> how much data transferred from
RAM to swap
swapout how much data transferred from
swap to RAM
bi how much block input
bo how much block output
system in the number of interrupts
the number of contexts changed
# vmstat -a (to see the active and inactive processes)
# vmstat -d (to see the statistics of the disk used)
Page 140
RED-HAT LINUX 6/7
Page 141
RED-HAT LINUX 6/7
Page 142
RED-HAT LINUX 6/7
Page 143
RED-HAT LINUX 6/7
Before using the SAR utility, we should first install the SAR utility.
package by# yum install sysstat* -y command.
Examples :
sar 2 10 (It will give the system report for
every 2 seconds up to 10 times
# sar -p 2 10 to see the CPU utilization for
every 2 seconds up to 10 times
# sar -p ALL -f /var/log/sa/sa25 to check the CPU
utilization on 25th day of the current month
# sar -p ALL -f /var/log/sa/sa10 -s 07:00:00 -e 15:00:00 (to
check the CPU utilization on 10th day of the current
month from 7:00 to 15:00 hrs. where -s means start time -e end time)
# sar -r 2 10 (to see the memory utilization for
every 2 seconds up to 10 times
Page 144
RED-HAT LINUX 6/7
Page 145
RED-HAT LINUX 6/7
verification Transfer
Samba Connection Samba
138 445
Establishment Authentication
MySQL 3306 iSCSI 3260
Ping does not use any port number. It uses ICMP (Internet Control Message Protocol).
Message Protocol only.
Other useful commands :
uptime (to see how long the system has been running and also
gives the load average report
The load average has 3 fields. 1 - present status, 2 - 5 minutes
back and 3 - 15 minutes back.
# iostat 5 2 to monitor the input and output statistics
for every 5 seconds up to 10 times
# nproc (to check how many
how many processors (CPUs) are there in the system
top 1 to see the number of processors
There are CPUs in the system.
# iptraf to monitor the TCP or network traffic
statistics in graphical mode
Before using this command, install the iptraf package by # yum
install iptraf* -y command.
iftraf -ng -f eth0 to see the IP traffic
statistics in graphical mode
# lscpu (to see the no. of
CPUs present in the system
# lsusb (to see the number of USB)
devices present in the system
# lsblk (to see all the partitions or block
devices information
# cat /etc/redhat-release (to
see the RHEL version of system
# dmidecode (to see the complete)
hardware information of the system
# dmidecode -t memory (to see the
memory information of the system
# dmidecode -t bios (to see the)
system's bios information
# dmidecode -t system
(to see the system's information)
Page 146
RED-HAT LINUX 6/7
Page 147
RED-HAT LINUX 6/7
* When there are stopped jobs and you want to exit from the terminal
then, a warning message will be displayed. If we try again to exit from
the terminal, then the stopped or suspended jobs will be killed automatically.
Page 148
RED-HAT LINUX 6/7
Page 149
RED-HAT LINUX 6/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 --dport 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 --dport 20 -j ACCEPT
RHEL - 7 :
# firewall-cmd --permanent --add-service=ftp command in
RHEL - 7.
# firewall-cmd --complete-reload command in RHEL - 7.
8. How to configure the FTP client and how to connect to the FTP server?
(i) Go to the client machine and install the FTP and LFTP packages.
yum install ftp* lftp* -y
(ii) Connect the FTP server from client.
# ftp <FTP server IP address or server host name>
Example: # ftp 172.25.9.11 or ftp://server.example.com
ftp
Password : <press enter key>
ftp > ls (to see the files in the FTP
document root directory
We can also connect to the FTP server through the browser.
(i) Open the web browser and type in the address bar as,
ftp://172.25.9.11 or ftp://server.example.com
9. How to configure the Secure FTP server?
(i) Open the FTP configuration file by # vim
/etc/vsftpd/vsftpd.conf command.
(ii) Go to line no: 12 and type as, anonymous_enable=no (save
and exit the file)
yes (by default)
It means anybody can login to the FTP server without any
username and password.
If anonymous_enable=no, then we must provide the username
and passwords when it prompts.
(iii) Restart the ftp daemon by # service vsftpd restart command in
RHEL - 6 or
# systemctl restart vsftpd command in RHEL - 7.
Page 150
RED-HAT LINUX 6/7
(iv) Assign the FTP user password by # passwd ftp (type and
retype the ftp user password)
(v) Go to the client side and connect to the FTP server by # ftp
172.25.9.11 command.
10. How to configure the FTP server to enable the file upload feature?
(i) Open the FTP configuration file using vim
/etc/vsftpd/vdftpd.conf command.
(ii) Go to line no: 19 and type as, writable_enable=yes
(iii) Go to line no: 29 and type as, anon_upload_enable=yes
(save and exit the file)
(iv) Make the uploaddirectory in /var/ftp/pubdirectory by # mkdir
/var/ftp/pub/upload
(v) Change the group of the upload directory as ftp by# chgrp ftp
upload command.
(vi) Change the permissions of the upload directory by # chmod
775 upload command.
(vii) To permanently add the ftp service to SELinux policy by
getsebool -a | grep ftp (to check the
SELinux Booleans for FTP service
# setsebool -p allow_ftpd_anon_write on
# chcon -t public_content_rw_t upload (to add read-
write context of the upload directory
# setsebool -p ftp --full-access=1command or #
setenforce=0 command to disable the SELinux.
(viii) Restart the FTP daemon by # service vsftpd restart command
in RHEL - 6 or
# systemctl restart vsftpd command in RHEL - 7.
11. How to deny a specific system from using the FTP server?
(i) Open the /etc/hosts.deny file and add an entry for the system which
one to deny the ftp service.
# vim /etc/hosts.deny (go to the last line and type as
below
vsftpd : 172.25.9.10 (to deny 172.25.9.10)
system
vsftpd : ALL (to deny all the systems)
vsftpd : ALL EXCEPT *.example.com (to deny all the)
systems except example.com domain systems
save and exit the file
(ii) Restart the ftp daemon by # service vsftpd restart command in
RHEL - 6 or
Page 151
RED-HAT LINUX 6/7
(v) Restart the ftp daemon by the command # service vsftpd restart in
RHEL - 6 or
The # systemctl restart vsftpd command in RHEL - 7.
13. How to deny specific users access to the FTP services?
(i) Open the FTP users file by# vim /etc/vsftpd/ftpusers
command.
(ii) Enter the user names to deny FTP services. For example as
follows,
root
raju
great save and exit the file
(iii) Restart the FTP daemon using the # service vsftpd restart command.
RHEL - 6 or
The # systemctl restart vsftpd command in RHEL - 7.
14. What is LFTP and how to configure LFTP?
LFTP is also used to upload or download the files. But, by using LFTP
we can login to the FTP server without password because It will not ask any
passwords. To use LFTP we have to install the LFTP package on the server.
(i) Install the LFTP package by using the command # yum install lftp* -y.
Page 152
RED-HAT LINUX 6/7
Even though we changed the above, the root user cannot access the
FTP server because the home directory context is not added. We can solve this.
as follows.
(vi)# getsebool -a | grep ftp (to check the SELinux
Boolean of the root home directory
(vii)# setsebool -p ftp_home_dir on (to change the
Boolean of the root home directory
Now go to the client system and try to log in to the FTP server as the root user.
Here we can access the FTP server.
16. What is the difference between FTP and LFTP servers?
Page 153
RED-HAT LINUX 6/7
(i) The user name and password are required to access the FTP server
but LFTP does not require passwords.
(ii) In ftp> prompt the 'Tab' key will not work but in lftp>.
prompt the 'Tab' key will work as usual.
Other useful FTP Commands :
ftp 172.25.9.11 (to access the FTP server provide
FTP user name and password
ftp > ls (to see all the files and
directories in FTP root directory
ftp > !ls to see the local nothing
present working directory files
ftp > pwd to see the FTP present
working directory
ftp > !pwd (to see the local file)
system's present working directory
ftp > get <file name> (to download the specified
file
ftp > mget <file 1><file 2><file3> (to download multiple files)
at a time
ftp > cd /var/ftp/pub/upload (to move to upload)
directory)
ftp > put <file name> to upload the specified file
into the FTP upload directory)
ftp > lcd /root/Downloads (para cambiar a lo local)
/root/Download directory
ftp > help to get help about FTP
commands
ftp > bye or quit (to quit or exit from the
FTP server
lftp 172.25.9.11 (to access the LFTP server
without asking any passwords)
Page 154
RED-HAT LINUX 6/7
called mount points. After the NFS is mounted, all I/O operations are written
back to the server, and all the clients notice the change. A manual refresh is
not needed because the client accesses the remote file systems the same as local file
system because access does not require the IP address, user name and
password. However, we can provide security using Kerberos security.
2. What are the disadvantages of NFS?
NFS does not support cross platforms. That is, it will not support the
sharing the files between Linux and Windows systems.
(ii) NFS does not support encryption of the data and it supports only
plain text format.
(iii) NFS does not support TCP Wrappers, i.e., NFS does not support
/etc/hosts.allow and /etc/hosts.deny, because there is no libwrap.so
module is not loaded with NFS service.
(iv) NFS does not support authentication. So, to overcome this problem
Kerberos security system is used.
3. What is the profile of NFS?
Package : NFS*
Services : nfs (in RHEL - 6)
nfs-server, nfs-secure-server (nfs with
kerberos) (both for NFS server)
nfs-secure (for NFS client) (these three
services are in RHEL - 7)
Script : /etc/init.d/nfs
Port numbers : 2049 (for NFS server) and below 1024
(for NFS client)
Configuration Files : /etc/exports and
/etc/sysconfig/nfs
Other Important Files : /var/lib/nfs/etab and
/var/lib/nfs/rmtab
Versions : NFS - 3 (default in RHEL - 5) but it
supports NFS - 4
NFS - 4 (default in RHEL - 6) but It also
supports NFS - 3
NFS - 4 (default in RHEL - 7) but it also
supports NFS - 3
Protocol : UDP protocol
4. What are the background daemons for NFS and explain them?
There are 6 background daemons for NFS.
(i) rpc . mountd :
Page 155
RED-HAT LINUX 6/7
Page 156
RED-HAT LINUX 6/7
Indirect mount :
This method is used to mount the NFS share by using the Autofs service.
Autofs uses the automount daemon to manage our mount points by only
mounting them dynamically when they are accessed.
Autofs consults the master map configuration file /etc/auto.master to
determine which mount points are defined. It then starts an automount
process with the appropriate parameters for each mount point. Each line in the
The master map defines a mount point and a separate map file that defines the file.
systems to be mounted under this mount point. For example,
the /etc/auto.misc file might define mount points in the /mnt directory;
this relationship would be defined in the /etc/auto.master file.
Each entry in auto.master has three fields. The first field is the mount
point. The second field is the location of the map file, and the third field is
optional. The third field can contain information such as a timeout value.
For example, to mount the directory /product on the remote machine
server9.example.com at the mount point /mnt/nfs on your machine, add the
following line to auto.master:
/mnt /etc/auto.misc --timeout 60
Next, add the following line to /etc/auto.misc:
nfs -rw server9.example.com:/product
The first field in /etc/auto.misc is the name of the /mnt subdirectory.
This subdirectory is created dynamically by automount. It should not
actually exist on the client machine. The second field contains mount options
such as rw for read and write access. The third field is the location of the NFS
export including the hostname and directory.
The directory /mnt must exist on the local file system. There should be
no subdirectories on the local file system.
To start the autofs service, at a shell prompt, type the following
command:
service autofs restart
To view the active mount points, type the following command at a shell
Page 157
RED-HAT LINUX 6/7
(ii) Create the NFS shared directory on the server system by # mkdir
/publiccommand.
(iii) Modify the permissions of the /public directory by # chmod 777
/publiccommand. (These permissions
may be changed depending on its requirement
Modify the SELinux context of the /public directory if SELinux is
enabled by executing the below command. # chcon -t public_content_t
/public
(v) create some files in the /public directory by # touch f{1..10}
command.
Open the NFS configuration file and add an entry for the NFS.
shared information by # vim /etc/exports command and type as an entry like
<shared directory name> To whom to export the shared directory
sync
For example,
# vim /etc/exports
/public *.example.com (ro/rw, sync)
(save and exit the file)
Where *.example.com means the shared directory can be
exported to all the systems of the example.com domain.
* Permissions such as ro (read only) or rw (read & write) and sync
means the data will always be synced.
/public desktop9.example.com (rw,(to sync)
export the /public to desktop 5 system only
/public *.example.com (ro, sync) (export to the entire
example.com domain with read only
/public 172.25.0.0/24 (rw, sync) (export to
172.25.0.0 network only with read and write)
/public server [ 0 - 20 ].example.com (rw, sync)
(export to server0 to server20 in
example.com domain with read and write
/public 172.25.0.10 (rw, sync) export to
172.25.0.10 network only with read and write)
Common Mount permission options:
rw read/write permissions
ro read-only permissions
insecure Allows the use of ports over 1024
Page 158
RED-HAT LINUX 6/7
(vii) Export the above shared directory to the defined client systems by #
exportfs -rv command.
(viii) Restart the NFS services by following the commands in RHEL - 6
and RHEL - 7.
service rpcbind restart (to
restart the rpcbind service in RHEL - 6)
# service nfs restart (to
restart the NFS service in RHEL - 6)
# systemctl restart nfs-server (to restart
the NFS service in RHEL - 7)
(ix) Make the NFS service start automatically at the next boot.
onwards as follows.
# chkconfig rpcbind on (to on the
rpcbind service in RHEL - 6)
# chkconfig nfs on (to
on the nfs service in RHEL - 6)
enable nfs-server (to
enable the nfs-server in RHEL - 7)
(x) Exports the NFS shared directory as follows.
# exportfs -rv
Enable the NFS service to the IP tables and Firewall in RHEL - 6
and RHEL - 7 as follows.
In RHEL - 6 :
(i) # setup
(a) Select Firewall Configuration.
(b) Select Customize ( Make sure firewall option remain selected ).
(c) Select NFS4 (by pressing spacebar once).
(d) Select Forward and press Enter.
(e) Select eth0 and select the Close button and press Enter.
(f) Select ok and press Enter.
(g) Select Yes and press Enter.
(h) Select Quit and press Enter.
(ii) Now open /etc/sysconfig/iptables file and add the following
rules under the rule for port 2049 and save file.
Page 159
RED-HAT LINUX 6/7
In RHEL - 7 :
# firewall-cmd --permanent --add-service=nfs (to
Enable the NFS service in the firewall
# firewall-cmd --permanent --add-service=mountd
(to enable the mountd service at firewall)
# firewall-cmd --permanent -add-service=rpc-bind
(to enable the rpc-bind service at firewall)
# firewall-cmd --complete-reload (to
reload the firewall
8. What are the requirements for an NFS client?
(i) NFS server IP address or hostname.
(ii) Check the NFS shared name.
(iii) Create the local mount point.
Mount the NFS shared name on the local mount point.
(v) Go to the mount point (local mount point) and access the NFS.
shared data.
9. How to access the NFS shared directory from the client?
Page 160
RED-HAT LINUX 6/7
(i) On the client system, install the nfs-utils package using # yum
install nfs-utils* -ycommand.
(ii) Check the exported NFS shared directory by # showmount -e
<IP address or hostname of the server>
# showmount -e 172.25.9.11 or #
showmount -e server9.example.com
(iii) Create one mount point to mount the NFS shared directory by #
mkdir /<mount point> command.
Example: # mkdir /mnt/nfs
(iv) Mount the NFS shared directory on the above created mount
point.
# mount <IP address or server hostname> : <NFS
shared directory><mount point>
# mount 172.25.9.11:/public /mnt/nfs or
# mount server9.example.com:/public
/mnt/nfs
These are temporary mount only. ie., If the system is rebooted these
are unmounted automatically and we have to mount again after
the system is rebooted.
(v) So, if we want to mount it permanently, then open /etc/fstab
file and put an entry of the mount point.
# vim /etc/fstab (to open
the file
<IP address or server hostname> : <shared
name><mount point><file system> defaults 0 0
172.25.9.11:/public /mnt/nfs nfs defaults
0 0 ( or )
server9.example.com:/public /mnt/nfs nfs
defaults 0 0 (save and exit the file)
Mount all the mount points as mentioned in the above /etc/fstab
file by # mount -acommand.
(vii)# df -hT command is used to check all the mounted partitions
with file system types.
10. Why can't the root user create files in the NFS shared directory?
how to make him create the files?
The root user normally has all the permissions, but in NFS root user is
also becomes a normal user. So, the root user has no permissions to
create the files on the NFS shared directory.
The root user becomes nfsnobodyuser and group alsonfsnobody
due to root_squash permission is there by default. So, if we want to make
Page 161
RED-HAT LINUX 6/7
the root user to create file on the NFS shared directory, then go to server side
and open the /etc/exports file and type as below,
<shared name> <domain name or systems names>(permissions,
sync, no_root_squash
Example : /public *.example.com(rw, sync, no_root_squash)
(save and exit the file)
# exportfs -rv (to export the shared
directory
# service nfs restart to restart the NFS service
in RHEL - 6)
Restart the NFS server (to restart the NFS service
in RHEL - 7)
11. What are the disadvantages of direct or manual mounting?
(i) Manual mounting means we have to mount it manually, so it
creates so many problems. For example if NFS service is not available then,
# df -hT command will hang.
(ii) If the NFS server is down while booting the client, the client will
not boot because it searches for NFS mount point as an entry in /etc/fstab
file.
(iii) Another disadvantage of manual mounting is it consumes more
memory and CPU resources on the client system.
So, to overcome the above problems normally indirect or automount is
used using Autofs tool.
12. What is a secure NFS server and explain it?
Secure NFS server means NFS server with Kerberos security. It is used
to protect the NFS exports. Kerberos is an authentication tool to protect the
NFS server shares. It uses the krb5p method to protect by authentication.
mechanism and encrypt the data while communication.
For this one key file is required and this should be stored in each and
Every client that is accessing the NFS secure directory. Only then Kerberos.
security will be available. This key file should be stored in /etc/krb5.keytab file.
For example, the following command will download and store the keytab.
# wget http://classroom.example.com/pub/keytabs/server9.keytab -O
/etc/krb5.keytab (where O is capital)
13. How to configure the secure NFS server?
(i) Install the NFS package.
# yum install nfs* -y
(ii) Create a directory to share through NFS server.
# mkdir /securenfs
(iii) Modify the permissions of shared directory.
Page 162
RED-HAT LINUX 6/7
Page 163
RED-HAT LINUX 6/7
Page 164
RED-HAT LINUX 6/7
16. How to add the LDAP user shared directory and how the LDAP user
Access that directory on client?
(i) Create a sub-directory in /securenfs directory.
# create directory /securenfs/secure
(ii) Change the ownership of the above subdirectory to LDAP user.
# chown ldapuser9 /securenfs/secure
(iii) Assign the full permissions on that directory to the LDAP user.
setfacl -m u:ldapuser9:rwx /securenfs/secure
(iv) Change the SELinux context of that directory if SELinux is enabled.
# chcon -t public_content_t /securenfs/secure
(v) Re-export the secure NFS shared directory.
Page 165
RED-HAT LINUX 6/7
# exportfs -rv
(vi) Restart the NFS services.
# service nfs restart
restart the NFS service in RHEL - 6
# service nfs-secure-server restart (restart
the secure NFS service In RHEL - 6)
# systemctl restart nfs (restart
the NFS service In RHEL - 7)
restart nfs-secure (restart
the secure NFS service In RHEL - 7)
On Client side:
(i) Login as an LDAP user on the local system through SSH.
ssh ldapuser9@localhost (typeyes
and press Enter if it asks (yes/no)
(ii) Type the password askerberos if it asks the LDAP user
password.
Go to that secure NFS shared mount point and access the contents.
$ cd /mnt/nfssecure
(to access the mount point)
Command not translatable.
Page 166
RED-HAT LINUX 6/7
(i) First check if the user belongs to the same domain as the NFS shared.
or not. i.e., the user's system domain and NFS shared system domain should
communicate.
(ii) Check if the user's system is pinging or not.
Check whether the user's name is present, not present, or disabled to access.
the NFS server.
(iv) Check whether the mounted file system is shared or not.
(v) Check all the NFS server and client daemons are running or
not.
Check if all the network connections are properly established.
(vii) Check whether the NFS service is running or not in the server's current state.
run level.
Check whether the NFS server is running, hung, or shutdown.
(ix) Check both NFS server and NFS client systems network routers,
network connections and IP addresses.
(x) Check whether the mount point is correct or not, and if the paths are correct.
not and files are there or not.
(xi) Check the NFS shared directory and mount point details are
correct or not in /etc/fstab file.
(xii) Check that the keytabs are downloaded and stored properly in
/etc/krb5.keytabfile on both NFS server and client.
(xii) Finally check whether the NFS port no. 2049 is running or not and
make sure that the IP tables or firewall should not block the NFS
service.
19. NFS server and NFS client configurations are OK, but at client it is not.
showing anything. How to resolve?
(i) The rpcbind may have failed.
(ii) The server is not responding.
NFS client may fail at reboot.
The NFS service is not responding.
The daemons on both systems may not be running.
The network may have failed on both the server and client or on either one.
system.
(vii) The server and client may not be in the same domain or not.
pinging.
(viii) The server may be in hung or shutdown state.
20. What is Autofs?
Autofs is a service that can automatically mount the shared directory on
demand and will automatically unmount the shared directory if it is not
Page 167
RED-HAT LINUX 6/7
accessed within the specified timeout period. The default timeout period is 5
minutes or we can specify the timeout period in /etc/auto.masterfile.
21. What are the advantages of the Autofs?
(i) Shares are accessed automatically and transparently when a user
tries to access any files or directories under the designated mount point of the
remote file system to be mounted.
(ii) Booting time is significantly reduced because no mounting is done.
at boot time.
Network access and efficiency are improved by reducing the number
of permanently active mount points.
(iv) Failed mount requests can be reduced by designating alternate
servers as the source of a file system.
(v) Users do not need to have root privileges to mount or unmount
the mount point.
(vi) We can reduce the CPU and memory utilizations because autofs will
not mount permanently.
(vii) We can also reduce hard disk utilization because of permanent mount
Points occupy the hard disk space.
22. What are the minimum requirements for Autofs?
(i) autofspackage.
(ii) autofsdeamon.
(iii) One shared directory.
One mount point.
Two configuration files are,
/etc/auto.master
(b) /etc/auto.misc
23. How to configure Autofs?
(i) Install the autofs package by # yum install autofs* -y
command.
(ii) Open /etc/auto.master file by # vim /etc/auto.master and
at last type as below.
< Client's local mount point> /etc/auto.misc --
timeout=60
Example :
/mnt /etc/auto.misc
save and exit this file
( * Where timeout=60 means, if the directory is not used for 60
seconds then the shared directory is unmounted automatically.
And the default is 5 minutes.
Page 168
RED-HAT LINUX 6/7
Page 169
RED-HAT LINUX 6/7
Page 170
RED-HAT LINUX 6/7
http://classroom.example.com:/pub/example-ca.crt
LDAP Password
(then click on the Apply button)
(v) Check whether the LDAP user is configured or not by # getent
password ldapuser9 command.
29. How to automatically mount the LDAP user's home directory when
demand using Autofs tool?
(i) Install the autofs package by # yum install autofs* -y
command.
(ii) Open the /etc/auto.master file by# vim /etc/auto.master
command and type as below.
/home/guests /etc/auto.misc
(save and exit this file)
(iii) Open the /etc/auto.misc file by # vim /etc/auto.misc command
and type as below.
ldapuesr9 -rw
classroom.example.com:/home/guests/ldapuser9(save and exit this
file)
(iv) Restart the autofs services.
# service autofs restart (restart the autofs)
service in RHEL - 6)
# chkconfig autofs on enable the
autofs service at next boot in RHEL - 6)
# systemctl restart autofs (restart the
autofs service in RHEL - 7)
Page 171
RED-HAT LINUX 6/7
Page 172
RED-HAT LINUX 6/7
Page 173
RED-HAT LINUX 6/7
Page 174
RED-HAT LINUX 6/7
Go to the last line and copy the last 7 lines and paste them at
last. And then modify as below.
samba
(this is the samba shared name)
public stuff
(this is a comment for samba)
/samba
(share directory name with full path) yes
(means no authentication)
no (means
requires authentication)
yes
(in read-write mode)
no (in
read only mode
no
(printing is not available)
yes
printing is available
write list = raju (to
Give write permission to user raju.
= + <group name> (to
give the write permission to the group
raju, u2 or @group 1, @group 2 (to
give the authentication to the users or groups
hosts allow = IP 1 or IP 2 or host 1 or host 2 or <host
network ID> or <host network ID> (to share
the directory to IP 1 or IP 2 or host 1 or host 2
<windows work group name> (to
share the directory to the windows work group
create mask = 644 (the files created
by samba users with 644 permission)
directory mask = 744 or 755 (the directories created
by samba users with 744 or 755 permissions)
(save and exit the configuration file)
(viii) Verify the configuration file for syntax errors by # testparm
command.
Restart the samba daemons in RHEL - 6 and RHEL - 7.
# service smbd nmbd restart to
restart the samba services in RHEL - 6)
Page 175
RED-HAT LINUX 6/7
Page 176
RED-HAT LINUX 6/7
(ii) Put an entry of the mount point details in the /etc/fstab file.
# vim /etc/fstab
//<samba server host name or IP address>/<shared
directory name><mount point> cifs defaults,
<samba user name>
//server9.example.com/samba /mnt/samba
cifs defaults, username=raju,
<samba password> 0 0 (save and exit this file)
Mount all the mount points which are having entries in /etc/fstab
file.
# mount -a
(iv) Check all the mount points by # df -hT command.
8. How to mount the samba shared directory using credential file?
(i) Create one file and put entries of the user name and password
details.
# vim /root/smbuser
raju
<user's samba password>
save and exit the file
(ii) Open the /etc/fstab file and add an entry for the above credentials.
details of user.
# vim /etc/fstab
//server9.example.com/samba /mnt/samba cifs
/root/smbuser, multiuser, sec=ntlmssp
0 0
(save and exit this file)
9. How to access the samba share directory if it is already mounted?
(i) Go to Client system and switch to samba user.
su - raju
Page 177
RED-HAT LINUX 6/7
$ cd /mnt/samba
$ ls permission
denied message will be displayed
$ cifscreds add <host name or IP address of the samba
(to add CIFS credentials to the server)
$ ls (to see the
contents of the samba shared directory
10. How to access the Samba server from a Windows system?
(i) Go to the Windows system, click on the START button, click on Run and
type as\172.25.9.11\sambacommand.
(ii) Then provide samba user name and password if it prompts us.
(iii) Then see the contents of the samba shared directory.
Other useful commands :
# smbpasswd -a <user name> (to add the)
samba password to the samba user)
# smbpasswd -d <user name> (to
disable the samba user's password
# smbpasswd -e <user name> (to
Enable the Samba user's password
# smbpasswd -r <user name> (to
remove the samba user's password)
# smbpasswd -x <user name> (to delete
the samba user's password)
# smbpasswd -n <user name> (to set
the samba user's password as null
# findsmb (to check how many samba)
servers are running in our network
pdbedit (to check the available samba)
users who are accessing currently
smbstatus (to check how many smb clients are)
connected to the samba server
# mount -t cifs //<host name or IP address of the samba
server>/<shared directory><mount point> -o
<user name> (to mount the samba share directory on
local mount point temporarily
# mount -t cifs //172.25.9.11/samba /mnt/samba -o
raju
Page 178
RED-HAT LINUX 6/7
Page 179
RED-HAT LINUX 6/7
Page 180
RED-HAT LINUX 6/7
Page 181
RED-HAT LINUX 6/7
(ii) Name Server: The Name Server is the service running in the server.
that responds to the DNS query generated by
the resolver i.e. answers to the question of the resolver.
The working DNS :
(i) The client initiates a query to find a domain example.com.
client sends the query to the DNS server of the ISP. (The DNS Server IP
The IP address of the ISP's DNS Server is set on the client computer.
(ii) The ISP's DNS server first checks its own cache to check
whether it already knows the answer. But as the answer is not
present, it generates another query. As the Top Level Domain of example.com
is.com, so the DNS server queries the Internet Registration
Authority to find who is responsible for example.com.
(iii) The Internet Registration Authority responds to the ISP by
answering the query.
(iv) Once the ISP DNS Server knows the authoritative name servers, it
contacts the authoritative name servers to find out the IP address
forwww.example.comi.e. the IP address of hostwww in the domain
example.com. (v) example.com responds to the ISP DNS Server by
answering the query and providing the IP address of the web server
i.e. www
(vi) The ISP DNS Server stores the answer in its cache for future use and
answers to the client by sending the IP address of the www server.
(vii) The client may store the answer to the DNS query in its own cache
for future use. Then the client communicates directly with
the www server of domainexample.com using the IP address.
(viii) The www server responds by sending the index.html page.
3. What is the format of the domain name?
Like a physical address, internet domain names are a hierarchical way.
the Fully Qualified Domain Name is www.google.co.in, the www is the
Hostname, google is the Domain, co is the Second Level Domain and in
is the Top Level Domain.
4. What are the files we have to edit to configure the DNS?
There are four files to edit to configure the DNS. They are
/etc/named.conf, /etc/named.rfc1912.zones Forward Lookup Zoneand
Reverse Lookup Zone. DNS provides a centralized database for resolution.
Zone
It is a storage database that contains all the records.
Forward Lookup Zone is used to resolve Hostnames to IP addresses.
Reverse Lookup Zone is used to resolve IP addresses to Hostnames.
5. What are DNS records and explain them?
Page 182
RED-HAT LINUX 6/7
Page 183
RED-HAT LINUX 6/7
Page 184
RED-HAT LINUX 6/7
Page 185
RED-HAT LINUX 6/7
client10.example.com. IN A 172.25.9.12
client11.example.com. IN A 172.25.9.13
www IN CNAME server9.example.com.
(save and exit this file)
(v) Copy /var/named/named.emptyfile to
/var/named/named.reverseand edit as follows.
# cp -p /var/named/named.empty
/var/named/named.reverse
# vim /var/named/named.reverse
* Go to line number 2 and edit as follows.
@ IN SOA <DNS server fully qualified domain name>.
with root . <domain name> {.
* Go to line number 8 and edit as follows.
NS <DNS server fully qualified domain name>.
<Last octet of the DNS server IP address> IN PTR <DNS
server fully qualified domain name
Last octet of the Client 1 IP address IN PTR <Client 1
fully qualified domain name
Last octet of the Client 2 IP address IN PTR <Client 2
fully qualified domain name
Last octet of the Client 3 IP address IN PTR <Client 3
fully qualified domain name
DNS server fully qualified domain name IN A
<DNS server IP address>
www IN CNAMEFully Qualified DNS Server
domain name
The line number 2 should be edited as follows.
@ IN SOA server9.example.com. root.example.com. {
The line number 8 should be edited as follows.
NS server9.example.com.
11 IN PTR server9.example.com.
10 IN PTR client9.example.com.
12 IN PTR client10.example.com.
13 IN PTR client11.example.com.
server9.example.com. IN A 172.25.9.11
www IN CNAME server9.example.com.
(save and exit this file)
(vi) Check the DNS configuration files for syntax errors.
# named-checkconf /etc/named.conf
# named-checkconf /etc/named.rfc1912.zones
Page 186
RED-HAT LINUX 6/7
Page 187
RED-HAT LINUX 6/7
Page 188
RED-HAT LINUX 6/7
Page 189
RED-HAT LINUX 6/7
Page 190
RED-HAT LINUX 6/7
Page 191
RED-HAT LINUX 6/7
Page 192
RED-HAT LINUX 6/7
Page 193
RED-HAT LINUX 6/7
Page 194
RED-HAT LINUX 6/7
Page 195
RED-HAT LINUX 6/7
Page 196
RED-HAT LINUX 6/7
(ii) The router directs the DISCOVER packet to the correct DHCP
server.
(iii) The server receives the DISCOVER packet. Based on availability and
Usage policies set on the server, the server determines an appropriate
address (if any) to give to the client. The server then temporarily reserves
that address for the client and sends back to the client an OFFER
orDHCP OFFER packet with that address information. The server also
configures the client's DNS servers, WINS servers, NTP servers and
sometimes other services also.
(iv) Then the Client sends a DHCP REQUEST packet,
letting the server know that it intends to Use the address.
(v) Then the server sends an ACK or DHCP ACK packet,
confirming that the client has been given a lease on the address for a server
specified period of time.
3. What is the disadvantage of assigning a Static IP address?
When a system uses a static IP address, it means that the system is
manually configured to use a specific IP address. One problem with static
assignment, which can result from user error or inattention to detail, occurs
when two systems are configured with the same IP address. This creates a
conflict that results in loss of service. Using DHCP to dynamically assign IP
addresses to avoid these conflicts.
4. What is the profile of DHCP?
Package : dhcp*
Script file : /etc/init.d/dhcpd
Configuration file : /etc/dhcp/dhcpd.conf
Daemon : dhcpd
Port numbers : 67 (DHCP server) and 68 (DHCP client)
Log messages : /var/log/messages
Page 197
RED-HAT LINUX 6/7
Page 198
RED-HAT LINUX 6/7
Page 199
RED-HAT LINUX 6/7
dhclient
ifdown eth0
ifup eth0
7. How to assign a fixed IP address to the client every time it requests or how to
configure the MAC binding?
The process of assigning the same IP address (fixed IP address) to
The DHCP client every time it booted is called 'MAC binding'.
(i) Open the file /etc/dhcp/dhcpd.conf by # vim
/etc/dhcp/dhcpd.confcommand.
Go to line number 76 and 77 and edit those lines as below.
host <dhcp client hostname> {
hardware ethernet MAC address of the Client's NIC
card;
fixed addresses <IP address>;
}
Example :
host client 1 {
hardware ethernet 2015:ac18::55;
fixed addresses 172.25.9.150;
}
(save and exit this file)
(ii) Restart the DHCP services in RHEL - 6 and RHEL -
# service dhcpd restart (to restart the)
DHCP service in RHEL - 6)
# Enable dhcpd in chkconfig (to enable the
DHCP service at next boot in RHEL - 6)
# systemctl restart dhcpd (to
restart the DHCP service in RHEL - 7)
# systemctl enable dhcpd (to enable the
DHCP service at next boot in RHEL - 7)
Then the above MAC address of the system will get the same IP.
address every time it booted.
Page 200
RED-HAT LINUX 6/7
A computer that runs a Website. Using the HTTP protocol, the Web
server delivers Web pages to browsers as well as other data files to Web-
based applications. The Web server includes the hardware, operating system,
Web server software, TCP/IP protocols and site content (Web pages,
images and other files). If the Web server is used internally and is not exposed
to the public, it is an 'intranet server' and if the Web server is used in the
If it is connected to the internet and is exposed to the public, it is an Internet server.
2. What is Protocol?
A uniform set of rules that enable two devices to connect and transmit
the data to one another. Protocols determine how data are transmitted
between computing devices and over networks. They define issues such as
error control and data compression methods. The protocol determines the
following type of error checking to be used, data compression method (if
any), how the sending device will indicate that it has finished a message
and how the receiving device will indicate that it has received the message.
Internet protocols include TCP/IP (Transmission Control Protocol /
Internet Protocol), HTTP (Hyper Text Transfer Protocol), FTP (File Transfer
Protocol) and SMTP (Simple Mail Transfer Protocol).
3. How a Web server works?
(i) If the user types a URL in his browser's address bar, the browser
will splits that URL into a number of separate parts including
address, path name and protocol.
(ii) A DNS (Domain Naming Server) translates the domain name the
user has entered into its IP address, a numeric combination that
represents the site's true address on the internet.
(iii) The browser now determines which protocol (rules and regulations
which the client machine used to communicate with servers)
should be used. For example FTP (File Transfer Protocol) and HTTP (Hyper
Text Transfer Protocol).
(iv) The server sends a GET request to the Web Server to retrieve the
address it has been given. For example when a user types
http://www.example.com/Myphoto.jpg , the browser sends aGET
Myphoto.jpg command to example.com server and waits
for a response. The server now responds to the browser's
requests. It verifies that the given address exists, finds the necessary files, runs
the appropriate scripts, exchanges cookies if necessary and returns
the results back to the browser. If it cannot locate the file, the
The server sends an error message to the client.
(v) Then the browser translates the data it has been given into HTML
and displays the results to the user.
Page 201
RED-HAT LINUX 6/7
Page 202
RED-HAT LINUX 6/7
(d) Start the web server and enable web server service at next boot.
# start httpd service (to start the
webserver daemon in RHEL - 6)
# chkconfig httpd on (to enable
the service at next boot in RHEL - 6)
# systemctl restart httpd (to start
the webserver daemon in RHEL - 7
# systemctl enable httpd (to enable
the service at next boot in RHEL - 7)
Open the browser and access the web server document.
firefox (to
open the firefox browser
Then in the address bar type as http://localhost/manualand
press Enter key.
8. How to configure the IP based virtual host Web server?
(a) First assign the static IP address and hostname to the server.
(b) Check whether the server package by# rpm -qa httpd*
command.
(c) If not installed, install the web server package by # yum install
httpd* -y command.
(d) Check the configuration file to configure the http web server by #
rpm -qac httpd command.
(e) If required, open the web server document by # rpm -qad httpd
command.
(f) Go to the configuration file directory by# cd /etc/httpd/conf.d
Create the configuration for IP based hosting.
# vim /etc/httpd/conf.d/ip.conf
<VirtualHost <IP address of the web server> : 80>
ServerAdmin root@<hostname of the web server>
ServerName <hostname of the web server>
DocumentRoot /var/www/html
</VirtualHost>
/var/www/html
AllowOverride none
Require All Granted
</Directory>
(save and exit this file)
Example:
Page 203
RED-HAT LINUX 6/7
# vim /etc/httpd/conf.d/ip.conf
create the configuration file
<VirtualHost 172.25.9.11:80>
ServerAdmin root@server9.example.com
ServerName server9.example.com
DocumentRoot /var/www/html
</VirtualHost>
<Directory "/var/www/html">
AllowOverride none
Require All Granted
</Directory>
(h) Go to document root directory and create the index.html file.
# cd /var/www/html
# vim index.html
<html>
Page 204
RED-HAT LINUX 6/7
# firewall-cmd --complete-reload
(k) Go to client system, open the firefox browser and type as
http://server9.example.com in the address bar and check the index page.
displayed or not.
(l) We can also access the website using the elinksCLI tool.
# yum install elinks* -y
(install the elinks package)
# elinks --dump server9.example.com
(access the index page)
9. How to configure the name based web hosting?
Make a directory for virtual or named based hosting.
# create directory /var/www/virtual
(b) Go to the configuration file directory by # cd /etc/httpd/conf.d
(c) Create the configuration for name based hosting.
# vim /etc/httpd/conf.d/virtual.conf
<VirtualHost <IP address of the web server> : 80>
ServerAdmin root@<hostname of the web server>
ServerName <virtual hostname of the web server>
DocumentRoot /var/www/virtual
</VirtualHost>
<Directory "/var/www/virtual">
AllowOverride none
Require All Granted
</Directory>
(save and exit this file)
Example :
# vim /etc/httpd/conf.d/virtual.conf
create the configuration file
<VirtualHost 172.25.9.11:80>
ServerAdmin root@server9.example.com
ServerName www9.example.com
DocumentRoot /var/www/virtual
</VirtualHost>
<Directory "/var/www/virtual">
AllowOverride none
Require All Granted
</Directory>
Page 205
RED-HAT LINUX 6/7
(d) Go to the named based virtual directory and create the index.html
file.
# cd /var/www/virtual
# vim index.html
<html>
<H1>
This is Name based Web Hosting
Page 206
RED-HAT LINUX 6/7
# mkdir /var/www/port
(b) Go to the configuration file directory by # cd /etc/httpd/conf.d
(c) Create the configuration for port based hosting.
# vim /etc/httpd/conf.d/port.conf
<VirtualHost <IP address of the web server> : 8999>
ServerAdmin root@<hostname of the web server>
ServerName <port based hostname of the web server>
DocumentRoot /var/www/port
</VirtualHost>
<Directory "/var/www/port">
AllowOverride none
Require All Granted
</Directory>
(save and exit this file)
Example :
# vim /etc/httpd/conf.d/virtual.conf
create the configuration file
<VirtualHost 172.25.9.11:8999>
ServerAdmin root@server9.example.com
ServerName port9.example.com
DocumentRoot /var/www/port
</VirtualHost>
<Directory "/var/www/port">
AllowOverride none
Require All Granted
</Directory>
(d) Go to port based virtual directory and create the index.html file.
# cd /var/www/port
# vim index.html
<html>
<H1>
This is Port based Web Hosting
</html>
(save and exit this file)
(e) Generally, port-based web hosting requires a DNS server. So, we
can solve this problem by the following way.
Page 207
RED-HAT LINUX 6/7
For that open the /etc/hosts file and enter the server name
and IP addresses on both server and client.
# vim /etc/hosts
172.25.9.11 port5.example.com
(save and exit this file)
(f) By default the web server runs on port number 80. If we want to
configure on a different port number, we have to add the port number
in the main configuration file.
# vim /etc/httpd/conf/httpd.conf
Go to Listen: line 80 and open a new line below this line
and type as,
Listen: 8999
(save and exit this file)
(g) By default, SELinux will allow port numbers 80 and 8080 only for
webserver. If we use different port numbers other than 80 or
8080 then execute the following command.
# semanage port -a -t http_port_t -p tcp 8999
(h) Restart the web server daemon.
# start httpd service (to start
the webserver daemon in RHEL - 6)
# chkconfig httpd on (to enable
the service at next boot in RHEL - 6)
# systemctl restart httpd (to start
the webserver daemon in RHEL - 7
# systemctl enable httpd (to enable
the service at next boot in RHEL - 7)
(i) Add the service to the IP tables and firewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deport 8999
-j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deport
8999 -j ACCEPT
# service iptables save
# service iptables restart
In RHEL - 7 :
# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-port=8999/tcp
firewall-cmd --complete-reload
Page 208
RED-HAT LINUX 6/7
(j) Go to the client system, open the Firefox browser, and type as
http://port9.example.com in the address bar and check the index page is
displayed or not.
(k) We can also access the website using the elinksCLI tool.
# yum install elinks* -y
install the elinks package
elinks --dump port9.example.com
(access the index page)
11. How to configure user authentication based web hosting?
It will ask for a username and password to access this website. So, we have
to provide http password.
(f) Go to the configuration file directory by # cd /etc/httpd/conf.d
Create the configuration for user authentication based hosting.
# vim /etc/httpd/conf.d/userbase.conf
<VirtualHost <IP address of the web server> : 80>
ServerAdmin root@<hostname of the web server>
ServerName <hostname of the web server>
DocumentRoot /var/www/html
</VirtualHost>
<Directory "/var/www/html">
AllowOverride none
Require All Granted
AuthType Basic
AuthName "This site is protected"
AuthUserFile /etc/httpd/pass
Require User <user name>
</Directory>
(save and exit this file)
Example :
# vim /etc/httpd/conf.d/userbase.conf
create the configuration file
<VirtualHost 172.25.9.11:80>
ServerAdmin root@server9.example.com
ServerName server9.example.com
DocumentRoot /var/www/html
</VirtualHost>
<Directory "/var/www/html">
AllowOverride none
Page 209
RED-HAT LINUX 6/7
</html>
(save and exit this file)
(i) Restart the web server daemon.
# service httpd start (to start
the web server daemon in RHEL - 6
# chkconfig httpd on (to enable
the service at next boot in RHEL - 6)
# systemctl restart httpd (to start
the webserver daemon in RHEL - 7
# systemctl enable httpd (to enable
the service at next boot in RHEL - 7)
(j) Add the service to the IP tables and firewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deport 80 -j
ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deport 80
-j ACCEPT
service iptables save
# service iptables restart
In RHEL - 7 :
# firewall-cmd --permanent --add-service=http
# firewall-cmd --complete-reload
(k) Create the user and assign the HTTP password.
# useradd raju
Don't give the normal password because this user requires the
http password.
# htpasswd -c m /etc/httpd/pass <user name>
Page 210
RED-HAT LINUX 6/7
<Directory "/var/www/html">
AllowOverride none
Require All Granted
Order Allow, Deny
Allow from 172.25.9.0 or 172.25.0 (allows 172.25.9 network)
or 172.25 network to access the websites)
Deny from .my133t.org (deny all the systems of
*.my133t.org domain to access the websites)
</Directory>
13. How to Redirect the website?
* Redirecting means whenever we access the website, it redirects to
another website.
(a) Go to the configuration file directory by # cd /etc/httpd/conf.d
(b) Create the configuration for redirect-based hosting.
# vim /etc/httpd/conf.d/redirect.conf
<VirtualHost 172.25.9.11:80>
ServerAdmin root@server9.example.com
ServerName server9.example.com
DocumentRoot /var/www/html
Page 211
RED-HAT LINUX 6/7
Redirect / "http://www.google.com"
</VirtualHost>
<Directory "/var/www/html">
AllowOverride none
Require All Granted
</Directory>
save and exit this file
(c) Go to the document root directory and create the index.html file.
# cd /var/www/html
# vim index.html
<html>
<H1>
This is Redirect based Web Hosting
</H1>
</html>
save and exit this file
Restart the web server daemon.
# start httpd service (to start
the webserver daemon in RHEL - 6
# chkconfig httpd on (to enable
the service at next boot in RHEL - 6)
# systemctl restart httpd (to start
the webserver daemon in RHEL - 7)
Enable httpd to enable
the service at next boot in RHEL - 7)
(e) Add the service to the IP tables and firewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deport 80 -j
ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deport 80
-j ACCEPT
# service iptables save
# service iptables restart
In RHEL - 7 :
firewall-cmd --permanent --add-service=http
firewall-cmd --complete-reload
Page 212
RED-HAT LINUX 6/7
<Directory "/var/www/html/private">
AllowOverride none
Require All Granted
</Directory>
(save and exit this file)
(c) Create private directory in /var/www/html.
# create directory /var/www/html/private
(c) Go to the document root private directory and create the index.html
file.
# cd /var/www/html/private
# vim index.html
<html>
<H1>
This is Alias based Web Hosting
</html>
(save and exit this file)
Restart the web server daemon.
# start httpd service (to start
the webserver daemon in RHEL - 6
Page 213
RED-HAT LINUX 6/7
<Directory "/var/www/html/confidential">
AllowOverride none
Require All Granted
</Directory>
(save and exit this file)
Page 214
RED-HAT LINUX 6/7
</html>
(save and exit this file)
Restart the web server daemon.
# service httpd start (to start
the webserver daemon in RHEL - 6)
# chkconfig httpd on (to enable
the service at next boot in RHEL - 6)
# systemctl restart httpd (to start
the webserver daemon in RHEL - 7)
enable httpd (to enable
the service at next boot in RHEL - 7)
(e) Add the service to the IP tables and firewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deport 80 -j
ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deport 80
-j ACCEPT
# service iptables save
# service iptables restart
In RHEL - 7 :
# firewall-cmd --permanent --add-service=http
# firewall-cmd --complete-reload
(f) Go to the client system, open the Firefox browser and type as
The provided text appears to be a URL and does not contain translatable content.bar and check the
address
Whether the directory-based web page is displayed or not.
(g) We can also access the website using the elinksCLI tool.
# yum install elinks* -y
(instalar el paquete elinks)
# elinks --dump server9.example.com/confidential
(access the index page)
Page 215
RED-HAT LINUX 6/7
16. How to configure the web server to display the user-defined home page
not the index.html page?
Normally, Apache will look for index.html as the default home page.
If the name changed, it will display the home page without configuring that one.
For that we can do the above as follows.
(i) Go to the configuration file directory by # cd /etc/httpd/conf.d
command.
(ii) Create a userpage configuration file.
# vim userpage.conf
<VirtualHost 172.25.9.11:80>
ServerAdmin root@server9.example.com
ServerName server9.example.com
DocumentRoot /var/www/html
DirectoryIndex userpage.html
</VirtualHost>
<Directory "/var/www/html">
AllowOverride none
Require All Granted
</Directory>
(save and exit this file)
(iii) Go to document root directory by # cd /var/www/html
command.
(iv)# vim userpage.html
<html>
<H1>
This is user page as home page web hosting
</html>
(save and exit this file)
Restart the web server daemon.
# service httpd start (to start
the webserver daemon in RHEL - 6)
# chkconfig httpd on (to enable
the service at next boot in RHEL - 6)
# systemctl restart httpd (to start
the webserver daemon in RHEL - 7)
# systemctl enable httpd (to enable
the service at next boot in RHEL - 7)
(e) Add the service to the IP tables and firewall.
Page 216
RED-HAT LINUX 6/7
In RHEL - 6 :
iptables -A INPUT -i eth0 -p tcp -m tcp --deport 80 -j
ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deport 80
-j ACCEPT
service iptables save
# service iptables restart
In RHEL - 7 :
# firewall-cmd --permanent --add-service=http
# firewall-cmd --complete-reload
(f) Go to client system, open the Firefox browser and type as
http://server9.example.com in address bar and check the user defined
The web page is displayed or not.
(g) We can also access the website using the elinksCLI tool.
# yum install elinks* -y
(install the elinks package)
# elinks --dump server9.example.com
(access the index page)
17. How to configure CGI based web hosting?
CGI content will change dynamically every time the client accesses it.
Normal web server will not be used to support this type of web hosting.
To access these dynamic pages, we need to configure the web server as '.wsgi'.
server. The following steps will configure the CGI web server.
(a) Install the CGI package by # yum install mod_wsgi* -y
command.
(b) Download or create the CGI script file in the web server's document
root directory.
Example : # cp webapp.wsgi /var/www/html
(c) Create the configuration file for CGI based web hosting.
<VirtualHost 172.25.9.11:80>
ServerAdmin root@server9.example.com
ServerName webapp9.example.com
DocumentRoot /var/www/html
WSGIScriptAlias / /var/www/html/webapp.wsgi
</VirtualHost>
(d) Restart the web server daemon.
# service httpd start (to start
the webserver daemon in RHEL - 6
# chkconfig httpd on (to enable
the service at next boot in RHEL - 6)
Page 217
RED-HAT LINUX 6/7
Page 218
RED-HAT LINUX 6/7
Page 219
RED-HAT LINUX 6/7
</html>
(save and exit this file)
Restart the web server daemon.
# start httpd service (to start
the webserver daemon in RHEL - 6
# chkconfig httpd on (to enable
the service at next boot in RHEL - 6)
# systemctl restart httpd (to start
the webserver daemon in RHEL - 7
Enable httpd (to enable
the service at next boot in RHEL - 7)
(h) Add the service to the IP tables and firewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deport 443 -
j ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deport
443 -j ACCEPT
# service iptables save
# service iptables restart
In RHEL - 7 :
# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=https
firewall-cmd --complete-reload
(i) Go to client system, open the firefox browser and type as
https://server9.example.com/in and check the
secured web page is displayed or not.
21. How to generate our own private and public keys using crypto-utils
package?
(i) Install the package by # yum install crypto-utils* -y
command.
(ii) Create our own public and private keys by # genkey
<hostname of the server> command.
Page 220
RED-HAT LINUX 6/7
MUA stands for Mail User Agent. It is the e-mail client we used.
tocreate-draft-sendemails. Generally Microsoft Outlook, Thunderbird,
kmail, ....etc., are the examples for MUAs.
MTA :
MTA stands for Mail Transfer Agent. It is used to transfer the
messages and mails between senders and recipients. Exchange, Qmail,
Sendmail, Postfix, ....etc., are examples of MTAs.
SMTP:
Page 221
RED-HAT LINUX 6/7
Page 222
RED-HAT LINUX 6/7
Maildir
(save and exit this file)
(iv) Open the other configuration file and finally type as below.
# vim /etc/dovecot/dovecot.conf
imap pop3 lmtp
(save and exit this file)
Restart the mail server services.
# service postfix restart (to
restart the postfix daemon in RHEL - 6)
# service dovecot restart (to
restart the dovecot daemon in RHEL - 6)
# chkconfig postfix on (to enable the
Postfix daemon at next boot in RHEL - 6)
# chkconfig dovecot on (to enable the
dovecot daemon at next boot in RHEL - 6)
# systemctl restart postfix dovecot (to
restart the postfix and dovecot daemons in RHEL - 6)
systemctl enable postfix dovecot (to
enable the daemons at next boot in RHEL - 6)
(vi) Add the service to the IP tables and firewall.
In RHEL - 6 :
# iptables -A INPUT -i eth0 -p tcp -m tcp --deport 25 -j
ACCEPT
# iptables -A OUTPUT -i eth0 -p tcp -m tcp --deport 25
-j ACCEPT
# service iptables save
# service iptables restart
In RHEL - 7 :
# firewall-cmd --permanent --add-port=25/tcp
# firewall-cmd --complete-reload
Send a test mail to the user.
# mail -s testmail raju
Hi this is a test mail
ok bye... bye .... (exit and
send the mail by Ctrl + d)
(viii) Login as raju user and check the mail.
switch user to raju
$ ls
$ cd Maildir
$ ls
Page 223
RED-HAT LINUX 6/7
$ cd new
$ cat <mail name>
6. How to configure mail server as null client in RHEL - 7?
(i) Open the configuration file and finally type as below.
# vim /etc/postfix/main.cf
relayhost = [client9.example.com]
loopback-only
mynetworks = 127.0.0.0/8 [ : : 1]/128
server9.example.com
mydestination
error: local delivery disabled
(save and exit this file)
(ii) Restart the postfix daemons.
# systemctl restart postfix
# systemctl enable postfix
(iii) Add the postfix service to Firewall.
# firewall-cmd --permanent --add-port=25/tcp
# firewall-cmd --complete-reload
Send a test mail to the user.
# mail -s testmail raju or # mutt -s testmail raju
Hi this is a test mail
ok bye... bye.... exit and
send the mail by Ctrl + d
(v) Login as raju user and check the mail.
su - raju
ls
$ cd Maildir
$ ls
$ cd new
$ cat <mail name>
Other useful commands:
To send a mail to the local system, there is no need to configure the mail.
server.
To send a mail to the remote system, we need to configure it first.
the mail server.
mail raju@server9.example.com (to send the
mail to the Raju user of the server
type the message whatever you want (press Ctrl + d
to exit and send the mail)
su - raju (to switch to the raju user)
Page 224
RED-HAT LINUX 6/7
Page 225
RED-HAT LINUX 6/7
Page 226
RED-HAT LINUX 6/7
Page 227
RED-HAT LINUX 6/7
: n (new partition) ---> Enter ---> Enter ---> Enter ---> +<size
in MB/GB/TB> ---> w (write the changes into the disk
partprobe (to write the
changes into the partition table
pvcreate <disk partition name> (to create
the physical volume
# vgcreate <physical volume name> (to create
the volume group
# lvcreate -s <extent size> -n <logical volume name><vg
name (to create the logical volume)
(ii) Install the iSCSI package by # yum installscsi-target-utils-y
command in RHEL - 6 or
Install the iSCSI package by # yum install target* -y
command in RHEL - 7.
(iii) Start the iSCSI daemon and enable the daemon at next boot time.
# service tgtd restart (to start
the iSCSI daemon in RHEL - 6)
# chkconfig tgtd on (to enable the iSCSI
daemon at next boot in RHEL - 6)
systemctl start target (to start the
target daemon in RHEL - 7)
enable target (to enable the target)
daemon at next boot in RHEL - 7)
(iv) Configure the iSCSI storage.
In RHEL - 6 :
#vi /etc/tgt/targets.conf
default driver iscsi
<target iqn.2015-06.com.example:server9.target1>
backing-store <iSCSI partition name>
write-cache off
In RHEL - 7 :
# targetcli (to get the configuration window and
displays"/>"prompt appears)
ls (to see the
configuration contents
/backstores/block create <block storage name><the above
created volume name> (create the
block storage
Page 228
RED-HAT LINUX 6/7
Page 229
RED-HAT LINUX 6/7
Page 230
RED-HAT LINUX 6/7
(ix) Create a mount point for the above file system by # mkdir
/mnt/iscsicommand.
(x) Open the /etc/fstab file and put an entry of the above file
system information.
# vim /etc/fstab
<partition name> or <UUID> /mnt/iscsi ext4 _netdev 0
0 save and exit this file
(xi) Mount all the partitions that have entries in /etc/fstab
file by # mount -acommand.
(xii) Check all the mounted file systems by # df -hT command.
(xiii) To disconnect iSCSI target we can use the following commands. Don't
forget that logout from the target.
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
(xiv) Restart the client system by the init 6 command.
(xv) After reboot, check the remote file system by the # df -hT command.
Page 231
RED-HAT LINUX 6/7
Page 232
RED-HAT LINUX 6/7
Page 233
RED-HAT LINUX 6/7
name2
type (size)
name3
type (size));
Example: mysql or mariadb > create table mydetails (Name
varchar (30), status varchar (10)
Address varchar
(50), teléfono int (10));
See the structure of the table.
mysql or mariadb >describe <table name>; (to see
the structure of the table
Example: mysql or mariadb > describe mydetails;
(v) Insert or enter the data into the table.
mysql or mariadb >insert into mydetails values ("Raju",
Single
(vi) Query the table to get the data.
mysql or mariadb >select * from mydetails;
(to see all the records of the tables)
mysql or mariadb >select name, phone from mydetails;
select the wanted data ie., filtering the data
5. How to take a backup of the database, drop the database and restore
the database using backup?
To take a backup or restore of the database, we should first exit.
from the database server and then take a backup or restore the backup.
(i) Exit from the database server.
mysql or mariadb >exit;
(ii) Take a backup of the database.
# mysqldump -u root -p <database name> > <file name>
full path
Example : # mysqldump -u root -p mydetails >
/root/mydetails.bak
Delete the database from the database server.
mysql or mariadb >drop database <database name>;
Example: mysql or mariadb > drop database mydetails;
Restore the deleted database using the backup copy.
mysql or mariadb >exit;
# mysql -u root -p <database name><<backup file name
with path>
# mysql -u root -p mydetails <
/root/mydetails.bak
Page 234
RED-HAT LINUX 6/7
6. How to create the user in the database and make the user do
transactions or operations?
(i) To create the user in the database first log in to the database and
then create the user.
mysql or mariadb > create user <user name>@<host name>
identified by "<password>";
Example: mysql or mariadb > create user raju@localhost or
server9.example.com identified by
raju123
(ii) Make the user do transactions on the database. (nothing but
granting the permission
mysql or mariadb > grant select, insert, update, delete on
<database name>.* to <user name>; or
mysql or mariadb > grant all on <database name> .* to
<user name>;
Example: mysql or mariadb > grant select, insert, update,
delete on mydetails .* to raju; or
mysql or mariadb > grant all on mydetails .* to raju;
(where database . * means granting permissions on all the
contents like tables, indexes, views,
synonyms and others
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 or mariadb > update mydetails set name="bangaram"
where name='raju';
8. How to delete the table from the database?
mysql or mariadb > drop table <table name>;
Example: mysql or mariadb > drop table mydetails;
9. How to connect the remote database from our system?
# mysql -u root -h <host name> -p (here
we have to enter the password)
# mysql -u root -h server9.example.com -p
(If the database is configured as localhost database, then the server will
not allow remote database connections and Permission denied message
will be displayed on the screen)
10. How to add mysqld service to IPtables and mariadb service to
firewall?
In RHEL - 6 :
Page 235
RED-HAT LINUX 6/7
Page 236
RED-HAT LINUX 6/7
Page 237
RED-HAT LINUX 6/7
# firewall-cmd --complete-reload
(to reload the firewall configuration)
4. How to configure the client system to send log messages to the log
server?
(i) Open the log server configuration file by# vim
/etc/rsyslog.conf command.
(ii) Go to line no. 90 and type as below.
*.*@<log server IP address> : 514
Example : *.* @172.25.9.11:514
(save and exit this file)
(iii) Restart the log server daemons in RHEL - 6 and RHEL - 7.
# service rsyslog restart to restart
the log server daemon in RHEL - 6)
# chkconfig rsyslog on (to enable the log server
daemon at next boot in RHEL - 6)
# systemctl restart rsyslog (to restart
the log server daemon in RHEL - 7)
# systemctl enable rsyslog (to enable the log
server daemon at next boot in RHEL - 7)
Then all the log messages are stored in /var/log/securelocation.
To monitor all the messages on the server by # tailf /var/log/secure
command.
Open the /etc/rsyslog.conf file and type as below to store all the
client's log messages in remote log server only.
# vim /etc/rsyslog.conf
All files in /var/log/secure
(save and exit this file)
Then restart the log server daemons in RHEL - 6 and RHEL - 7.
# service rsyslog restart (to restart
the log server daemon in RHEL - 6)
# systemctl restart rsyslog (to restart
the log server daemon in RHEL - 7)
5. What is a log file?
Log file is a file that contains messages about the system, including the
kernel, services and applications running on it, ....etc., There are different log
files for different information. These files are very useful when trying to
troubleshoot a problem with systems.
Almost all log messages are stored in /var/log directory. Only root
User can read these log messages. We can use less or more commands to
Page 238
RED-HAT LINUX 6/7
read these log files. The messages will be generated only when rsyslog service
is running, otherwise the log messages will not be generated.
The different types of log files and their locations:
System and general messages and DHCP
log messages.
Authentication log messages.
Security and authentication and user log
messages.
Mail server log messages.
Cron jobs log messages.
All booting log messages.
All Apache web server log messages.
Mysql database server log messages.
All the user's login
messages.
Qmail log messages.
All kernel related log messages.
All samba server log messages.
Linux installation log messages.
Recent login information for all users.
lastlog (to see the log
messages of the above log file
All package installation log messages
generated by # yum or # rpm commands.
All printer and printing related log messages.
All ntp server and services log messages.
Mail, printer and cron jobs spooling
messages.
/var/log/sssd-----> System security service daemon log messages.
SELinux log messages.
# dmesg (to see the boot log)
messages
# tailf or # tail -f /var/log/secure to check or watch
the log files continuously)
# vim /etc/rsyslog.conf (we can change the log
messages default destinations
* Whenever we change the contents of the /etc/rsyslog.conf file, then
we have to restart the rsyslog service.
There are 7 types of priority messages. We can change the default.
destination of those log files. For that
Page 239
RED-HAT LINUX 6/7
open rsyslog server configuration file and we have to enter the rules as
follows.
# vim /etc/rsyslog.conf
priority type new destination of the
log files> (save and exit this file)
# logger <type any text> (to send that text into
/var/log/messages files and to test whether logging
service is running or not
logrotate to create the log files with datewise
* Generally in log messages the fields are,
Date & Time : From which system : command name or
Execution of the command
# yum install tmpwatch -y (to install the tmpwatch package to
execute the below command)
tmpwatch (to monitor the /tmp directory)
logwatch (to monitor the log messages)
# yum install watch -y (to install the watchpackage to execute)
the below command)
# watch <command> to watch the specified command results
continuously
Create a directory with mode 755 in /ram to give the permissions to the
directory while creating that directory
journalctl (it tracks all the log files between two different
timings and save by default
in/run/loglocation)
*/run/logis mounted on tmpfs file system i.e., if the system is
rebooted the whole information in that
location will be deleted or erased.
Page 240
RED-HAT LINUX 6/7
Page 241
RED-HAT LINUX 6/7
Page 242
RED-HAT LINUX 6/7
Page 243
RED-HAT LINUX 6/7
Page 244
RED-HAT LINUX 6/7
Page 245
RED-HAT LINUX 6/7
Page 246
RED-HAT LINUX 6/7
Page 247
RED-HAT LINUX 6/7
Page 248
RED-HAT LINUX 6/7
26. Virtualization
What is virtualization?
Virtualization allows multiple operating system instances to run
concurrently on a single computer; it is a means of separating hardware
from a single operating system. Each 'guest' OS is managed by a Virtual
Machine Monitor (VMM), also known as a hypervisor. Because the
The virtualization system sits between the guest and the hardware, it can
control the guests’ use of CPU, memory, and storage, even allowing a guest OS
to migrate from one machine to another.
2. What are types of virtualizations available in Linux?
RHEL - 5 : RHEL - 6 & 7 :
xen kvm
64 bit 64 bit
VT-Enabled VT-Enabled
Intel/AMD Intel/AMD
2 GB RAM 2 GB RAM
6 GB Hard disk 6 GB
Hard disk
3. What are the packages of virtualization and how to install them?
packages?
(i) qemu It is used to provide user level KVM virtualization
and disk image also)
(ii) virt It is used to provide virtualization software.
(iii) libvirt It is used to provide the libraries for virtualization
software)
Page 249
RED-HAT LINUX 6/7
(iv) python (This package provides the host and server libraries for
interacting with Hypervisor and
Host system
yum install qemu* virt* libvirt* python* -y (to
install the virtualization software
4. How to start the virtualization manager and how to create a new one
virtual machine?
(i) Go to Applications -----> System Tools -----> Virtual Machine
Manager
(ii) Virtual Machine Manager is used to check and display the
available virtual machines. It is also used to create the new virtual
machines.
(iii) To create a new virtual machine first click on the monitor icon, then
Enter the virtual machine name, select Local and select Forward.
(iv) Click on Browse Local, Select the guest O/S " . iso " image file
and Select Forward.
5. What are the packages of Virtualization Hypervisor and how to install
the packages?
(i) virtualization hypervisor (provides the foundation to host
virtual machines includes the libvirt and
qemu-kvm package
(ii) virtualization client (provides the support to install
and manage virtual machines includes
virsh, virt-install, virt-manager, virt-top and virt-viewer packages
virtualization tools provides tools for offline management
of virtual machines includes the
libguestfs package)
virtualization platform (provides an interface to access and
controlling virtual machines includes the
libvirt, libvirt-client and virt-who packages)
Installation of Virtualization Hypervisor :
# yum group install "virtualization hypervisor" "virtualization"
virtualization tools
virtualization platform
6. How to create a storage pool and volume using the virsh tool?
(i) View all the available storage pools by # virsh pool-list
Command.
(ii) Create a storage pool directory by # mkdir
/var/lib/libvirt/<pool name> command.
Page 250
RED-HAT LINUX 6/7
Page 251
RED-HAT LINUX 6/7
Page 252
RED-HAT LINUX 6/7
Page 253
RED-HAT LINUX 6/7
Page 254
RED-HAT LINUX 6/7
Page 255
RED-HAT LINUX 6/7
Page 256
RED-HAT LINUX 6/7
(viii) If any files are open in the production server, the backup may be
failed. So, check any files opened or not by# lsof or# fuser -cv
<file system> commands.
(ix) Sometimes the script in Veritas Net backup or Tivoli tools may be
corrupted or not running, then restore those scripts from backup
or we need to manually export & import and take backup.
(x) Sometimes backup failed due to backup port no. 13782 may not be
working or in blocked state. It can be checked by # netstat -ntulp |
grep 13782 command.
If the media server and production server are not in the same
domain, then backup may be failed. (ie., production server
The domain name may be changed but no notification has been given to the backup team about that.
change, so the media server is in another domain.
Backup Procedure:
Deport the disk group on production server.
(ii) Import the disk group on backup (media) server.
(iii) Join the disk group with media server.
(iv) Sync the data with production server.
Take the backup.
(vi) split the disk group from media server.
Join the disk group with production server.
Deport the disk group from media server.
(ix) Import the disk group on production server.
Backup policy
Complete (full) backup (every month ie., once in a month).
(ii) Incremental backup (Daily).
(iii) Differential or cumulative backup (every week end).
22. How to troubleshoot if the file system is full?
First check whether the file system is O/S or other than O/S.
(ii) If it is other than O/S, then inform the respective teams to house.
keep the file system (ie., remove the unnecessary files in those files
system).
If it is not possible to maintain, then inform the different teams (raise the
CRQ (Change Request) for increasing the file system.
(a) First obtain business approval and raise the CRQ for monitoring.
team to ignore the alerts from the system, stop the application
team to stop the application and database team to stop the database.
(b) Normally the team lead, tech lead, or manager will do this by
initiate the mail thread.
(c) We will do this on the weekend to reduce the business impact.
Page 257
RED-HAT LINUX 6/7
(iv) First take a backup of the file system then unmount the file system.
(v) Remove that partition and again create that file system with
increased size, then mount again that file system and restore
the backup.
(vi) If the file system belongs to system log files or other log files and not
to delete then they requested us to provide one Repository server (only
for log files). Normally one script will do automatically redirect the log
files to that repository server.
(vii) Sometimes we will delete file contents not the files to reduce the file
sizes. For that we execute the command# cat /dev/null
nullifying the files.
(ix) If it is root file system or O/S file system,
(a) may be/optfull or may be/varfull or may be /tmp
full
(b) In /var/log/secureor/var/log/systemor/var/tmpfiles
may be full. If those files are important then redirect them to other
central repository server or backup those files and nullifying those files.
(c) If /homedirectory is present in the root (/) file system then
this file system full will occur. Generally /home will be separated
from root file system and created as separate /home file system. If
/home is in root (/) as a directory then create a separate file system for
/home and copy those files and directories belong to /home
and remove that /homedirectory.
(d) If root (/) is full then cannot login to the system. So, boot
with net or CDROM in single user mode and do the above
said.
(x) Normally, if the file system is different from the operating system, we will inform about that.
respective manager or owner and take the permissions to remove
unnecessary files through verbal permission or CRQ.
23. CPU utilization full, how to troubleshoot it?
(a) Normally we get these scenarios on weekends because backup
team will take heavy backups.
(b) First check which processes are using more CPU utilization by # top
and take a snapshot of that user processes and send the snap
shot and inform that user to kill the unnecessary process.
(c) If those processes are backups then inform the backup team to
reduce the backups by stopping some backups to reduce the CPU
utilization.
(d) Sometimes during peak stages (peak hours mean having business hours)
CPU utilization will be full and then return to the normal position
Page 258
RED-HAT LINUX 6/7
automatically after some time (within seconds). But ticket raised by monitoring
team. So, we have to take a snapshot of that peak stage and
attach that snapshot to the raised ticket and close that ticket.
Sometimes if heavy applications are running and not to kill (i.e.,
business applications), then if any spare processor is available
or other low load CPUs available then move those heavy application processes
to those CPUs.
(d) If CPUs are also not available then if the system supports another CPU
then inform the data center people or CPU vendor to purchase
new CPU through Business approval and move some processes to the newly
purchased CPUs.
24. How to troubleshoot when the system is slow?
System slow means the end users response is slow.
(b) Check the Application file system, CPU utilization, memory
utilization and O/S file system utilization.
(c) If all are ok, then check network statistics and interfaces whether the
interfaces are running in full duplex mode or half duplex mode and
check whether the packets are missing. If all are ok from our side then,
(d) Inform the network team and other respective teams to solve this
issue.
25. How to troubleshoot if the node is down?
(a) Check pinging the system. If it's pinging, then check whether the
Is the system in single user mode or not.
(b) If the system is in single user mode then put the system in multi
user mode i.e., default run level by confirming with our team
whether the system is under maintenance or not.
(c) Check in which run level the system is running. If it is in init 1 it will
not be able to ping. If it is in init s then it will ping.
In this situation also if it is not pinging then try to login through
console port. If not possible then inform to data centers people to hard
boot the system.
If connected through the console port then we may get the console
prompt.
26. How to troubleshoot if the memory utilization is full?
(a) Check how much memory is installed in the system by #
dmidecode -t memorycommand.
(b) Check the memory utilization by the # vmstat -v command.
(c) Normally, applications or heavy backups utilize more memory. So,
inform the application team or backup team or other teams which
Page 259
RED-HAT LINUX 6/7
Page 260
RED-HAT LINUX 6/7
Causes
The system is continuously rebooting.
(b) When in peak business hours, if the heavy applications are
running the system got a panic and rebooted. This is repeating
regularly.
Solution :
(a) First we check how much RAM is present in the system with #
dmidecode -t memory command.
(b) Then we raise the case to the vendor with the help of higher management.
authorities.
(c) Then the vendors will provide the case number for future reference.
(d) They will also ask for the rack number and system number to replace the
memory.
(e) we will inform the data center people to coordinate with the
vendor.
30. What is your role in DB patching?
In Database patching the following teams will be involved.
Database Administrator (DBA) team.
Linux Administrators team.
(iii) Monitoring team.
(iv) Application team.
(i) DBA team:
This is the team to apply the patches to the databases.
(ii) Linux team :
This team is also involved if any problems occur. If the database
volume is having a mirror we should first break the mirror and then
the DBA people will apply the patches. After 1 or 2 days there is no problem
Again, we need to sync the data between the mirrored volume to patch.
applied volume. If there is no space for patch we have to
provide space to DBA team.
(iii) Monitoring team :
This team should receive requests or suggestions to ignore any
problems occur. After applying the patch if the system is automatically
rebooted then monitoring team will raise the ticket 'Node down' to system
administrators team. So, to avoid those types of tickets we
I have to send requests to ignore those types of alerts.
(iv) Application team :
For applying any patches, the databases should not be available
to application. So, if suddenly database is not available then
Page 261
RED-HAT LINUX 6/7
The application may have crashed. So, first the application should be stopped.
will be done by application team.
31. What is SLA?
A service-level agreement (SLA) is simply a document describing the level
of service expected by a customer from a supplier, laying out the metrics by
which that service is measured and the remedies or penalties, if any, should
the agreed-upon levels not be achieved. Usually, SLAs are between companies
and external suppliers, but they may also be between two departments
within a company.
32. What is Problem Management?
The objective of Problem Management is to minimize the impact of
problems on the organisation. Problem Management plays an important
role in the detection and providing solutions to problems (work around&
known errors) and prevents their reoccurrence.
A 'Problem' is the unknown cause of one or more incidents, often
identified as a result of multiple similar
incidents. A 'Known error' is an identified root cause of a Problem.
33. What is Incident Management?
An 'Incident' is any event which is not part of the standard operation of
the service and which causes or may cause, an interruption or a reduction of
the quality of the service.
The objective of Incident Management is to restore normal operations as soon as possible.
quickly as possible with the least possible impact on either the business or
the user, at a cost-effective price.
Inputs for Incident Management mostly come from users, but can have
other sources as well like management Information or Detection Systems.
The outputs of the process are RFCs (Requests for Changes), resolved and
closed Incidents, management information and communication to the
customer.
34. What is Change Management?
Change management is a systematic approach to dealing with change.
both from the perspective of an organization and on the individual
level. change management has at least three different aspects, including
adapting to changecontrolling changeand effecting change. A
a proactive approach to dealing with change is at the core of all three
aspects. In an information technology(IT)system environment, change
management refers to a systematic approach to keeping track of the
details of the system (for example, whatoperating systemrelease is running on
each computer and whichfixeshave been applied).
35. What is Request Management?
Page 262
RED-HAT LINUX 6/7
Page 263
RED-HAT LINUX 6/7
Page 264
RED-HAT LINUX 6/7
making it multi-processor.
HoweverincreasingThe number of processors did increase the working speed.
of many tasks and performance but it also leads to increase in size, complexity
and heat issues. So, in order to continue improvement of performance the
the core concept was introduced.
Instead of having two CPUs and a motherboard capable of hosting them,
two CPUs are taken together and combined to form adual core
processorwhich will utilize an individual socket using less power and size
capable of performing the same amount of task as dual processor CPU.
Bottom Line is that Load value depends on the number of cores in your
machine. For example, a dual core is relevant to 2 processors or 2 cores and
quad core is relevant to 4 processors or four cores as the maximum value for
load.
46. How do I check the number of cores on my Linux system?
The information which you see under /proc/cpuinfo can be confusing at
times. If you run the below command
# less /proc/cpuinfo | grep processor
processor 0
processor 1
processor 2
processor 3
processor 4
processor 5
So as per the above command my system has 16 processors in it.
However, it really has 8 processors with hyperthreadingenabled. The
hyper threadingpresents2 logical CPUs to the operating system for each actual
core so it effectively doubles the number of logical CPUs in your system.
47. How to find if hyper threading is enabled
Look out for 'ht' in theflagssection inside cpuinfo with the below
command
less /proc/cpuinfo | grep flags | uniq | grep -i "ht"
fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx rdtscp lm
constant_tsc nonstop_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr
sse4_1 sse4_2 popcnt lahf_lm.
The fields we need to compare to find the number of cores are 'physical id'.
and "core id". Run the below command
# less /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l
2
# less /proc/cpuinfo | grep "core id" | sort|uniq | wc -l
Page 265
RED-HAT LINUX 6/7
4
So the number of cores would be 2x4 = 8 cores.
48. What do you understand by Load Average?
If the number of active tasks utilizing CPU is less compared to
available CPU cores then the load average can be considered normal but if
the number of active tasks starts increasing with respect to available CPU cores then
the load average will start rising. For example,
uptime
00:43:58 up 212 days, 14:19, 4 users, load average: 6.07, 7.08, 8.07
49. How to check all the current running services in Linux?
To find the status of anysingle service:
# service vsftpd status
vsftpd (pid 5909) is running...
To get the status of all the running services:
# service --status-all | grep running
acpid (pid 5310) is running...
atd (pid 6528) is running...
auditd (pid 5012) is running...
Avahidaemonis not running
Avahi DNS daemon is not running
The PegasusCIMListener is running.
The Pegasus CIM Object Manager is running.
crond (pid 6242) is running...
dcerpcd (pid 5177) is running...
eventlogd (pid 5223) is running...
In case you don't use grep you will be able to see all the services on
yourmachine:
# service --status-all
NetworkManager is stopped
acpid (pid 5310) is running...
anacron is stopped
atd (pid 6528) is running...
auditd (pid 5012) is running...
automount is stopped
Avahi daemon is not running
Avahi DNS daemon is not running
hcid is stopped
sdpd is stopped
You can also check theactiveports along with their services using :
# netstat -ntlp
Page 266
RED-HAT LINUX 6/7
Page 267
RED-HAT LINUX 6/7
# dmidecode -s system-product-name
VMware Virtual Platform
# dmidecode | less
System Information
VMware, Inc.
VMware Virtual Platform
Version: None
Power Switch
Not Specified
Family: Not Specified
On a virtual server running VMware you can run the below command
to verify :
# lspci | grep -i vmware
00:0f.0 VGAcompatiblecontroller: VMware SVGA II Adapter
51. How to find thebitsize of your linux machine?
uname -m
i686
# uname -m
x86_64
If we get i386, i586 and i686 that signifies your machine is 32-bit
but if we get x86_64 or ia64 then your machine will be 64-bit.
getconf LONG_BIT
32
getconf LONG_BIT
64 (Here we get an output of bit size either 32 or 64)
52. How can you add a banner or login message in Linux?
By editing these two files
/etc/issue
/etc/motd
53. What is the difference between normal kernel and kernel-PAE?
The kernel in a 32-bit machine supports a maximum of 4.GB RAMwhereas
kernel PAE in 32 bit linux machine supports up to 64 GB RAM
54. Tell me the command to find all the commands in your Linux machine
having only 2 words like ls, cp, cd etc.
find /bin /sbin /usr/bin /usr/sbin -name ?? -type f
55. Which file is generally used to configure kickstart?
anaconda.cfg
56. Which log file will you check for all authentication related messages?
/var/log/secure
Page 268
RED-HAT LINUX 6/7
57. What is the command used to find the process responsible for a
particular running file?
fuserfilename
lsof filename
58. What is the command to take remote of any Linux machine?
rdesktop
59. What are the three values shown in the load average section of top?
command?
It shows the current, 5 minutes ago, and 15 minutes ago load average value.
60. How to check all the processes running by a particular user?
ps -u<username>
61. What is an orphan process?
An orphan process is a process that is still executing, but whose parent
has died.
62. What is a defunct process?
These are also termed as zombie processes. These are those processes that
have completed their execution but still has an entry in the process table.
When a process ends, all of the memory and resources associated with it are released.
de-allocated so they can be used by other processes. After the zombie is
removed, its process identifier (PID) and entry in the process table can then
be reused.
Zombies can be identified in the output from the Unix ps command by
the presence of a 'Z' in the 'STAT' column
63. How do you limit maximum connections in your Apache server?
Change the below parameter value inside httpd.conf
MaxClients 256
64. Welche Befehle verwenden Sie, um eine Datei von einer FTP- oder HTTP-Website herunterzuladen?
using CLI?
# wget path_to_the_file
65. What is the default port for ssh? How will you change it to some other
random port no.?
The default SSH port number is 22. To change the default port number, we need to
make required changes inside sshd_config file in the below mentioned line
#Port 22 (Uncomment the above line and define the new port)
no
Restart the services for changes to take effect.
66. What is the difference between A record andCNAMErecord in DNS?
A record:
It is the Address records also known as host records
Points to the IP address reflecting the domain
Page 269
RED-HAT LINUX 6/7
Page 270
RED-HAT LINUX 6/7
Page 271
RED-HAT LINUX 6/7
Page 272
RED-HAT LINUX 6/7
Page 273
RED-HAT LINUX 6/7
Page 274
RED-HAT LINUX 6/7
Page 275
RED-HAT LINUX 6/7
Page 276
RED-HAT LINUX 6/7
Page 277
RED-HAT LINUX 6/7
# yum repolist
Configure the DHCP server.
# 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
Go to line number 47 and edit the line as below.
subnet 172.25.9.0 netmask 255.255.255.0 {
range 172.25.9.50 172.25.9.200;
* comment on next two lines
option routers 172.25.9.11;
option broadcast-address 172.25.9.255;
default-lease-time 600;
max-lease-time 7200;
allow booting;
allow bootp;
next-server 172.25.9.11;
filename "Pxelinux.0";
authoritative;
save and exit this file
# 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 --dport 68 -j ACCEPT
(h) Configure the TFTP server.
# yum install tftp* syslinux* -y
# vim /etc/xinetd.d/tft
Go to disable=yes line and change it to no
(save and exit this file)
# cp -rvpf /media/RHEL6/isolinux/*.* /var/lib/tftpboot
# create directory /var/lib/tftpboot/pxelinux.cfg
# cp /var/lib/tftpboot/isolinux.cfg
/var/lib/ftfpboot/pxelinux.cfg/default
# cp -rvpf /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
Page 278
RED-HAT LINUX 6/7
Page 279
RED-HAT LINUX 6/7
Page 280
RED-HAT LINUX 6/7
(c) vxrelocd :
It always monitors the consistency in the disks and notifies the
user if failed using vxnotifyd deamon.
(ii) It also relocates and recognizes the new disk.
(d)vxrecoverd :
It passes the lost data into new disk.
(ii) It also notifies the Administrators using vxnotifyd.
deamon.
(e)vxnotifyd :
It notifies the user (Administrator) about failed disks and
after recovery also it notifies to the Administrator.
3. How to create the root mirror?
Bring the disk from O/S to Veritas Volume Manager control using
the Veritas Advanced Management tool, vxdiskadm command (It
gives (displays) options for easy administration of Veritas Volume Manager).
Select 2nd option ie., Encapsulation because to preserve the
existing data present in the disk and reboot the system to effect
Encapsulation and modify the /etc/sysconfig file. While encapsulating, it
asks disk name and disk group (root disk name and rootdg).
(iii) Backup the /(root), /etc/sysconfig directories.
(iv) Take another disk and initialize it by # vxdisksetup -i <mirrored
root disk name> command.
(v) Add the above initialized disk to the volume group ie., roodg by
vxdg -g <rootdg> adddisk mirrordisk=<mirrored root
disk name
(vi) vxmirror -v -g <rootdg><original disk name><mirrored root
disk name> (disk level mirroring)
(vii) For individual mirroring, # vxassist -g <rootdg> mirror
<volume name> or
# vxrootmirr -g <rootdg><volume name> command.
Page 281
RED-HAT LINUX 6/7
7. What is the main configuration file for VCS (Veritas Cluster) and
where it is stored?
'main.cf' is the main configuration file for VCS and it is located in
/etc/VRTSvcs/conf/configdirectory.
8. What is the public region and private region?
when we bring the disk from O/S control to Volume Manager control in
any format (either CDS, simple or sliced), the disk is logically divided into
two parts.
(a) Private region:
It contains Veritas configuration information like disk type and
name, disk group name, groupid and configdb. The default
size is 2048 KB.
(b) Public region:
It contains the actual user's data like applications, databases and
others.
9. There are five disks on VxVM (Veritas Volume Manager) and all are
failed. What are the steps you follow to Get those disks online?
(i) Check the list of disks in Volume Manager Control by # vxdisk list
command.
(ii) If the above disks are not present, then bring them O/S control to
VxVM control by
# vxdisksetup -i <disk names> if data is not on
those disk) or execute
# vxdiskadm command and select 2nd option ie.,
encapsulation method if the disks having the data.
Page 282
RED-HAT LINUX 6/7
Even though it is not possible, then check the disks are available.
at O/S level by # fdisk -l command.
If the disks are available, execute the above command once.
again.
(b) If the disks are not available then recognize them by scanning
the hardware.
Even though if it is not possible, then reboot the system and follow
the steps (i) and (ii).
10. What is the basic difference between private disk group and shared
disk group?
Private disk group :
The disk group is only visible for the host on which we have created it. If
the host is a part of the cluster, the private disk group will not be visible to
the other cluster nodes.
Shared disk group :
The disk group is sharable and visible to the other cluster nodes.
11. How will you create a private disk group and a shared disk group?
# vxdg init <disk group name><disk media name>=<O/S disk name>
(to create the private disk group)
# vxdg -s init <disk group name><disk media name>=<O/S disk
name>(to create the shared disk group)
12. How will you add a new disk to the existing disk group?
we can do this in two ways.
(i) Run the vxdiskadm command, which will open a menu-driven interface.
program to do various disk operations. Select add disk option and
give disk group name and disk name.
(ii) # vxdg -g <disk group name> adddisk <disk media
name>=<O/S disk name>
# vxdg -g appsdg adddisk disk02=/dev/sdb
13. How will you grow or shrink the volume/file system? What is the
to increase by a certain amount or percentage and shrink to options?
(i) We can grow the volume/file system by,
vxassist -g appsdg growby or growto 100GB appsvol
(or)
# vxresize -g appsdg +100GB appsvol alloc = <disk name>
(ii) We can shrink the volume/file system by,
# vxassist -g appsdg shrinkby 20GB appsvol
# vxassist -g appsdg shrinkto 20GB appsvol
(or)
Page 283
RED-HAT LINUX 6/7
Page 284
RED-HAT LINUX 6/7
18. Define LLT and GAB. What are the commands to create them?
LLT :
(i) LLT means Low Latency Transport protocol
It monitors the kernel to kernel communication.
It maintains and distributes the network traffic within the
cluster.
It uses heartbeat between the interfaces.
Page 285
RED-HAT LINUX 6/7
Page 286
RED-HAT LINUX 6/7
Page 287
RED-HAT LINUX 6/7
If the resource is in a faulted state, then clear the service group state.
Resources can be critical or non-critical. If the resource is critical, then it
automatically failover if the resource is failed. If the resource is Non-critical,
then it switches over and we have to manually switch over the resource
group to another available system.
31. What are the dependencies between resources in a Cluster?
If one resource depends on another resource, then there is a dependency.
between those resources.
Example: NIC (Network Interface Card) is a hardware component
nothing but hardware resource. The IP address is a software component
nothing but software resource and it depends on NIC card. The relationship
between NIC and IP address is a Parent - Child relationship.
The resource that starts first is called Parentresource and the
remaining dependency resources are called Child resource.
32. What are the minimum requirements for or in VCS?
(i) Minimum two identical (same configuration) systems.
(ii) Two switches (Optical Fibre Channel).
(iii) Minimum three NIC cards. (Two NICs for private network and
one NIC for public network).
(iv) One common storage.
(v) Veritas Volume Manager with license.
(vi) Veritas Cluster with license.
33. What are the Veritas Cluster daemons?
(i) had
It is the main daemon in Veritas Cluster for high availability.
It monitors the cluster configuration and the whole cluster.
environment.
It interacts with all the agents and resources.
(ii) hashadow :
It always monitors the daemon.
(b) Its main functionality is logging about the cluster.
35. What are the main configuration files in a Cluster?
/etc/VRTSvcs/conf/config/main.cf and
/etc/VRTSvcs/conf/config/types.cf are the main configuration
files in Cluster.
36. What are the main log files in a Cluster?
/var/VRTSvcs/log/Engine_A.log (logging about when the
cluster started, when failed, when failover
occurs, when switchover forcefully, ...etc.,)
Page 288
RED-HAT LINUX 6/7
Page 289
RED-HAT LINUX 6/7
40. How to move the service group from one node to another node
manually?
(i) Stop the application.
(ii) Stop the database.
(iii) Unmount the file system.
Stop the volume.
(v) Export the disk group.
(vi) Import the disk group.
(vii) Start the volume.
(viii) Mount the file system.
(ix) Start the database.
(x) Start the application.
41. How to rename a disk group in VxVM step by step?
(i) Stop the application.
(ii) Stop the database.
(iii) Unmount the file system.
(iv) Stop the volume.
(v) Deport the disk group.
Rename the disk group.
(vii) Import the disk group.
(ix) Start the volume.
(x) Mount the file system.
(xi) Start the database.
Start the application.
42. How to create a volume with 4 disks?
(i) Bring the disks to O/S control by scanning the LUNs using the
following the command,
# echo "---" > /sys/class/scsi_host/< lun no. >/scan (to scan
the lun no.)
(ii) Bring those disks from O/S control to VxVM control.
(a) If we want to preserve the data, then bring the disks to VxVM
control using encapsulation method by
vxdiskadm (here we get the options to do this and select)
2nd option i.e., Encapsulation)
(b) If we don't want to preserve the data, then bring the disks to
VxVM control using initialization method by# vxdisksetup -i
<disk 1 name> (for example # vxdisksetup -i /dev/sda)
vxdisksetup -i <disk 2 name> (for example #
vxdisksetup -i /dev/sdb)
Page 290
RED-HAT LINUX 6/7
Page 291
RED-HAT LINUX 6/7
Page 292
RED-HAT LINUX 6/7
Persistent Resource
Those resources which we cannot start or stop are called
Persistent resources.
` Some resources we can start/stop and some other resources we
cannot stop or start.
We cannot start or stop the NIC card.
(b) Non-Persistent Resource :
Those resources which we can start/stop are called Non -
Persistent Resources.
Resources may be critical or non-critical. We need to design the
resources as critical or non-critical. ie., the customer will insist which is
critical and which is non-critical.
(v) If a critical resource fails, then only the service group is moved
automatically from one system to another system. ie., failover,
otherwise if a non-critical resource fails, then we need to do it manually
movement of service group from one system to another system. ie.,
switchover.
46. What are the steps you follow to put the volume in a Cluster?
(i) First create the disk group, volume, and create the file system.
mount and unmount before putting the volume in a cluster because testing
of that volume is working or not.
(ii) Create the service group and add the Attributes to it.
# hagrp -add <service group>
# hagrp -add appssg
Attributes
# hagrp -modify appssg system list={ sys A0, sys B0} (to add sys A
and sys B attributes to service group)
# hagrp -modify appssg autostart list={ sys A } (to start
the sys A attributes automatically)
# hagrp -modify appssg enabled 1 or 0 (1 means start and
0 means not to start automatically)
(iii) Creating resources and adding them to the service group and
specify their attributes.
For file system :
/mnt/apps (the mount point)
(b) /appsvol (the volume name)
(c) /appsdg (the disk group)
hares -add dg-apps diskgroup appssg (to add
the diskgroup resource to a service group
Page 293
RED-HAT LINUX 6/7
to a service group)
# hares -modify dg-mnt fstype=vxfs (to add the
mount point attributes to a service group
hares -modify dg-mnt mount=/mnt/apps (to add
the mount point directory attribute to a
service group
# hares -modify dg-mnt fsckopt=% y or %n (to add
the fsck attribute either yes or no to
service group)
Create links between the above diskgroup, volume and mount
point resources.
# hares -link parent-res child-res
hares -link dg-appdg dg-volume
hares -link dg-volume dg-mnt
47. What is meant by freezing and unfreezing a service group with
persistent and evacuate options?
Freezing:
If we want to apply patches to the system in a cluster, then we have to
freeze the service group because first stop the service group, if it is
Page 294
RED-HAT LINUX 6/7
critical, the service group will move automatically to another system in the Cluster.
So, we don't want to move the service group from one system to
another system, we have to freeze the service group.
Unfreeze:
After completing the task, the service group should be unfreezed
because, if the system is crashed or down and the resources are critical, then the
service group cannot move from system 1 to system 2 due to freeze
service group and results in not available of application. If unfreezed the
Service group after maintenance, the service group can move from system 1
to system 2. So, if system 1 failed, system 2 is available and
application also available.
Persistent option:
If the service group is frozen with the persistent option, then we can stop.
or down or restart the system. So, there is no loss of data and after
restarted the system, the service group remains in a frozen state only.
Example: # hasys -freeze -persistent <system name>
# hasys -unfreeze -persistent <system name>
Evacuate
If this option is used in the frozen service group system, if the system goes down
or restarted the persisted information is evacuated, i.e., before freeze all
the service groups should be moved from system 1 to another system 2.
48. What layouts are available in VxVM and how do they work?
and how to configure?
(i) There are 5 layouts available in VxVM. They are RAID-0, RAID-1,
RAID-5, RAID-0+1 and RAID-1+0.
RAID-0:
We can configure RAID-0 in two ways.
(a) Stripped (default).
(b) Concatenation.
Stripped:
(i) At least two disks are required to configure.
(ii) In this, the data will be written on both disks in parallel, i.e., one line.
in one disk and 2nd line on 2nd disk, ...etc.
In this, the data writing speed is fast.
In this there is no redundancy for data.
Concatenation :
(i) In this minimum one disk is required to configure.
(ii) In this, the data will be written to the first disk and after filling the first disk
then it will write on the 2nd disk.
In this, the data writing speed is less.
Page 295
RED-HAT LINUX 6/7
Logs
If the layout is mirror, then log is DRL.
If the layout is RAID-5, then the log is RAID-5 log.
The main purpose of the log is fast recovery operation.
We have to specify whether the log is required or not in all types of
layouts except RAID-5 because the Logging is default in RAID-5.
* If we want to configure RAID-5 without logging then,
# vxassist -g <diskgroup name> make <volume name>
50GB, nolog layout=raid 5
If the layout is other than RAID-5 then,
# vxassist -g <diskgroup name> make <volume name>
50GB, log layout=mirror
Page 296
RED-HAT LINUX 6/7
Page 297
RED-HAT LINUX 6/7
Page 298
RED-HAT LINUX 6/7
53. How to install VxVM? What version of Veritas are you using and how?
to know the veritas version?
(i) Install the packages supplied by Veritas using # rpm or # yum
commands.
(ii) Execute the command #vxinstall to install VxVM ie., enable the
system to use volume manager.
(iii)#vxinstall will allow us to encapsulate or not encapsulate the root
disk.
(iv) Always use option 2 i.e., Custom installation because, if option 1 is
used ie., Quick installation, it takes all the disks for rootdg.
License
(i) All the licenses are stored in /etc/vx/licensesdirectory and we
can take backup of this directory and restore it back, if we need
reinstall the server.
(ii) Removing the VxVM package will not remove the installed license.
(iii) The command used to install the license is vxlicinst.
(iv) To view the VxVM license information by using the # vxlicrep command.
To remove the VxVM license use # vxkeyless set NONE
command.
(vi)The license packages are installed in /opt/VRTSvlic/bin/vxlicrep
directory.
(vii) The license keys are stored in /etc/vx/licenses/licdirectory.
(viii) We can see the licenses by executing the below commands,
# cat /etc/vx/licenses/lic/keyor
cat /opt/VRTSvlic/bin/vxlicrep | grep "License key"
(ix) To see the features of the license key by using the # vxdctl license command.
Version :
(i) We are using VxVM 6.2 version.
(ii) to know the version of VxVM by # rpm -qa VRTSvxvm
command.
54. What are the available formats to take control of disks from the operating system?
to veritas in VxVM?
We can take control of disks from O/S to Veritas in 3 formats.
(i) CDS (Cross platform Data Sharing and the default format in
VxVM.
(ii) Sliced.
Simple.
(i) CDS :
We can share the data between different Unix flavors.
Page 299
RED-HAT LINUX 6/7
(b) Both the private and public regions are available in the 7th.
partition.
The entire space is in 7th partition.
(d) So, there is a chance to lose the data because, if the disk is
failed ie., partition 7 is corrupted or damaged then the data may
be lost.
(e) This is the default in Veritas Volume Manager.
(ii) Sliced :
(a) It is always used for root disk only.
(b) In this format we cannot share the data between different
Unix flavors. Normally, sliced is used for root. disk and cds is
used for data.
Private region is available at the 4th partition and public region is
available at 3rd partition.
(d) So, if the public region fails, we can recover the data from
private region i.e., minimizing the data loss.
Simple
(a) This format is not widely used now because it is available in
old VxVM 3.5
(b) In this private and public regions are available at 3rd
partition.
Specifying the format while setup :
# vxdisksetup -i /dev/sda (to setup the disk and this is
default format i.e., CDS format
# vxdisksetup -i /dev/sdb <sliced / simple>
(pour spécifier le format découpé ou simple)
55. In how many ways can we manage VxVM?
(I) Command line tool.
(ii) GUI (see tool)
(iii) # vxdiskadm command (it gives the options to manage the disks)
30. RedHat Cluster
How can you define a cluster and what are its basic types?
A cluster is two or more computers (callednodesor members) that work
together to perform a task. There are four major types of clusters:
Storage
High availability
Load balancing
High performance
2. What is Storage Cluster?
Page 300
RED-HAT LINUX 6/7
Page 301
RED-HAT LINUX 6/7
8. What is the order in which you will start the Red Hat Cluster services?
In Red Hat 4:
# service ccsd start
# service cman start
service fenced start
service clvmd start (If CLVM has been used to create clustered volumes)
# start gfs service
# service rgmanager start
In RedHat 5:
# service cman start
# start clvmd service
start gfs service
# service rgmanager start
In Red Hat 6:
# service cman start
# start clvmd service
start gfs2 service
# service rgmanager start
9. What is the order tostopthe Red Hat Cluster services?
In Red Hat 4:
# service rgmanager stop
stop service gfs
# service clvmd stop
service fenced stop
# service cmanstop
# stop ccsd service
In Red Hat 5 :
service rgmanager stop
# servicegfsstop
# stop service clvmd
stop servicecman
In Red Hat 6:
# service rgmanagerstop
Stop the gfs2 service
service clvmdstop
# service cman stop
10. What are the performance enhancements in GFS2 compared to GFS?
Page 302
RED-HAT LINUX 6/7
Page 303
RED-HAT LINUX 6/7
This ensures that if the system crashes or loses power, you will recover all of the
metadata when the journal is automatically replayed at mount time.
GFS2 requires one journal for each node in the cluster that needs to mount the
file system. For example, if you have a 16-node cluster but need to mount only
the file system from two nodes, you need only two journals. If you need to
mount from a third node, you can always add a journal with the gfs2_jadd
command.
13. What is the default size of journals in GFS?
When you run mkfs.gfs2 without the size attribute for journal to create a
GFS2 partition, by default a 128MB size journal is created which is enough for
most of the applications
In case you plan on reducing the size of the journal, it can severely affect
the performance.Supposeyou reduce the size of the journal to 32MB it
does not take much file system activity to fill a 32MB journal, and when the
journal is full, performance slows because GFS2 has to wait for writes to
the storage.
14. What is a Quorum Disk?
Quorum Disk is a disk-based quorum daemon, qdiskd, that provides
supplemental heuristics to determine node fitness.
With heuristics you can determine factors that are important to the operation.
of the node in the event of a network partition
For a 3 node cluster a quorum state is present until 2 of the 3 nodes are down.
active i.e. more than half. But what if due to some reasons the 2nd node also
stops communicating with the 3rd node? In that case under a normal
architecture the cluster would dissolve and stop working. But for mission
critical environments and such scenarios we use quorum disk in which an
An additional disk is configured and is mounted on all the nodes with qdiskd.
service running and a vote value is assigned to it.
So suppose in the above case I have assigned 1 vote to qdisk so even after 2
nodes stop communicating with the 3rd node, the cluster would have 2 votes (1
qdisk + 1 from the 3rd node) which is still more than half of the vote count for a 3
node cluster. Now both the inactive nodes would be fenced and your 3rd node
would be still up and running being a part of the cluster.
15. What is rgmanager in Red Hat Cluster and its use?
This is a service termed as Resource Group Manager
RGManager manages and provides failover capabilities for collections of clusters.
resources called services, resource groups, or resource trees
it allows administrators to define, configure, and monitor cluster services. In
the event of a node failure, rgmanager will relocate the clustered service to
another node with minimal service disruption.
Page 304
RED-HAT LINUX 6/7
19. How does the NetworkManager service affect Red Hat Cluster?
The use of NetworkManager is not supported on cluster nodes. If you have
installed NetworkManager on your cluster nodes, you should either remove it
or disable it.
# service NetworkManager stop
# chkconfig NetworkManager off
The cman service will not start if NetworkManager is either running or has
been configured to run with the chkconfig command
20. What is the command used to relocate a service to another node?
# clusvcadm -r service_name -m node_name
21. What is split-brain condition in Red Hat Cluster?
We say a cluster has quorum if a majority of nodes are alive, communicating,
and agree on the active cluster members. For example, in a thirteen-node
Page 305
RED-HAT LINUX 6/7
Page 306
RED-HAT LINUX 6/7
Page 307
RED-HAT LINUX 6/7
Page 308
RED-HAT LINUX 6/7
Page 309
RED-HAT LINUX 6/7
NOTE: You can enable/disable the marked blue line by pressing "m".
top - 17:51:07 up 1 day, 2:56, 27 users, load average: 5.33, 29.71, 28.33
Tasks: 1470 total, 1 running, 1469 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0% user, 0.1% system, 0.0% nice
99.9% id, 0.0% wa, 0.0% hi, 0.0% si, 0.0% st
Mem: 264114424k total, 253006956k used, 11107468k free, 66964k
buffers
Swap: 33554424k total, 3260k used, 33551164k free, 245826024k
cached
The next line shows your memory (RAM and swap) usage
and capacity.
PID USER PR NI VIRT RES SHR S %CPU
Memory Usage COMMAND
13916 stmprd 18 0 903m 129m 9936 S 51.4 0.1 3:07.01
java
13921 stmprd 18 0 901m 128m 9936 S 49.8 0.0
java
13825 stmprd 18 0 951m 190m 9932 S 49.5 0.1 3:07.13
java
13856 stmprd 20 0 978m 197m 9936 S 49.2 0.1 3:05.89
java
13853 stmprd 18 0 921m 150m 9932 S 48.5 0.1 3:09.14
java
13875 stmprd 18 0 907m 132m 9940 S 48.5 0.1 3:09.49
java
13937 stmprd 25 0 926m 165m 9936 S 48.2 0.1 3:10.31
java
13919 stmprd 18 0 917m 153m 9936 S 47.5 3:05.92
java
13879 stmprd 25 0 921m 160m 9936 S 47.2 0.1 3:08.43
java
13908 stmprd 25 0 901m 131m 9932 S 47.2 0.1 3:12.23
java
13905 stmprd 25 0 907m 137m 9932 S 46.6 2:59.85
Page 310
RED-HAT LINUX 6/7
java
The left sections show you the details of the process running along with
the below details.
Fields/Column Description
PID Process Id
USER The effective user name of the task's owner
PR The priority of the task
The nice value of the task. A negative nice value means higher
priority, whereas a positive nice value means lower priority. Zero
NI
in this field simply means priority will not be adjusted in
determining a task's dispatchability
The task's share of the elapsed CPU time since the last screen
%CPU
update, expressed as a percentage of total CPU time.
%MEM A task's currently used share of available physical memory
TIME+ Total CPU time the task has used since it started
The status of the task which can be one of:
'D' = uninterruptible sleep
'R' = running
S
'S' = sleeping
'T' = traced or stopped
zombie
RES The non-swapped physical memory a task has used
SHR The amount of shared memory used by a task
Display the command line used to start a task or the name of the
Command
associated program
Page 311
RED-HAT LINUX 6/7
Page 312
RED-HAT LINUX 6/7
Page 313
RED-HAT LINUX 6/7
Page 314
RED-HAT LINUX 6/7
Page 315
RED-HAT LINUX 6/7
Page 316
RED-HAT LINUX 6/7
Page 317
RED-HAT LINUX 6/7
99.9%id
Mem: 49432728k total, 2051952k used, 47380776k free, 310176k
buffers
Swap: 2097144k total, 0k
PID USER PR NI VIRT RES SHR S %CPU
memory percentage
TIME+ COMMAND
5359 root 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
top
Page 318
RED-HAT LINUX 6/7
Page 319
RED-HAT LINUX 6/7
Page 320
RED-HAT LINUX 6/7
0:28.64 0 migration/1
6 root 34 19 0 0 0 S 0.0 0.0
0:00.67 0 ksoftirqd/1
7 root RT -5 0 0 0 S 0.0 0.0
0:00.00 0 watchdog/1
8 root RT -5 0 0 0 S 0.0 0.0
0:28.00 0 migration/2
9 root 34 19 0 0 0 S 0.0 0.0
0:00.73 0 ksoftirqd/2
Page 321