Linux Lab Manual Feb
Linux Lab Manual Feb
Linux Lab Manual Feb
LINUX
Reference Guide
With Lab Exercises
Student Name:
Batch:
Branch:
AMEERPET
Page 1 of 274
UNIX Basics
www.kerrneltech.com
Page 2 of 274
UNIX Basics
www.kerrneltech.com
Compiled by
Page 3 of 274
UNIX Basics
www.kerrneltech.com
Page 4 of 274
UNIX Basics
www.kerrneltech.com
Musabuddin Syed
Page 5 of 274
UNIX Basics
www.kerrneltech.com
Page 6 of 274
UNIX Basics
www.kerrneltech.com
Contents
INTRODUCTION TO LINUX
09-15
16-33
BASIC COMMANDS..
34-55
56-74
75-93
94-113
114-124
125-133
134-150
JOB AUTOMATION...
151-158
159-168
169-176
SOFTWARE MANAGEMENT....
177-194
195-197
198-200
MANAGING PROCESSES..........
201-210
211-223
224-231
SAMBA SERVER....
232-239
240-250
251-260
261-274
Page 7 of 274
UNIX Basics
www.kerrneltech.com
Page 8 of 274
UNIX Basics
www.kerrneltech.com
INTRODUCTION TO LINUX
www.kerrneltech.com
HISTORY OF UNIX
In the beginning, there was AT&T.
Bell Labs Ken Thompson developed UNIX in 1969 so he could play games on a scavenged DEC PDP-7.
With the help of Dennis Ritchie, the inventor of the C programing language, Ken rewrote UNIX entirely
in C so that it could be used on different computers. In 1974, the OS was licensed to universities for
educational purposes. Over the years, hundreds of people added and improved upon the system, and it
spread into the commercial world. Dozens of different UNIX flavors appeared, each with unique
qualities, yet still having enough similarities to the original AT&T version. All of the flavors were based
on either AT&Ts System V or Berkeley System Distribution (BSD) UNIX, or a hybrid of both.
During the late 1980s there were several of commercial implementations of UNIX:
Apple Computers A/UX
AT&Ts System V Release 3
Digital Equipment Corporations Ultrix and OSF/1 (renamed to DEC UNIX)
Hewlett Packards HP-UX
IBMs AIX
Lynxs Real-Time UNIX
NeXTs NeXTStep
Santa Cruz Operations SCO UNIX
Silicon Graphics IRIX
SUN Microsystems SUN OS and Solaris
and dozens more.
The Open Standards Foundation is a UNIX industry organization designed to keep the various UNIX
flavors working together. They created operating systems guidelines called POSIX to encourage interoperability of applications from one flavor of UNIX to another. Portability of applications to different
gave UNIX a distinct advantage over its mainframe competition.
Then came the GUIs. Apples Macintosh operating system and Microsofts Windows operating
environment simplified computing tasks, and made computers more appealing to a larger number of
users. UNIX wizards enjoyed the power of the command line interface, but acknowledged the difficult
learning curve for new users. The Athena Project at MIT developed the X Windows Graphical User
Interface for UNIX computers. Also known as the X11 environment, corporations developed their own
flavors of the UNIX GUIs based on X11. Eventually, a GUI standard called Motif was generally accepted
by the corporations and academia.
During the late 1990s Microsofts Windows NT operating system started encroaching into traditional
UNIX businesses such as banking and high-end graphics. Although not as reliable as UNIX, NT became
popular because of the lower learning curve and its similarities to Windows 95 and 98. Many traditional
UNIX companies, such as DEC and Silicon Graphics, abandoned their OS for NT. Others, such as SUN,
focused their efforts on niche markets, such as the Internet.
Page 10 of 274
UNIX Basics
www.kerrneltech.com
Linus Torvalds had a dream. He wanted to create the coolest operating system in the world that was
free for anyone to use and modify. Based on an obscure UNIX flavor called MINIX, Linus took the source
code and created his own flavor, called Linux. Using the power of the Internet, he distributed copies of
his OS all over the world, and fellow programmers improved upon his work. In 1999, with a dozen
versions of the OS and many GUIs to choose from, Linux is causing a UNIX revival. Knowing that people
are used to the Windows tools, Linux developers are making applications that combine the best of
Windows with the best of UNIX.
UNIX Principles
Everything is a file:- UNIX system have many powerful utilities designed to create and
manipulate files. The UNIX security model is based around the security of files. By
treating everything as a file, you can secure access to hardware in the same way as you
secure access to a document.
Configuration data stored in text: - Storing configuration in text allows an administrator
to move a configuration from one machine to another easily, provide the ability to roll
back a system configuration to a particular date and time.
Small, Single-Purpose Programs: - UNIX provides many utilities.
Avoid captive user interfaces:Ability to chain programs together to perform complex tasks:- A core design feature of
UNIX is that output of one program can be the input for another. This gives the user the
flexibility to combine many small programs together to perform a larger, more complex
task.
www.kerrneltech.com
Linux Origins
LINUS TORVALDS
a) Finnish college student in 1991
b) Created Linux Kernel
When Linux Kernel combined with GNU applications, complete free UNIX like OS was
developed.
Why Linux?
1) Linux is a UNIX like OS: Linux is a similar to UNIX as the various UNIX versions are to each
other.
2) Multi-User and Multi-tasking: Linux is a multi-user and multi-tasking operating system.
That means that more than one person can be logged on to the same Linux computer at
the same time. The same user could even be logged into their account from two or
more terminals at the same time; Linux is also Multi-Tasking. A user can have more than
one program executing at the same time.
3) Wide hardware support: Red Hat Linux support most pieces modern x86 compatible PC
hardware.
4) Fully Supported: Red Hat Linux is a fully supported distribution Red Hat Inc. provides
many support programs for the smallest to the largest companies.
Page 12 of 274
www.kerrneltech.com
ARCHITECTURE OF UNIX
The architecture of UNIX can be divided into three levels of functionality, as shown in Figure . The lowest
level is the kernel , which schedules tasks , manages resources, and controls security. The next level is
the shell, which acts as the user interface, interpreting user commands and starting applications. The
highest level is utilities, which provides utility functions. In other words it is the USER level, as user is the
one who operates those utilities.
Page 13 of 274
www.kerrneltech.com
/root
/home
/boot
/etc
/usr
/opt
/bin
/sbin
Page 14 of 274
www.kerrneltech.com
/dev
/proc
/var
/mnt
/media
/lib
Page 15 of 274
www.kerrneltech.com
Recommended
Requirement for
RHEL6-32BIT
AMD/INTEL
DUAL CORE
NORMAL
1 GB
20 GB
Minimum
Requirement for
RHEL6-32 BIT
AMD/INTEL P IV
NORMAL
384-512 MB
15 GB
Recommended
Requirement for
RHEL6-64BIT
AMD/INTEL
CORE 2 DUO
VT ENABLED
2 GB
40 GB
Minimum
Requirement for
RHEL6-64BIT
AMD/INTEL
DUAL CORE
VT ENABLED
768-1GB
20 GB
Enter into BIOS setting and make CD/DVD Drive as first boot device
Make sure that VT (Virtual Technology) is enabled for RHEL6-64 bit systems
Insert the RHEL 6 CD/DVD into CD/DVD drive and boot the system
If booted from CD/DVD Rom the following screen will be displayed
Page 16 of 274
www.kerrneltech.com
Move the cursor to Install or upgrade an existing system and press Enter
To test the media select OK, to skip the testing move cursor to Skip and press enter
Page 17 of 274
www.kerrneltech.com
Page 18 of 274
www.kerrneltech.com
Select the keyboard type as required usually U.S English, click Next to continue
Select the type of storage for the Computer. Click Next to continue
Page 19 of 274
www.kerrneltech.com
Assign a hostname to the system, if wish to give ip address click on Configure Network, else
Click Next to continue
Select the nearest city in your Time Zone and Click on Next to continue
Page 20 of 274
www.kerrneltech.com
Select the type of partitioning you want, to create your own partitions with custom sizes,
select Create Custom Layout and click on Next to continue
Page 21 of 274
www.kerrneltech.com
Click on the Free space, then click on Create to create your own partitions
Page 22 of 274
www.kerrneltech.com
Select / from Mount Point Box, give the size you wish for it and click on OK to create it.
Select the Free space again and click on Create to create another partition. Also Check the
box beside Standard Partition, Click on Create to continue
Page 23 of 274
www.kerrneltech.com
Select /boot from Mount Point Box, give the size 200 MB for it and click on OK to create it.
This time select swap from File System Type, give the size required and click on OK
Page 24 of 274
www.kerrneltech.com
Click on Write changes to disk to continue, if wish make changes click on Go back.
Page 25 of 274
www.kerrneltech.com
To change the name of boot loader select Edit and assign new name to it.
To assign password to boot loader check the box beside Use boot loader password and
assign a password to it.
To keep all as default, just click on Next button to continue.
Page 26 of 274
www.kerrneltech.com
Page 27 of 274
www.kerrneltech.com
When above prompt is displayed, remove the CD/DVD from the drive and click on Reboot
to reboot the system.
Page 28 of 274
www.kerrneltech.com
www.kerrneltech.com
Check No, I prefer to register at a later time. to skip the registration and click on Forward.
Page 30 of 274
www.kerrneltech.com
Page 31 of 274
www.kerrneltech.com
Give a name to create a user and assign it a password. Click on Forward to continue.
Page 32 of 274
www.kerrneltech.com
Page 33 of 274
www.kerrneltech.com
BASIC COMMANDS
Page 34 of 274
www.kerrneltech.com
Creating a Directory:
#mkdir <dir name>
#mkdir ktdir
Linux
Aix
advlinux linuxclstr
hacmp lpar
Storage
san
netapp
#mkdir p KernelTech/{Linux/{advlinux,linuxclstr},Aix/{hacmp,lpar},Storage/{san,netapp}}
Check it by using tree command or ls R command
Page 35 of 274
www.kerrneltech.com
Page 36 of 274
www.kerrneltech.com
Renaming a File
#mv <old name> <new name>
#mv ktfile kernelfile
Renaming a Directory
The procedure and command for renaming the directory is exactly same as renaming a file.
#mv old name new name
#mv ktdir kerneldir
Page 37 of 274
www.kerrneltech.com
Removing a File
#rm filename or #rm f filename (without prompting)
Without prompting:
Page 38 of 274
www.kerrneltech.com
VIM EDITOR
VI
Visual display editor
VIM Visual display editor improved
This is command mode editor for files. Other editors in Linux are emacs, gedit
vi editor is most popular
It has 3 modes:
1
2
3
Command Mode
Insert mode (edit mode)
extended command mode
Note: When you open the vim editor, it will be in the command mode by default.
In the command mode the cursors can be used as
h/l/k/j to move cursor left/right/up/down
Insert Mode:
i
a
A
o
O
Command Mode:
gg
G
w
b
nw
nb
u
www.kerrneltech.com
U
Ctrl+R
yy
nyy
p
P
dw
x
dd
ndd
/
Page 40 of 274
www.kerrneltech.com
Types of Files:
Symbol
d
l
b
c
Type of File
Normal file
Directory
Link file (shortcut)
Block file (Harddisk, Floppy disk)
Character file (Keyboard, Mouse)
Symbolic Link
There are two types of Links:1
2
3
4
5
Soft Link
Hard link
Page 41 of 274
www.kerrneltech.com
To avoid case sensitivity of the word (i.e. the word may be uppercase of lowercase) use -i
#grep i kernel ktfile (lets grep the word kernel whether upper of lower case in the file ktfile)
Page 42 of 274
www.kerrneltech.com
Filter Commands:
Filter commands are used to filter the output so that the required things can easily be
picked up. The commands which are used to filter the output are
#less
#more
#head
#tail
#sort
#cut
#sed
Page 43 of 274
www.kerrneltech.com
less:The less command is used to see the output line wise or page wise.
Ex: less /etc/passwd
head:
It is used to display the top 10 lines of the file.
Ex:# head /etc/passwd
Page 44 of 274
www.kerrneltech.com
tail:
It is used to display the last 10 lines of the file
#tail /etc/passwd
Page 45 of 274
www.kerrneltech.com
Sort:
It is used to sort the output in numeric or alphabetic order
#sort filename
Page 46 of 274
www.kerrneltech.com
cut command:
The cut command is used to pick the given expression (in columns) and display the output.
# cut -d -f filename (where d stands for delimiter ex. : , etc and f stands for field)
Page 47 of 274
www.kerrneltech.com
sed command:
sed stands for stream editor, which is used to search a word in the file and replace it with the
word required to be in the output
Note: it will only modify the output, but there will be no change in the original file.
#sed s/searchfor/replacewith/g filename
I/O Redirection:
Redirection is a process where we can copy the output of any command(s), file(s) into a new
file. There are two ways of redirecting the output into a file.
Using > or >> filename after the command, and
Using tee command
Lets see the > and >> option first
Syn: command > new file
Note: if the given name of the file is not available a new file will be created automatically. If
the file already exists then it will overwrite contents of that file.
www.kerrneltech.com
Page 49 of 274
www.kerrneltech.com
Find command:
find command is used to find the files or directorys path, it is exactly like the find option in
windows where you can search for a file.
Syntax: find / (under root) option filename
Options that can be used with find command:
Option
-name
-inum
-type
-user
-group
Usage
For searching a file with its name
For searching a file with particular inode number
For searching a particular type of file
For files whose owner is a particular user
For files belonging to particular group
Page 50 of 274
www.kerrneltech.com
Page 51 of 274
www.kerrneltech.com
File Permissions:
Permissions are applied on three levels: Owner or User level
Group level
Others level
Access modes are of three types: r read only
w write/edit/delete/append
x execute/run a command
Access modes are different on file and directory:
Permissions
r
w
x
Files
Open the file
Write, edit, append, delete file
To run a command/shell script
Directory
'ls' the contents of dir
Add/Del/Rename contents of dir
To enter into dir using 'cd'
Filetype+permission, links, owner, group name of owner, size in bytes, date of modification,
file name
Permission can be set on any file/dir by two methods:1 Symbolic method (ugo)
2 Absolute methods (numbers)
1 Symbolic method (ugo):
Symbolic mode: General form of symbolic mode is:
# chmod [who] [+/-/=] [permissions] file
who To whom the permissions to be assigned
User/owner (u); group (g); others (o)
Example: Assigning different permissions to the file (user=rwx, group=rw and others=r)
#chmod u=rwx,g=rw,o=r ktfile (where ktfile is the name of the file)
Page 52 of 274
www.kerrneltech.com
Likewise you can add or remove permissions from any file for anyone (user group or other)
www.kerrneltech.com
Calculation of default permissions for file and directory, basing upon the umask value
Note: For a file by default it cannot have the execute permission, so the maximum full
permission for a file at the time of creation can be 666 (i.e. 777 -111 = 666), whereas a directory
can have full permissions i.e. 777
666
-022
644
(rw-,r--,r--)
Page 54 of 274
www.kerrneltech.com
777
- 022
755
Note: Create a file and a directory and check for the default permissions.
These were the few things amongst the basics; keep working to furnish your basics. After All,
if the foundation is good then only the building can stand still
Page 55 of 274
www.kerrneltech.com
What is a partition?
Partitioning is a means to divide a single hard drive into many logical drives. A partition is a contiguous
set of blocks on a drive that are treated as an independent disk. A partition table is an index that relates
sections of the hard drive to partitions.
Encapsulate your data. Since file system corruption is local to a partition, you stand to lose only
some of your data if an accident occurs.
Increase disk space efficiency. You can format partitions with varying block sizes, depending on
your usage. If your data is in a large number of small files (less than 1k) and your partition uses
4k sized blocks, you are wasting 3k for every file. In general, you waste on average one half of a
block for every file, so matching block size to the average size of your files is important if you
have many files.
Limit data growth. Runaway processes or maniacal users can consume so much disk space that
the operating system no longer has room on the hard drive for its bookkeeping operations. This
will lead to disaster. By segregating space, you ensure that things other than the operating
system die when allocated disk space is exhausted.
EXTENDED
P
L FREE
Page 56 of 274
www.kerrneltech.com
On the disk where O/S is installed, will have the first partition as MBR.
MBR is a Master Boot Record, which contains two important utilities, IPL (Initial
Program Loader) and PTI (Partition Table information)
IPL is responsible for booting the operating the system, because it contains the boot
loader.
In earlier versions of Linux i.e. up to RHEL 4, the default boot loader was LILO (Linux
Loader). But, since RHEL5 onwards it has been changed to GRub (Grand Unified Boot
loader), which is far more superior to LILO.
The PTI (Partition Table information) is the information about the number of partitions
on the disk, sizes of the partition and types of partitions.
Disk Identification:
Different type of disks will be having different initials in Linux
FILE SYSTEM:
It is method of storing the data in an organized fashion on the disk. Every partition on
the disk except MBR and Extended partition should be assigned with some file system
in order to make them store the data. File system is applied on the partition by
formatting it with a particular type of file system.
Page 57 of 274
www.kerrneltech.com
S.NO
Stands
1.
EXT2
EXT3
EXT4
for
Second Stands for Third Extended Stands for Fouth Extended
Extended File System
File System
File System
It was introduced in 1993 It was introduced in 2001
It was introduced in 2008.
Does not have journaling Supports Journaling
Supports Journaling
feature.
Feature.
Feature.
2.
3.
4.
5.
Cannot convert ext file You can convert an ext2 file All previous ext file systems
system to ext3 file system can easily be converted into
system to ext2.
directly
(without ext4 file system. You can also
6.
backup/restore).
MOUNTING:
Attaching a directory to the file system in order to access the partition and its file
system is known as mounting.
The mount point is the directory (usually an empty one) in the currently accessible file
system to which a additional file system is mounted.
The /mnt directory exists by default on all Unix-like systems. It, or usually its
subdirectories (such as /mnt/floppy and /mnt/usb), are intended specifically for use as
mount points for removable media such as CDROMs, USB key drives and floppy disks.
/etc/mtab is a file which stores the information of all the currently mounted file
systems; it is dynamic and keeps changing.
/etc/fstab is the file which is keeps information about the permanent mount point. If
you want to make your mount point permanent, so that it will be mounted even after
reboot, then you need to make an appropriate entry in this file.
Page 58 of 274
www.kerrneltech.com
Note: Observe in the above picture that the device name is /dev/sda .
Page 59 of 274
www.kerrneltech.com
Page 60 of 274
www.kerrneltech.com
Page 61 of 274
www.kerrneltech.com
Deleting a partition
Lets delete the partition weve created above i.e. /dev/sda7
Use d to delete a partition and specify the device name, in our case it is 7.
Now then we have learnt creating a partition. Lets see how to format a partition with a
particular file system.
Page 62 of 274
www.kerrneltech.com
Likewise you can format the different partitions with different file systems like
#mkfs.ext3 /dev/sda8
#mkfs.vfat /dev/sda9
Note: Even after formatting the partition we cannot add the data into the partition. In order
to add the data in the partition it is required to be mounted.
Page 63 of 274
www.kerrneltech.com
Mounting a partition
Mounting is a procedure where we attach a directory to the file system. There are two types of
mounting which will be used in Linux or any UNIX.
Temporary Mounting
Permanent Mounting
Temporary Mounting
In a temporary mount point we will create a directory and mount it, but this mount point will
last only till the system is up, once it is rebooted the mounting will be lost.
Syntax:
#mount <device name> <directory name (mount point)>
#mount /dev/sda7 /kernel
Now we have successfully mounted the partition we can access it and can store the data
To add the data access the mount point
#cd /kernel
Add the data and exit the directory
Unmounting a partition
#umount <mount point directory>
#umount /kernel
verify it with mount command.
Page 64 of 274
www.kerrneltech.com
Permanent Mounting
Permanent mounting procedure is exactly same like temp mounting, but here we will update
the /etc/fstab file with the mounting details, so that it will be mounted even after the system is
reboot.
Steps To make a permanent mount point:
Make a directory or use an existing directory
Add entry in /etc/fstab file
Use mount a command to check it is mounting. (mount a will mount all the entry
placed in /etc/fstab)
Here we will be using our existing /kernel directory as mount point which is created previously.
#vim /etc/fstab
Device Name
Mount Point
#mount a
Page 65 of 274
www.kerrneltech.com
You can now access the directory and add, delete or modify the contents and can also unmount
the file system at any point
Sometimes a directory reflects error while unmouting, the possible causes for it are
You are in the same directory and trying to unmount it. Check with pwd command
Some users are present in the directory and using the contents in it.
Check with fuser cu /dev/sda7
Check for the files which are open with lsof /dev/sda7
Kill the open connections using fuser ck /kernel/hello where hello is the file which is
open.
Now you can use umount command to unmount the file system.
To list all the mounted partition along with their labels, use mount l command
Page 66 of 274
www.kerrneltech.com
As we know that to make a permanent mount point, an entry has to be made in /etc/fstab
file.
#vim /etc/fstab
Now use mount a command and verify it with mount command whether it is mounted or
not.
#vim /etc/fstab
Now mount it with mount a command and verify it with mount command
Page 67 of 274
www.kerrneltech.com
Page 68 of 274
www.kerrneltech.com
Create a normal partition using fdisk and change hex code to make it swap partition.
The hex code for SWAP is 82. (To change the use t in fdisk and list all the hex code use l)
Update the partition table using partx a command
Page 69 of 274
www.kerrneltech.com
Page 70 of 274
www.kerrneltech.com
Page 71 of 274
www.kerrneltech.com
Page 72 of 274
www.kerrneltech.com
#vim /etc/crypttab
7.
Unmount the partition, and close the partition i.e. encrypt it back
# umount /dev/mapper/ktpart
#cryptsetup luksClose /dev/mapper/ktpart
#mount a (To check encryption is working)
Page 73 of 274
www.kerrneltech.com
When you assign the label of the partition in the /etc/crypttab, the system will be
halted at the time of boot and will ask you to enter the passphrase of that particular
partition so that the partition can be decrypt and mounted.
Either you should type the passphrase to continue or can ignore it by using ctrl+c to
continue booting without decrypting and mounting the partition.
In order to make the O/S to take the passphrase automatically and unlock the partition,
we can save the passphrase in a file, so that it can take the passphrase and mount it and
boot it normally without halting.
Change the permission of the file (600), and add the path of the file in /etc/crypttab
Note: The permission of the file is changed so that groups and others may not be able to view
and modify the contents of the file.
After making the above changes, restart the system and check whether it is halting to ask you
passphrase or booting continuously. It will not ask any passphrase for sure.
www.kerrneltech.com
www.kerrneltech.com
Logical Volume (LV) is composed of a group of LEs. You can format and mount any file system
on an LV. The size of these LVs can easily be increased or decreased as per the requirement .
Logical Extent (LE)
It is also a chunk of disk space. Every LE is mapped to a specific PE.
LVM Command
pvs
vgs
lvs
pvdisplay
vgdisplay
lvdisplay
pvcreate
vgcreate
lvcreate
vgextend
lvextend
lvresize
lvreduce
pvmove
vgreduce
pvremove
vgremove
lvremove
Function
Displays all the physical volumes
Displays all volume groups in the system
Displays all the logical volumes in the system
Displays detailed information on physical volumes
Displays detailed information on volume groups
Displays detailed information on logical volumes
Create a new physical volume
Create a new volume group.
Creates a new logical volume
Add a new physical disk to a volume group.
Extends a logical volume
Resizes a logical volume
Reduces a logical volume
Moves/migrates data from one physical volume to another
Reduces a volume group by removing a PV from it.
Deletes a physical volume
Removes /Deletes a volume group
Removes /Deletes a logical volume
Page 76 of 274
www.kerrneltech.com
The above command will list all the PVs in the system, if you want to see the details only for
a particular PV, then use
#pvdisplay <partition name> i.e. #pvdisplay /dev/sda7
Page 77 of 274
www.kerrneltech.com
To check all the VGs detail you can also use the command
#vgdisplay
It will list out all the VGs in the system in detail.
Page 78 of 274
www.kerrneltech.com
Once we are ready with a Volume Group then its the time to create a Logical Volume LV
The syntax for creating an LV is
#lvcreate L <size of LV> -n <name for LV> <VG name>
#lvcreate L 300M n ktlv ktvg (To create a LV of 200MB)
Note: The output for only lvdisplay command is very lengthy to show, it is recommended
that you run the command on the system and check it out. The syntax is given above.
Page 79 of 274
www.kerrneltech.com
Mounting:
Mounting an LV is exactly same like a normal partition, again the path for mounting will be
/dev/vg/lv
Create a directory over which the LV should be mounted.
#mount </dev/vgname/lvname> /directory name
#mount /dev/ktvg/ktlv /ktdir
Verify the mounting with mount command
Make it a permanent mount by making an entry in /etc/fstab
#vim /etc/fstab
www.kerrneltech.com
Page 81 of 274
www.kerrneltech.com
Verify it by df h
www.kerrneltech.com
Finally reduce the size of the LV using lvreduce command. It will prompt you about the change
We know the size of LV is around 500MB, from previous picture in case of extending the size of LV.
Or else you can run df h and verify it again.
Umount the LV by using umount command
Mount the LV and run the command df-h, to verify the change in the size of LV
#mount a ( if an entry is passed in /etc/fstab use this command)
#df h
Page 83 of 274
www.kerrneltech.com
Access the mount point of the failing PV and check the data in it,
Page 84 of 274
www.kerrneltech.com
Add new PV which should be of the same size or higher than that of the replacing PV to
the volume group.
In our case the size of the failing PV is around 500MB, so we need to add a PV whose size is
at least 500MB or more
I have created another partition from fdisk i.e. /dev/sda7 with the size around 500MB
Mount back the LV, access the mount point and verify the data in it.
Page 85 of 274
www.kerrneltech.com
Deleting/Removing an LV:
As we was having only one LV and that is now deleted, thats why it is not showing any LVs
after executing lvdisplay command.
To delete the volume a group, make sure that if there is any LV in it, it should not be
mounted. Because while removing a vg it will also remove LVs inside it. In our case we have
no LV in our volume group, so we will not be concerned about it.
To delete a VG, use the following command.
#vgremove <vgname>
#vgremove ktvg
Deleting a PV is very simple. The only thing we should check that the PV we are going to
delete should not belong to any volume group. We can only delete a PV which is free.
The syntax to delete a PV is
#pvremove <PV name>
#pvremove /dev/sda6
#pvremove /dev/sda7 OR
#pvremove /dev/sda{6,7} (To remove multiple PVs in one command)
www.kerrneltech.com
Page 87 of 274
www.kerrneltech.com
Okay, now then we know the size of PE is 16, lets calculate how many LE is required to
create an LV of 400 MB.
The formula for calculating no. of LE is
<size of LV required, in MB> divided by Size of PE
400/16 = 25
If the size of LV is to be 2 GB then first we need to convert GB into MB and then calculate
2x1024 / 16 =128.
You can use #bc command to do all the calculations. Use ctrl+d or Ctrl+c to quit the
calculator
Page 88 of 274
www.kerrneltech.com
So now we got the calculation done and we came to know that 25 LEs are required to
create 400MB of LV.
The syntax to create an LV with no. of LE is
#lvcreate l <no. of LE> -n <name for the LV> <volume group name>
#lvcreate l 25 n ktlv2 ktvg2
The only difference in a normal installation and LVM installation is that instead of creating
normal partition we will create a VG and then LVs for all partitions, except /boot and swap.
The advantage of installing Linux using LVM is that, if any of system partition is running out
of space and required more space, in case of normal partitioning it is not possible to
increase the size of a partition once it is created. But, using LVM the space can be
dynamically increased whenever it is required.
Even if there is no space remaining in the disk some space can be borrowed from other
LVMs and can easily be assigned to required system partition to fulfill its need.
LVM provides a greater scalability to the administrator and avoid uncertain down time to
the server.
LVM ensures the possibility of increasing and decreasing the sizes whenever required and
prevents unnecessary loss of time.
Page 89 of 274
www.kerrneltech.com
Start the installation normally as done previously, but only at the time of partitioning follow
the steps below.
Select the Free space and click on Create, then select LVM Physical Volume and click on
Create to proceed.
Give the maximum possible size to this PV, as all the partition has to be created inside it
only.
Page 90 of 274
www.kerrneltech.com
Select the created PV, i.e., vda1 and this time check the box beside LVM Volume Group to
create a volume group.
Click on Add button to start adding LVs, Select a mount point and assign a size to it and click
on OK
Page 91 of 274
www.kerrneltech.com
Repeat the above step and create the following partitions with the given sizes
/usr with 8.5 GB approx
/var with 4.5 GB approx
/opt with 2 GB approx
/, /tmp, /home 2 GB each approx
/opt 3 GB approx
Note: All the sizes listed above are based on the availability of the space. It is no where a
recommended or minimum sizes. The sizes can be based on your requirements. But /usr
required the above given size if it is 64 bit architecture.
Select the Free space under Hard Drives and create /boot with 200 MB and /Swap with
2GB. Make sure that you select Standard Partition this time, instead of LVM.
Page 92 of 274
www.kerrneltech.com
Verify the sizes and click on Next to continue with the installation. Complete the installation
as usual as we have done previously at the beginning of the course.
Practice the LVM Concept well; as it is the most important part in Linux and
in any UNIX operating system as well.
That sums up the LVM concept in Linux
Page 93 of 274
www.kerrneltech.com
Users and groups are used to control access to files and resources
Users login to the system by supplying their username and password
Every file on the system is owned by a user and associated with a group
Every process has an owner and group affiliation, and can only access the resources its
owner or group can access.
Every user of the system is assigned a unique user ID number ( the UID)
Users name and UID are stored in /etc/passwd
Users password is stored in /etc/shadow in encrypted form.
Users are assigned a home directory and a program that is run when they login (Usually a shell)
Users cannot read, write or execute each others files without permission.
TYPE
EXAMPLE
USER ID (UID)
GROUP ID
(GID)
HOME
DIRECTORY
SHELL
Super User
Root
/root
/bin/bash
System User
ftp, ssh,
apache
nobody
Visitor,
ktuser,etc
1 to 499
1 to 499
/var/ftp , etc
/sbin/nologin
500 to 60000
500 to 60000
/home/user
name
/bin/bash
Normal User
Page 94 of 274
www.kerrneltech.com
www.kerrneltech.com
2. /etc/shadow
root:$1fdsfsgsdfsdkffefje:14757:0:99999:7:::
The fields are as follows,
1. root = User name
2. :$1fdsfsgsdfsdkffefje = Encrypted password
3. 14757 = Days since that password was last changed.
4. 0 = Days after which password must be changed.
5. 99999 = Days before password is to expire that user is warned.
6. 7 = Days after the password is expires that the user is disabled.
7. A reserved field.
A root user can change password of self and of any user in the system, there are no rules for
root to assign a password. Root can assign any length of password either long or short, it
can be alphabet or numeric or both. On the whole there is no limitation for root for
assigning a password.
A normal user can change only its password. Valid password for a normal user should adhere to
Note: For security reasons dont keep the password based on date of birth because it can easily be
hacked.
www.kerrneltech.com
When no option is used with useradd command the options like UID, GID, home dir and
shell will be assigned default.
#useradd <username>
#useradd ktusr
Observe that the uid, gid, home dir, and shell is assigned automatically.
Lets create a user with our own attributes
Page 97 of 274
www.kerrneltech.com
After creating a user if we need to modify the attributes of user like changing uid, changing
secondary group id or adding a comment, locking or unlocking the user account, can be
done by following command
Page 98 of 274
www.kerrneltech.com
Observe in both pictures that once the account is unlocked the exclamation is gone.
Page 99 of 274
www.kerrneltech.com
Last password change: When the password was change last time.
Password expires: Password expiry date
Password inactive: After password expiry grace period before the account gets locked.
Account expires: Date on which the account expires.
Minimum number of days b/w password change: once the password is changed, it cannot
be changed until a min period of specified date. [0] means never.
Max number of days b/w password change: After changing the password how long it will
be valid for.
Number of days of warning before password expires: start of warnings to change the
password, no. of days before the password expires.
www.kerrneltech.com
#chage ktusr
The second method is for, if you want to change a particular field of password aging policy
#chage <option> <value> <username>
The options which can be used are as follows
-m for Min password age
-M for Max password age
-d for last time the password is changed.
-W Password expiration warnings
-I Password inactive [-1 means inactive].
-E A/C expiration date
Lets see how to change only the account expiration date
Likewise you can use any option listed above and change any particular field in password aging
parameters.
Page 101 of 274
www.kerrneltech.com
Deleting a User:
Were now done with user administration, lets see whats in part-II
www.kerrneltech.com
Users are assigned to groups with unique group ID numbers (the GID)
The group name and GID are stored in /etc/group
Each user is given their own private group
They can also be added to their groups to gain additional access
All users in a group can share files that belong to the group
Each user is a member of at least one group, called a primary group. In addition, a user can be a
member of an unlimited number of secondary groups. Group membership can be used to
control the files that a user can read and edit. For example, if two users are working on the
same project you might put them in the same group so they can edit a particular file that other
users cannot access.
A users primary group is defined in the /etc/passwd file and Secondary groups are defined
in the /etc/group file.
The primary group is important because files created by this user will inherit that group
affiliation.
www.kerrneltech.com
www.kerrneltech.com
Adding the members to the group is to add users to the group. To add the members to the
group the syntaxes are
To add single user to the group
#usermod G <group name > < user name>
#usermod G ktgroup ktuser
Adding multiple single or multiple users to the group with various attributes
#gpasswd < option> <arguments> <group name>
Options:
-M For Adding Multiple users to a group
-A for Adding a group Administrator
-a for Adding a single user to a group
-d removing a user from a group
www.kerrneltech.com
To add and remove groups use can also use the graphical tool in linux
#system-config-users &
www.kerrneltech.com
Note: observe that in the permissions rwsr-xr-x it contains an s, which means SUID is
placed.
Lets remove suid on Ping command and logged in as normal user and check the results
www.kerrneltech.com
Example
When a directory is created and its group is set to some group. Now if SGID is applied to it,
and the group member creates files and directory inside it, then it will get the same group
rather than getting users primary group
Lets see it practically.
Note: when a file is created by any user it will get the group as primary group of the owner
which is usually owners private group with same name.
STICKY BIT
If sticky bit is applied on a file or directory, then only root and owner of that file or directory can
delete it. Even if others are having full permissions they cannot delete the file or directory.
Let see it practically.
www.kerrneltech.com
Define more fine-grained discretionary access rights for files and directories.
Often, you want to share files among certain groups and specific users. It is a good practice
to designate a directory for that purpose. You want to allow those groups and users to read,
and write files in that directory, as well as create new files into the directory. Such special
permissions can be given using ACL.
ACL can be applied on ACL enabled partition that means you need to enable ACL while
mounting the partition.
www.kerrneltech.com
If your partition already exists, then just add an acl after defaults as shown above and use
the following command.
#mount o remount /dev/sda7
Now lets assign full permission to the directory and then apply acl on it, so that we can
analyze how acl will work.
Okay, now we are ready to apply acl, but first lets understand the command and option in
details.
The syntax to apply acl is
#setfacl <option> < argument > < file or directory name >
The options are,
-m Modifies an ACL
-x Removes an ACL
-R Recurses into subdirectories
www.kerrneltech.com
Note: Whatever ACL permissions assigned to a user or group or others, it will be treated as
Normal Permissions minus ACL
To assign read and execute permission to a particular user the syntax could be
#setfacl m u: <username>: <permissions> <file or dir name>
#setfacl m u:ktuser: rx ktdir
Verify it by using getfacl command
Now login as ktuser and try to create a file inside ktdir, as we have not assigned write
permission to ktuser, though it is having full permissions, still it will not allow ktuser to
create a file inside it.
Observe that when you check for the permissions it is showing a + sign after normal permission,
that indicate that ACL is applied on this directory.
www.kerrneltech.com
Now you know how to apply acl on any file or directory, let me just give one more examples
which you can broaden your understandings.
Assigning read and execute permission for a user and a group at same time.
#setfacl m u:ktuser:rx,g:ktgroup:rx /ktdir
Likewise you can explore applying acl to any user, group, or others in many ways.
Removing acl for a particular user
#setfacl x u:<username> <dir name>
#setfacl x u:ktuser /ktdir
www.kerrneltech.com
ACL can also be applied to a file in exactly similar fashion as we did for a directory.
This part confirms the end of USER ADMINISTRATION
Page 113 of 274
www.kerrneltech.com
Media is the medium via which two different computers NIC card will be connected. The
best example for media is Cable. Example RJ 45, CAT 5 etc.
3. Topology
Topology is the scheme or design in which the computers in the network will be connected
to each other. Example for topology is Bus, Ring, star, mesh, tree topologies. The following
pictures explain it better.
www.kerrneltech.com
4. Protocol
A network protocol defines rules and conventions for communication between network
devices. Protocols for computer networking all generally use packet switching techniques to
send and receive messages in the form of packets.
Network protocols include mechanisms for devices to identify and make connections
with each other, as well as formatting rules that specify how data is packaged into messages
sent and received. Some protocols also support message acknowledgement and data
compression designed for reliable and/or high-performance network communication.
Hundreds of different computer network protocols have been developed each designed for
specific purposes and environments.
Example for Protocols are TCP/IP (Transmission Control Protocol), UDP (User Datagram
Protocol), HTTP. The most widely and regularly used protocols for transferring data are TCP
and UDP. Lets analyze some basic differences between TCP/IP and UDP.
TCP/IP
Transmission Control Protocol
It is connection Oriented
Reliable
TCP Acknowledgement will be sent/received
Slow Communication
Protocol Number for TCP is 6
HTTP, FTP, SMTP uses TCP
UDP
User Datagram Protocol
Connectionless
Non-Reliable
No Acknowledgement for UDP
Faster Communication
Protocol Number for UDP is 17
DNS, DHCP uses UDP
5. IP ADDRESS
An IP address can be thought of as being similar to a phone number. Just as every person who
communicates with a telephone is using a phone with a unique phone number, every computer that
is on the Internet has a unique IP address. Not only on internet but within an organization every
computer is assigned an IP address so that they can communicate with each other. Basically IP
addressing is very deep concept. To understand the concept of IP address we need to understand
some important aspect of IP Address which is
IP Address Classes
Subnet mask
Gateway
The above concepts in IP Addressing are very important to understand networking clearly.
www.kerrneltech.com
IP Address Classes
The IP addresses are further broken down into classes. These classes are A, B, C, D, E and their possible
ranges can be seen in Figure below.
Subnet Mask
A subnet mask allows users to identify which part of an IP address is reserved for the network
and which part is available for host use. By looking at the IP address alone, especially now with
classless inter-domain routing, users cannot tell which part of the address is which. Adding the
subnet mask or netmask gives users all the information needed to calculate network and host
portions of the address with ease. In summary, knowing the subnet mask can allow users to
easily calculate whether IP addresses are on the same subnet or not.
A commonly used netmask is a 24-bit netmask as seen below.
Netmask:
255.
255.
255.
Binary:
11111111
11111111
11111111
00000000
Netmask length
16
24
--
www.kerrneltech.com
Gateway
A gateway is a network point that provides entrance into another network. On the Internet, a
node or stopping point can be either a gateway node or a host (end-point) node. Both the
computers of Internet users and the computers that serve pages to users are host nodes. The
computers that control traffic within your company's network or at your local Internet service
provider (ISP) are gateway nodes.
For example lets say our network is 192.168. something and we want to
send a file to other computer on 10.10.network, so we need a gateway to communicate
between two computers of different networks.
#/etc/sysconfig/network is a file which keeps the information about the hostname assigned to
the system. If you want to change the hostname permanently, you need to change the
hostname in this file.
#/etc/hosts a file which is responsible for resolving hostname into IP locally, in other word it
acts as local DNS if DNS server is not accessible.
#/etc/resolv.conf is a file which keeps the address of DNS server to which the clients will be
accessing to resolve IP to hostname and hostname to IP.
www.kerrneltech.com
LAB WORK:
www.kerrneltech.com
#host <hostname>
#host ktlinux.kt.com
www.kerrneltech.com
With ip address
#dig x <ip address>
#dig x 192.168.10.98
www.kerrneltech.com
Note: The above change is temporary and will be last only till you are logged in, if you want to
change it permanently edit the /etc/sysconfig/network file and then logout and login to
confirm the change.
#vim /etc/sysconfig/network delete the previous hostname and add the new name.
Note: Once you logout and login again the change will be permanent, observe the highlighted
region above.
www.kerrneltech.com
Now select the NIC adapter i.e. eth0 and press Enter
Assign the above ip address and other details as per your requirement, move the cursor to
OK and press Enter
Page 122 of 274
www.kerrneltech.com
Move the cursor to save to save the changes in device configuration and press Enter.
Once again move the cursor to Save&Quit button and press Enter
Finally Move the cursor to Quit button and Press Enter to quit the utility.
Page 123 of 274
www.kerrneltech.com
Now restart the network service and check for the ip address
#service network restart
If the change is not reflected with above service restart, restart the network manager
#service NetworkManager restart (N and M are case sensitive)
The above picture confirms that we have successfully assigned an IP address to a machine.
You can also check the functioning of newly assigned IP address by pinging it from other
machines in the network.
If it is not pinging from outside then check whether the cable is connected properly or
not.
If the server is in the remote location use #mii-tool to check whether the cable is
connected or not
[root@kernellinux]# mii-tool
eth0: negotiated 100baseTx-FD, link ok
www.kerrneltech.com
SELinux is a security enhancement to Linux that allows users and administrators more
control over which users and applications can access which resources, such as files.
Standard Linux access controls, such as file modes (-rwxr-xr-x) are modifiable by the
user and applications that the user runs, whereas SELinux access controls are
determined by a policy loaded on the system and not changeable by careless users or
misbehaving applications.
SELinux also adds finer granularity to access controls. Instead of only being able to
specify who can read, write or execute a file, for example, SELinux lets you specify who
can unlink, append only, and move a file and so on. SELinux allows you to specify access
to many resources other than files as well, such as network resources and inter-process
communication (IPC).
SELinux provides a flexible Mandatory Access Control (MAC) system built into the Linux
kernel. Under standard Linux Discretionary Access Control (DAC), an application or
process running as a user (UID or SUID) has the user's permissions to objects such as
files, sockets, and other processes. Running a MAC kernel protects the system from
malicious or flawed applications that can damage or destroy the system. The following
picture explains more detailed about both Access controls.
www.kerrneltech.com
www.kerrneltech.com
Modes of SELinux
There are three modes in which SELinux can be at a time, they are
Enforcing
Enable and enforce the SELinux security policy on the system, denying access and
logging actions
Permissive
Permissive mode is similar to Debugging Mode. In Permissive Mode, SELinux policies and
rules are applied to subjects and objects, but actions ( for example, Access Control denials)
are not affected. The biggest advantage of Permissive Mode is that log files and error
messages are generated based on the SELinux policy implemented.
Disabled
SELinux is turned off and no warn and log messages will be generated and stored.
Booleans
Booleans are variables that can either be set as true or false. Booleans enhance the effect of
SELinux policies by letting the system administrator fine tune a policy. A policy may protect
a certain daemon or service by applying various access control rules. In real world scenarios,
a system administrator would not like to implement all the access controls specified in the
policy.
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 processes. It uses roles to limit the domains that can be
entered, and has user identities to specify the roles that can be attained. In essence, types
and domains are equivalent, the difference being that types apply to objects while domains
apply to processes.
SELinux Context
Processes and files are labeled with a SELinux context that contains additional information,
such as a SELinux user, role, type, and, optionally, a level.
www.kerrneltech.com
#sestatus
www.kerrneltech.com
Observe that the type is admin_home_t, lets change it to public_content_t, so that it will be
available for all users.
To change the context of a file or directory the syntax is
#chcon t <argument> <file/dir name>
#chcon t public_content_t ktfile
To change the context for a directory and its contents, the syntax is
#chcon R t <argument > <dir name>
#chcon R t public_content_t ktdir
www.kerrneltech.com
To restore back the same of a directory with its contents, the syntax is
#restorecon Rv <dir name >
#resotrecon Rv ktdir
Note: For restoring the context of only the dir except its contents do not add R in the
command.
Page 130 of 274
www.kerrneltech.com
www.kerrneltech.com
Now, edit the configuration file, restart the computer and check the status.
#vim /etc/selinux/config
#init 6 (to reboot the system)
To Enable it back the procedure is exactly same as above, instead of SELINUX=disabled change
it to SELINUX=enforcing or permissive. Dont forget to restart the system, unless the system is
rebooted the changes will not take effect.
www.kerrneltech.com
To change any Boolean just copy the Boolean and give the option (the only possible option
for a Boolean to enable and disable is on/off). The syntax for changing Boolean value is
#setsebool < Boolean > < option (on/off) >
#setsebool allow_ftpd_anon_write on
Verify the change with getsebool command.
Hope you got the SELinux concept cleared by this time. Keep working on it
Page 133 of 274
www.kerrneltech.com
1. BIOS
www.kerrneltech.com
2. MBR
3. GRUB
As you notice from the above info, it contains kernel and initrd image.
So, in simple terms GRUB just loads and executes Kernel and initrd images.
Page 135 of 274
www.kerrneltech.com
4. Kernel
Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ps ef | grep init and check the pid.
5. Init
1.
2.
3.
4.
5.
6.
6. Runlevel programs
When the Linux system is booting up, you might see various services getting started. For
example, it might say starting sendmail . OK. Those are the run level programs,
executed from the run level directory as defined by your run level.
Depending on your 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/
www.kerrneltech.com
Please note that there are also symbolic links available for these directory under /etc
directly. So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.
www.kerrneltech.com
To start the graphical interface when you are in runlevel 3, use the following command
#startx
Change it back to runlevel 5 and reboot the system.
www.kerrneltech.com
www.kerrneltech.com
Move the cursor to 2nd line (line of Kernel) and press e to edit the kernel parameter
Type 1 after the line to boot in maintenance level and press enter to continue
Now, type b to boot it in single user mode. Then you will be in single user mode
Page 140 of 274
www.kerrneltech.com
Now without being prompted for password you will be logged in the single user mode
To change the password use command #passwd, but as you can see it will not work because
of SELinux.
Check the SELinux mode by using #getenforce command
As we can see that SELinux is in Enforcing mode, change it to Permissive and then try
changing the password
Okay, Now we are successfully changed the password, now just type exit or reboot, to
reboot the system and try the new password for root.
www.kerrneltech.com
There might be a situation where your boot loader i.e., GRub might got corrupted and you
want to recover it or in other word repair it. Basically the repairing of GRub means
installing a new grub on the existing one from RHEL 6 DVD.
To recover the grub the steps are:
Insert the RHEL 6 DVD and make the system boot from CD/DVD
Boot the system in Rescue installed system Mode.
Select the language with which you want to continue and move cursor on OK, press Enter.
Page 142 of 274
www.kerrneltech.com
Select the keyboard Type and move cursor to OK and press Enter to continue.
Select Local CD/DVD to make the sytem boot from it. As the systems bootloader is
corrupt.
www.kerrneltech.com
Move the curor to Continue tab, to mount the root from CD/DVD. Press Enter
Observe from above pic, that now your system has been mounted on /mnt/sysimage. It
means where our system root is residing
Move the cursor to OK and press Enter to continue.
www.kerrneltech.com
Select shell start shell and move cursor to OK to start the shell
You can observe that a shell prompt is displayed
Page 145 of 274
www.kerrneltech.com
Check that on which partition does your /boot is using #fdisk l or parted l command
Install the grub on the /boot device i.e. /dev/vda2 by using following command
#grub-install <device name>
#grub-install /dev/vda2
If it shows no error reported, that means we have successfully recovered the grub.
www.kerrneltech.com
Listing out the Modules (Drivers) and blacklisting the USB and CDROM Driver:
To search all the kernel modules in the system using find command
All the kernel modules in the system will be ending with .ko extension, so lets search it
using find command
#find / -name *.ko
Note:- Observe that all the modules listed are in /lib/modules only. All modules may be
supported or currently loaded modules.
www.kerrneltech.com
www.kerrneltech.com
To install/re-install a module
To install a module use the following command
#modprobe <mod name>
#modprobe fat
To disable a USB/CD-ROM drive driver, first check whether a driver is loaded or not
#lsmod |grep i usb
If it is not loaded, connect the USB drive to the system and wait for it to get loaded, then
check it again whether the module is loaded or not
#lsmod |grep i usb
www.kerrneltech.com
You can navigate through /media/E817.. and verify whether it is correct device or not.
Now as we know the module name just remove the module
#modprobe r usb_storage
The error showing above is because the drive is mounted, unmount it and try removing
module again
As we have successfully removed the module, now place the module name in
/etc/modprobe.d/blacklist.conf file so that it may not be loaded in future.
#vim /etc/modprobe.d/blacklist.conf
Now again try connecting the drive and check whether the USB is loading or not
Note: - The procedure for black listing CD-ROM is exactly same. Try it yourselves
To remove the USB/CD-ROM from black list
Remove the entry from /etc/modprobe.d/blacklist.conf
Connect the drive and install the module for USB and check whether it is mounting or not
www.kerrneltech.com
JOB AUTOMATION
Automation with cron and at
In any operating system, it is possible to create jobs that you want to reoccur. This process,
known as job scheduling, is usually done based on user-defined jobs. For Red Hat or any
other Linux, this process is handled by the cron service or a daemon called crond, which can
be used to schedule tasks (also called jobs). By default, Red Hat comes with a set of
predefined jobs that occur on the system (hourly, daily, weekly, monthly, and with arbitrary
periodicity). As an administrator, however, you can define your own jobs and allow your
users to create them as well.
The importance of the job scheduling is that the critical tasks like taking backups, which the
clients usually wants to be taken in nights, can easily be performed without the
intervention of the administrator by scheduling a cron job. If the cron job is scheduled
carefully than the backup will be taken at any given time of the client and there will be no
need for the administrator to remain back at nights to take the backup.
Crontab format
To assign a job in the Crontab file the format used is the following
www.kerrneltech.com
Options
Explanation
*/5
Is treated as ever 5 minutes, hours, days, or months. Replacing the 5 with another
numerical value will change this option.
2,4,6
9-17
Treats for any value between 9 and 17. So if placed in day of month this would be
days 9 through 17. Or if put in hours it would be between 9 and 5.
Crontab Commands
Command
crontab e
crontab l
crontab r
crontab -u
Explanation
Edit your crontab file, or create one if it doesnt already exist.
Display your crontab file.
Remove your crontab file.
If combined with e, edit a particular users Crontab file and if
combined with l, display a particular users crontab file. If
combined with r, deletes a particular users Crontab file
www.kerrneltech.com
Setting a job to display the current date for every minute on present console
To set the above job the steps are
Check the console on which you are working by following command
#tty
Wait for a minute and check whether time is displaying or not. Every min time will be
displayed as below.
Schedule a cron job to create a directory ktdir under /root on Sunday 22 October at 1:30
AM
To schedule above job edit the crontab file as shown below and restart the service
#crontab e
www.kerrneltech.com
Schedule a job to run the backup script bkpscript.sh on every Saturday 12:30 PM
In order to schedule above job the steps are.
Check the location of script and also check whether it is having execute permission or not. If
not then add the execute permissions to all user on it.
www.kerrneltech.com
Schedule a job so that a user ktuser should get the mail from 15 th to 20th and 25th to 30st
November as a reminder of some session at 2:25 PM
This task is very much similar to the previous one but there is only a small change in format.
#crontab e u ktuser
There are still various method you can schedule the cron jobs, Do some R&D on it to find
out more.
If again want to allow them to use cron job facilities just remove their names from
/etc/cron.deny file.
Page 155 of 274
www.kerrneltech.com
Allow only two users musab and rahul to use cron jobs out of all the users in the system
Assuming that we have 100 users in our system, putting all 98 names in /etc/cron.deny file
is a time consuming process. Instead of that, we can create one more file /etc/cron.allow,
in which we can assign names of those users who are allowed to use cron jobs.
Remove the /etc/cron.deny file and create /etc/cron.allow, still if both files are existing
cron.allow file will be having precedence over cron.deny file. Just to avoid confusion it is
good to remove cron.deny file
Note: /etc/cron.deny file exists by default, but we need to create /cron.allow file. If your name
is not there in cron.allow file then you will not be allowed to use cron jobs, and as mentioned
above, if both files are existing cron.allow file will be having precedence over cron.deny file. If
neither cron.deny nor cron.allow files exists then only root can use cron jobs.
Now, lets put those two users musab and rahul name in /etc/cron.allow file and check
the results.
#vim /etc/cron.allow
Note: To see man pages on cron job use #man 4 crontabs command
Page 156 of 274
www.kerrneltech.com
AT JOBS
at is used to schedule the job for a particular time or interval, in other words it is used
only for one time or only for one interval.
The disadvantages of at jobs are
It can be modified like cron jobs
It cannot be reused
The content cannot to viewed in normal human readable format
Schedule at job to display current date on current console now
To schedule above job using at first check the console
#tty
Schedule at job to get a mail at 10.30 AM till three days from now for a meeting
#at 10.30am + 3days
Note: See man pages man at for more on at jobs and formats.
Page 157 of 274
www.kerrneltech.com
To remove a job
check the job id
To remove a job the syntax is
#atrm < job id >
#atrm 17
#atrm 18
To restrict a user from using at jobs it is exactly same like cron job
Add user names to /etc/at.deny , it will work like exactly like /etc/cron.deny
To allow only few out of many users remove at.deny like we did for cron.deny and create
/etc/at.allow and add user names who are allowed to use at jobs in it, like cron.allow
If both at.allow and at.deny exists, then at.allow will have higer priority.
If neither at.allow nor at.deny exits, then only root can use at jobs.
All the above are few examples to use cron jobs and at jobs, do some constant R&Ds to
know more about it.
Page 158 of 274
www.kerrneltech.com
These two diagrams above show how a telnet session can be viewed by anyone on the network
by using a sniffing program like Ethereal (now called Wireshark) or tcpdump. It is really rather
trivial to do this and so anyone on the network can steal your passwords and other information.
The first diagram shows user jsmith logging in to a remote server through a telnet connection.
He types his username jsmith and password C0lts06! which are viewable by anyone who is
using the same networks that he is using.
The second diagram shows how the data in an encrypted connection like SSH is encrypted on
the network and so cannot be read by anyone who doesn't have the session-negotiated keys,
which is just a fancy way of saying the data is scrambled. The server still can read the
information, but only after negotiating the encrypted session with the client.
www.kerrneltech.com
The first time around it will ask you if you wish to add the remote host to a list of known_hosts,
go ahead and say yes.
Enter the password of the remote system correctly, once logged in check hostname and ip
address to confirm login.
To leave the session, just type exit or logout command and you will be back to your own
machine through which you are logged in.
www.kerrneltech.com
As a system administrator, one person will be assigned to manage many systems, for
example one person has to manage more than 10 systems at a time. In this situation admin
has to transfer some files from one system to another 9 systems or vice versa, for every
login on remote system it will prompt for password. Even for transferring files for every
transfer we need to enter the password.
Above situation will be very annoying for system admin to type password for every step.
Therefore SSH provides a best way to escape password prompting every now and then.
By generating SSH keys, a public key and a private key, an admin can copy the public key
into other system and done, it will work as authorized access from the admins system. Now
whenever we are logging from admins system to other system in which we have stored the
public key of admins system, it will not prompt us for password and we can login to that
system as many time as we want without being prompt for the password.
SSH keys are an implementation of public-key cryptography. They solve the problem of
brute-force password attacks by making them computationally impractical.
Public key cryptography uses a public key to encrypt data and a private key to decrypt it.
LAB WORK
Generating SSH key pair
It will prompt above to mention the file where these keys shoud be stored, to keep its default
directory just press Enter. The default location will be /root/.ssh/ directory
Now it will ask for passphrase, which will be used instead of password. The passphrase will only
be asked once per session. Enter your desired passphrase twice as shown on next page, and
press enter.
www.kerrneltech.com
Okay now our keys are successfully generated, go to /root/.ssh/ directory and check for the
keys.
#cd /root/.ssh
The id_rsa is a private key and id _rsa.pub is the public key which will be used later to make
password less login.
www.kerrneltech.com
Enter the password of the client to proceed, check it on client side whether it is copied or not
Move to client system and check whether the key is copied properly or not
To check the key navigate to /root/.ssh/ directory and check for authorzed_keys file which
will hold all the system which are authorized and will not be asked for password..
#cd /root/.ssh/
#cat authorized_keys
Try login to the client machine using SSH, check whether it is asking for password
For logging into client machine the procedure is same as shown earlier. But as we have
assigned a passphrase it will ask us for it. Once you enter a passphrase it will last until you
logged out of servers session. Lets see it practically.
#ssh 192.168.10.95
It will prompt for the passphrase as shown below, enter the passphrase and press Enter
www.kerrneltech.com
Exit the client session and login again. Notice the change
While we logout the client session and re-login again it will not ask us for passphrase
Logout of client session and completely logoff the server, login once again in server and
connect the client using SSH.
As we log off completely from the server then login once again and try to connect the client,
it will prompt for passphrase. Observe it below
Note: if connected to the server via putty, above is complete log out just connect to the server
once again as usual and try connecting to the client, but if connected graphically then go to
System -> logout <username>, select it and click on LOGOUT. Login once more open terminal
and reconnect to client and observe that it will prompt for passphrase.
www.kerrneltech.com
LAB WORK:
To copy a file using SCP to remote machine from source location
We are having a file ktfile in / directory, in the server ktlinux.kt.com whos IP is
192.168.10.98, and we need to copy the same in other servers i.e. ktcl5.kt.com with an IP
192.168.10.95, /root directory. Then,
The syntax for SCP a file from source location.
#scp <file name > <remote hosts IP >:/<location to copy the file >
#scp /ktfile 192.168.10.95:/root/
Now log in to destination system and check whether if the file is there.
To copy a file using SCP from a remote machine being in destinations location
Lets reverse the previous task, login to ktcl5 machine whose IP is 192.168.10.95, and
transfer a file from ktlinux machine whose IP is 192.168.10.98
Lets first remove the earlier copied file ktfile, then copy it again from destinations location.
The syntax for SCP a file from destination location.
#scp <source systems IP>:/<location of file to be copied> <destination location to copy>
Note: Password will be asked for every transfer if public key is not saved on both locations, in
our case we have already generated and copied the key, hence there is no password prompts.
Page 165 of 274
www.kerrneltech.com
To copy a directory using SCP from a remote machine being in destinations location
Lets reverse the previous task, login to ktcl5 machine whos IP is 192.168.10.95, and
transfer a directory ktdir from ktlinux machine whose IP is 192.168.10.98
Lets first remove the earlier copied directory ktdir, then copy it again being in destinations
location.
The syntax for SCP a file from destination location.
#scp <option> <source systems IP>:/<location of file to be copied> <destination location
to copy>
#scp r 192.168.10.98:/ktdir /root/
www.kerrneltech.com
speed up file transfer by copying the differences between two files rather than copying an entire file
every time.
For example, Assume that we are suppose to take the backup of a system and copy the same to
another system. For first time we will copy entire directory, but every day if we copy entire directory
it will kill lots of time. In such situation if rsync is used it will only copy the updated files/directories
rather than copying all files/directories inside main directory, which saves lots of time and speedup
the transfer
If rsync is combined with ssh it makes a great utility to sync the data securely. If rsync is not used
with ssh, the risk sniffing will always be there.
LAB WORK:Copy a directory using SCP, then update it and try rsync with SSH and check if the data is
synced.
As we have already copy a directory earlier using SCP from ktlinux to ktcl5 system, let s use
it for rsync.
Update the directory with some files in ktlinux system
Use rsync to sync the directory on ktcl5 machine, with the one in ktlinux machine
The syntax to rsycn a directory is
#rsync <options> <encryption> <source dir> <destination IP>:/<location of destination
dir>
#rsync rv -e ssh /ktdir 192.168.10.95:/root/
Observe that it is only copying the files which are not there in destinations folder.
Page 167 of 274
www.kerrneltech.com
Note: If you dont want to use ssh just remove e option from above syntax, but the drawback
of it is there will be no encryption
To compress the data and send it in archive mode use -avz instead of -rv in rsync
Update the file ktfile1 in ktlinux, sync it with rsync to ktcl5 and check the file again.
The syntax for syncing a file is
#rsync avz e ssh <source file> <destination ip>:/<location of file >
Like this you can use rsync in many ways to transfer the updated file or files/directory to other
system.
www.kerrneltech.com
Sudo stands for either "substitute user do" or "super user do" (depending upon how you
want to look at it). What sudo does is incredibly important and crucial to many Linux
distributions. Effectively, sudo allows a user to run a program as another user (most often
the root user). There are many that think sudo is the best way to achieve "best practice
security" on Linux
Users can login using their username and password and can issue administrative commands
placing sudo in front of the commands, e.g. sudo rpm -Uvh *.rpm , to run the command
which installs and updates programs in Linux (rpm).
The file /etc/sudoers file has the rules that users have to follow when using sudo command. That
means that whatever commands access is provided to any user in /etc/sudoers file, that user can
only run those commands.
Do not edit the /etc/sudoers directly; instead use "visudo" command to edit the sudoers file. There
are two reasons for that- it prevents two users from editing the file at the same time, and it also
provides limited syntax checking. Even if you are the only root user, you need the syntax checking,
so use "visudo".
www.kerrneltech.com
As we learnt above that it is the configuration file for sudo users, which is used to assign
specific commands to the specific users or groups.
Always use visudo command to edit this file. it prevents two users from editing the file at
the same time, and it also provides limited syntax checking .
When you run visudo command the output will be as follows
www.kerrneltech.com
Now logged in as ktuser and run admin commands like fdisk l etc
First try to run fdisk command normally and see what happens.
Note: Only for the first time of the session it will prompt for users password to continue, but
for rest of the process it will continue normally as shown below
www.kerrneltech.com
www.kerrneltech.com
Allow a user ktuser2 to run all commands without prompting for his password any time.
To allow run all commands, the syntax we have already seen, but allow him run commands
without prompting password a small change is to be made,
Now login as that user and check whether password is prompted or not
Note: - The same can be done for groups also, try it!
Restrict a user ktuser to run only two root commands.
This task is very simple, just modify the previous permissions assign to ktuser.
Lets give ktuser to run only #fdisk and #parted command access.
First check the complete path of those command by using following command
#which fdisk
#which parted
www.kerrneltech.com
Login as ktuser and try assigned commands and other commands as well
Observe that we have just remove # before the line to make the line readable. And also
observe that it contains all networking commands.
Just replace ALL with NETWORKIG from the last field of ktgroup line.
NOTE: - NETWORKING is the name of the command alias where uncommented the line.
Now login as one of the member of ktgroup and try some commands assigned it.
www.kerrneltech.com
Create a customize commands alias and assign it to ktgroup with network command.
Okay, first we need to create an alias say CUSTOM with some commands and assign it to
ktgroup in addition to NETWORK commands.
Lets firs get the path of the command need to be in CUSTOM alias
Okay, now lets create an alias for these commands and assign it to ktgroup
#visudo
What are you waiting for! Assign it to ktgroup and save the file.
Login as one of the users in ktgroup and try newly added commands.
www.kerrneltech.com
Create a user alias and add some users from different groups and assign some root privileges
This is very much similar to the previous task, instead of command alias we need to
combine some user and give them some alias name which act as one user, but actually
there are some users inside it. Then we can assign some privileges to them
First we need available users and their groups.
#tail /etc/passwd and #tail /etc/gshadow.
From the above query, we can take sai from ktgroup, student and ktuser and can make an
alias user. Search User Aliases, under that create your own alias user as shown below.
#visudo
Now, lets assign some command to this alias user called KTADMIN and save the file.
Now login as one of those users and check the assigned commands for them.
Note: Checkout sudoers file for more option and try it out on your own!!!!
Page 176 of 274
www.kerrneltech.com
SOFTWARE MANAGEMENT
To manage the software in Linux, two utilities are used,
1. RPM REDHAT PACKAGE MANAGER
2. YUM YELLOWDOG UPDATER MODIFIED
www.kerrneltech.com
To check whether a package is installed or not out of the list of installed package, the syntax
is
#rpm qa <package name> or
#rpm q < package name>
#rpm qa vsftpd or #rpm q vsftpd
One more method of checking the installed package, when you are not sure about the
package name, like whether it starts with capital letter and full name etc.
#rpm qa | grep i < package name>
#rpm qa |grep i vsft*
To check whether a package is consistent or not, before installing it. (Testing the installation)
To check the packages consistency,
Move to the directory where you have kept the rpm package which you wish to install
If the installation status shows 100%, then the package is good or consistent.
But while showing the hash progress if it shows any error, then the package is inconsistent.
Page 178 of 274
www.kerrneltech.com
Check the installed package by using it command, finger is used to check users details.
#finger <user name>
#finger ktuser
www.kerrneltech.com
To see the info about a particular package which is not installed, move to the directory
where you have kept the packages.
To see the information or details about the installed package, the syntax is
#rpm qi < package name >
#rpm qi vsftpd
www.kerrneltech.com
To check the package of a particular command, first check the installed location of a
command
#which <command name>
#which cat
Before installing a package forcefully, first understand a situation where we need this force
option.
Let me corrupt one command and show you how to install its package forcefully.
First check the package of the command we are going to corrupt. Let say mount command
#which mount
#rpm qf /bin/mount
Okay, so we know the package of mount lets copy other commands content over mount
command. Let copy date commands contents over mount command.
#cp /bin/date /bin/mount
Now when you run mount command it will show date, that means it is corrupted.
www.kerrneltech.com
So, to fix the mount command we need to reinstall its package, lets install the package and
check whether mount command is fixed or not. Move to the folder where you kept the
packages and install it
#rpm ivh util-linux-ng 2.17.2-6.el6.i686
It says the package is already install, check by using mount command whether it is working
fine.
Oops!!! It isnt fixed yet, now in such to force the installation to be done, the syntax is
#rpm ivh <package name > - - force
# rpm ivh util-linux-ng 2.17.2-6.el6.i686 - -force
Okay then weve not only installed the package successfully but we have also fixed the
command. Congratulations.
www.kerrneltech.com
Some rpm requires some other packages to be installed before it can be installed; this
requirement is termed as dependency. This means that before installing a package we
need to install the required packages first, so that it can work properly.
But sometimes we can skip installing the dependency, if we dont have that dependent
software with us.
The syntax for it is
#rpm ivh <package name> - -nodeps
#rpm -ivh util-linux-ng 2.17.2-6.el6.i686 - -nodeps
First lets make some changes in the configuration file of a package say vsftpd
#vim /etc/vsftpd/vsftpd.conf
Now run the following command and check for the result.
It is showing that on line 5 in config file, some changes have been made. Isnt it cool!!!
Page 183 of 274
www.kerrneltech.com
The Yellow dog Updater Modified (YUM) is a package management application for
computers running Linux operating systems.
Yum is a standard method of managing the installation and removal of software. Several
graphical applications exist to allow users to easily add and remove packages; however,
many are simply friendly interfaces with yum running underneath. These programs present
the user with a list of available software and pass the user's selection on for processing. It is
yum that actually downloads the packages and installs them in the background.
Packages are downloaded from collections called repositories, which may be online, on a
network, and/or on installation media. If one package due to be installed relies on another
being present, this dependency can usually be resolved without the user needing to know
the details. For example, a game being installed may depend on specific software to play its
music. The problem of solving such dependencies can be handled by yum because it knows
about all the other packages that are available in the repository.
Yum will work only from Cantos 5 / Red hat 5 and latest versions of fedora. For Old releases
like RHEL 4 you need to use up2date command to update your rpm based packages.
LAB WORK:Configuring a YUM server and adding the info about it in at least one client
To configure a YUM server the steps are.
Make sure that vsftpd package is installed, if not install it.
Copy entire RHEL6 DVD to /var/ftp/pub/rhel6 directory, where rhel6 dir is to made by
us only it is not default dir.
Make a repo file as kt.repoin /etc/yum.repos.d directory
Clean the yum cache and check the package list using yum command
www.kerrneltech.com
If it is not installed, then go to dvds mount point and navigate to Packages directory and
install it as shown below.
As we know the mount point of dvd is /media/RHEL_6, move to its location and enter into
Packages directory.
Now copy the RHEL6 DVD to /var/ftp/pub/rhel6 directory with its default permission
#cp rvfp /media/RHEL_6.0\I386\Disc\1/* /var/ftp/pub/rhel6
Note:- it will take around 5 minutes copy all the data, based on the DVD
Page 185 of 274
www.kerrneltech.com
I guess theres some explanation requires about the fields we have entered.
[KTREPO] is the short name given to the repository.
name is the complete name for the repository.
baseurl is the location of the dvd dump we have made.
enabled is to enable or disable the repository. The possible value for it is 0 and 1, where 0
means disable and 1 means enabled.
gpgcheck With the gpgcheck option, all packages must be signed, and yum must be able to
verify the signatures on packages from red hat . If gpgcheck=0, there will be no package
signing by red hat and signature verification.
Clean the yum cache and check the package list using yum command
To clear the cache use the following command
#yum clean all
If the configuration is correct, then the following output will be displayed, otherwise there
will be some errors displayed.
Page 186 of 274
www.kerrneltech.com
If the above output is displayed then congratulation you have successfully configured the
yum Server
Configure the yum client and check whether yum server is responding to it.
Configuring a yum client is very simple with just three steps.
Install ftp package , so that packages can be accessed from client
Make a repo file /etc/yum.repo.d/ as ktcl5.repo
Clean the cache and check whether yum server is responding or not
Install ftp package, so that packages can be accessed from client
Install the ftp package from rhel dvd in Packages directory.
www.kerrneltech.com
If your output is like this then you have successfully configured a yum client as well.
Congrats!!! Now you can configure as many as clients you want.
In case if yum list command is not listing the package then delete the following file in
/etc/yum.repos.d/ at client side only.
Clean the cache and list the packages, it will certainly solve the problem.
Page 188 of 274
www.kerrneltech.com
www.kerrneltech.com
It will prompt you for y/n to continue, type y and continue installing the package
www.kerrneltech.com
As there are no updates available for it, it is not showing anything to update
To install a package locally from a folder, pendrive or cd rom
Move to the package where you have stored the package to be installed
www.kerrneltech.com
www.kerrneltech.com
Lets try install package from group called urdu support, the syntax is
#yum groupinstall <package name> -y
#yum groupinstall urdu support -y
www.kerrneltech.com
The software management can be learnt more by using manual pages like man yum and also
man rpm etc.
If nothing works Google is yours!!!
Page 194 of 274
www.kerrneltech.com
/opt/etc.tar.gz
/opt/etc.tar.gz
20 MB
/opt/etc.tar
190 MB
/root/etc.tar
/etc
200 MB
Normal File
/root/etc
Back to Normal File
Page 195 of 274
www.kerrneltech.com
Check the size of tar file by using du h <file name > command
#du h /opt/etc.tar
www.kerrneltech.com
Transfer the file to other system and remove gzip and tar from it and check the size on every
step.
Lets transfer the file to other computer using scp
#scp /opt/etc.tar.gz 192.168.10.95:/root/
Login to the remote system, remove gzip it and check the size.
To gunzip a file the syntax is
#gunzip <file name>
#gunzip etc.tar.gz
Untar the file and check for the size of the file/directory
To untar a file the syntax is
#tar -xvf <file name>
#tar xvf etc.tar
www.kerrneltech.com
Services are programs (called daemons) that once started run continuously in the
background and are ready for input or monitor changes in your computer and respond to
them. For example the Apache server has a daemon called httpd (the d is for daemon) that
listens on port 80 on your computer and when it receives a request for a page it sends the
appropriate data back to the client machine.
Many services are required to run all the time however many can be safely turned of for
both security reasons as running unnecessary services opens more doors into your
computer, but also for performance reasons. It may not make much difference but your
computer should boot slightly faster with less services it has to start on boot.
One of the techniques in every Linux administrator's toolbox to improve security of a box is
to turn off unneeded services.
service - This controls the starting and stopping of services during a session, these
setting are not saved. If you start Apache this way but it is not set to start on boot using
the above method then it will continue to run but on next boot will not start
automatically.
chkconfig - This controls which services are set to start on boot, by their nature these
setting are saved and are applied at next boot. Changing these settings will not start the
service immediately; it will just flag them to be started from the next boot.
www.kerrneltech.com
Reload the ftp services, may be required after doing some change in config file.
To restart the ftp or any service, required when reload does not work
www.kerrneltech.com
Note: Where 0 1 2 3 4 5 6 are the run levels in Linux, The output shows that on which run level
the service is available even after reboot.
Check the status of a particular service, say vsftpd
To check the status of a vsftpd service, the command is
#chkconfig - - list <name of the service>
#chkconfig - - list vsftpd
The same can be done for making service unavailable in a particular run level.
Page 200 of 274
www.kerrneltech.com
MANAGING PROCESS
A Linux process is a program running in the Linux system. Depending on Linux distributions,
it's also known as service. In Linux community however, a Linux process is called daemon.
When you start a program or running an application in Linux, you actually execute that
program. A Linux process (a daemon), running in foreground or in the background, uses
memory and CPU resources. That's why we need to manage Linux process. Keeping unused
Linux process running in the system is a waste and also exposes your system to security
threat.
In Linux, every running process or daemon is given an identity number called PID (Process
ID). The process id is unique. We can terminate unused program in the system by stopping
its process id.
In order to manage Linux processes, we need to identify some process information such as
who's responsible for the process, which terminal the process is running from and what
command used to run the process.
Interactive Processes
System Process or Daemon
Automatic or batch
Interactive Processes
Interactive processes are those processes that are invoked by a user and can interact with the
user. VI is an example of an interactive process. Interactive processes can be classified into
foreground and background processes. The foreground process is the process that you are
currently interacting with, and is using the terminal as its stdin (standard input) and stdout
(standard output). A background process is not interacting with the user and can be in one of
two states - paused or running.
www.kerrneltech.com
Automatic Processes
Automatic processes are not connected to a terminal. Rather, these are tasks that can be
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 certain date and time: done using the at command
At times 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 wait to be executed until the system
load is lower than 0.8. In large environments, the system administrator may prefer cron job
processing when large amounts of data have to be processed or when tasks demanding a lot of
system resources have to be executed on an already loaded system. Cron job processing is also
used for optimizing system performance.
The Process which starts or creates another process is called parent process and the one
which got created is known as child process.
Every process will be having a parent process except init process.
The init process is the parent of all the process in the system. It is the first process which
gets started by the kernel at the time of booting
The PID of init will be 1.
Only after init process gets started the remaining process are called by it, and hence it is
responsible for all the remaining processes in the system.
Page 202 of 274
www.kerrneltech.com
To see which process are attached with some terminals (tty) and which are not
#ps x
Note: The process which are showing ? are not attached to any tty.
Page 203 of 274
www.kerrneltech.com
Signals in Linux
Signals are a way of sending simple messages to processes. Most of these messages are
already defined and can be found in <linux/signal.h>. However, signals can only be
processed when the process is in user mode. If a signal has been sent to a process that is in
kernel mode, it is dealt with immediately on returning to user mode.
Every signal has a unique signal name, an abbreviation that begins with SIG (SIGINT for
interrupt signal, for example). Each signal name is a macro which stands for a positive
integer - the signal number for that kind of signal. Your programs should never make
assumptions about the numeric code for a particular kind of signal, but rather refer to them
always by the names defined. This is because the number for a given kind of signal can vary
from system to system, but the meanings of the names are standardized and fairly uniform.
Signals can be generated by the process itself, or they can be sent from one process to
another. A variety of signals can be generated or delivered, and they have many uses for
programmers. (To see a complete list of signals in the Linux environment, uses the
command kill -l.)
Page 204 of 274
www.kerrneltech.com
There are total 64 signals in Linux, the list of all the signal can be sen by
#kill l
www.kerrneltech.com
Likewise you can use other signals to kill the process like
#kill -15 <pid>
#kill -1 <pid>
To stop the process using a signal no. 20
To stop a process first login as a normal user and start a process
#su musab
#cat > hello
www.kerrneltech.com
When talking about processes priority is all about managing processor time. The Processor
or CPU is like a human juggling multiple tasks at the same time. Sometimes we can have
enough room to take on multiple projects. 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
high 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 zero.
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 high priority
programs like daemons and services can be set to receive more of the CPUs focus. You can
even give a specific user a lower nice value for all of his/her processes so you can limit their
ability to slow down the computers core services.
There are two options to reduce/increase value of a process. You can either do it using the
nice command or the renice command.
Log in to other terminal and check the nice value for the above command/ process.
#ps elf
www.kerrneltech.com
When you need to see the running processes on your Linux in real time, you have top as
your tool for that.
top also displays other info besides the running processes, like free memory both physical
and swap
02:23:18 is the current time; up 1 day shows how long the system has been up for; 3
user how many users are logged in; load average: 0.01, 0.00, 0.23 the load average of
the system (1minute, 5 minutes, 15 minutes).
Page 208 of 274
www.kerrneltech.com
Shows CPU utilization details. 9.5%us user processes are using 9.5%; 31.2%sy system
processes are using 31.2%; 27.0%id percentage of available cpu; 7.6%wa time CPU is
waiting for IO.
543948k total is total memory in the system; 526204K used is the part of the RAM that
currently contains information; 17744k free is the part of RAM that contains no
information; 17748K buffers and 129928k cached is the buffered and cached data for IO.
Description
Process ID
Effective User ID
Dynamic priority
Nice value, also known as base priority
Virtual Size of the task. This includes the size of process's executable binary,
VIRT
the data area and all the loaded shared libraries.
The size of RAM currently consumed by the task. Swapped out portion of the
RES
task is not included.
Some memory areas could be shared between two or more task, this field
SHR
reflects that shared areas. The example of shared area are shared library and
SysV shared memory.
S
Task status
The percentage of CPU time dedicated to run the task since the last top's
%CPU
screen update.
%MEM
The percentage of RAM currently consumed by the task.
The total CPU time the task has been used since it started. "+" sign means it
TIME+
is displayed with hundredth of a second granularity. By default, TIME/TIME+
doesn't account the CPU time used by the task's dead children.
Command Showing program names
www.kerrneltech.com
To renice a process with PID 4, then press r and a prompt will ask you for PID enter 4 and
press enter. When prompted for renice value give any value .
Find out more on top command from internet and keep practicing
Page 210 of 274
www.kerrneltech.com
File Transfer Protocol (FTP) is a standard network protocol used to transfer files from one
host to another host over a TCP-based network, such as the Internet. FTP is built on clientserver architecture and utilizes separate control and data connections between the client
and server. FTP users may authenticate themselves using a clear-text sign-in protocol but
can connect anonymously if the server is configured to allow it.
In Red hat Enterprise Linux. You can access FTP from both the Command Line Interface mode and
GUI mode.
Usually, the FTP server, which stores files to be transferred, uses two ports for the
transferring purpose, one for Commands and the other for sending and receiving Data.
Requests from client computers are received at the port 21 of the server, which is
exclusively reserved for sending Commands; therefore, it is called the Command Port. Once
an incoming request is received, the data requested or uploaded by the client computer is
transferred through a separate port referred to as a Data Port. At this point, depending on
the Active or Passive mode of the FTP connection, the port number used for the Data
Transfer varies.
Security is a major concern with any computer connected to the internet, therefore any
computer connected to the internet should be protected by a Firewall. In order to connect
to certain services, such as FTP, you have to allow those connections in the Firewall, on both
the Client and Server side.
Although a client's computer may not have a firewall enabled, a server should always have
this enabled for maximum security.In order to connect to an FTP server that has a firewall
enabled, you have to connect using a specific connection mode in your FTP program.
There are different connection modes to choose from when connecting to an FTP server,
typically either "Active" or "Passive" mode.
Page 211 of 274
www.kerrneltech.com
Active FTP connection mode is where Command connection is initiated by the Client, and
the Data connection is initiated by the Server. And as the server actively establishes the
data connection with the Client, this mode is referred to as Active. The Client opens up a
port higher than 1024, and through it connects to the port 21 or the command port of the
Server. Then the Server opens up its port 20 and establishes a data connection to a port
higher than 1024 of the Client. In this mode, Client must set its firewall settings to accept all
the incoming connections that are received at the opened port.
In the Passive FTP connection mode, the server acts entirely passively as the Command
connection and the Data connection are both initiated and established by the Client. In this
mode, Server listens for incoming requests through its port 21 (command port), and when a
request is received for a data connection from the Client (using a high port), Server
randomly opens up one of its High ports. Then Client initiates a data connection between
the opened port of the Server and its own randomly selected port higher than 1024. In this
mode, the Client does not have to change its firewall settings, as it only requires outgoing
connections and the firewall do not block outgoing connections. However, the Server
administrators must make sure that the Server allows incoming connections at all its
opened ports.
www.kerrneltech.com
Use
Disadvantage
Package
Daemon
Script
Port no
Configuration files
:
:
:
:
:
:
:
Document Root
Home directory
:
:
www.kerrneltech.com
If you dont have yum repository created, then installed it using rpm from RHEL 6 DVD
Page 214 of 274
www.kerrneltech.com
Step4: Make the service enable even after reboot of the system
To make a service enable use the following command
#chkconfig vsftpd on
Step5: Connect from client and access the files and download it
To access the ftp server the client should have ftp package installed. If not installed,
install it using rpm, because yum will not work if ftp package is not installed.
Check whether ftp package is installed or not
#rpm q ftp
To install ftp package either download it from redhat website or install it from RHEL6 DVD
Move to the package folder and installed it.
#rpm ivh <package name>
www.kerrneltech.com
Note: when you run ls command you can see that it showing that we are using Passive mode.
www.kerrneltech.com
Exit the ftp server and check whether the files are there or not
To exit the ftp server either use
#bye or #quit
To connect to the ftp server graphically open web browser like firefox type the ftp servers ip
address as following
ftp://192.168.10.93
www.kerrneltech.com
Step2: Change the group to ftp and write permission to the upload directory
Changing the group of upload to ftp
#chgrp <group name> <directory name>
#chgrp ftp upload
Step3: Log into client machine, access ftp server and try to upload some files
Log into client machine and access the ftp server from the directory in which the files to
be uploaded are there.
www.kerrneltech.com
Permission denied is because the upload permission in the ftp configuration file is not
enabled in the ftp server. So, navigate to the ftp configuration file and change the
following attributes in it.
#vim /etc/vsftpd/vsftpd.conf
Uncomment (remove the #) the following line
www.kerrneltech.com
Step4: Again login to client system and try again to upload the files into ftp server
If the SELinux is enabled in the ftp server, this error Could not Create file will be displayed.
To solve above error log into server and change the following permission
Check the Booleans for ftp using following command
#getsebool a |grep ftp
Add read write permission in context of upload directory using following command
#chcon t public_content_rw_t
www.kerrneltech.com
Finally login into client machine, access the ftp server and try uploading the files in it.
Okay now youve made an ftp server for uploading files as well
www.kerrneltech.com
By default root user is blocked to be used in ftp user, try logging with root in ftp server
To Allow the root access to ftp server edit the /etc/vsftpd/user_list and
/etc/vsftpd/ftpuser and just add the comment (#mark) before root
#vim /etc/vsftpd/user_list
#vim /etc/vsftpd/ftpuser
Though everything right, but still it is not allowing us to login as root because the home dir is
not able to change. It is again because of SELinux.
www.kerrneltech.com
To solve the above problem, login to ftp server and change the following Boolean for ftp
www.kerrneltech.com
NFS stands for Network File System, and is a way to share files between machines as if they
were on your local hard drive. Linux can be both an NFS server and an NFS client, which
means that it can export filesystems to other systems, and mount filesystems exported
from other machines.
For example NFS server could be a Linux system and Unix could be a client. But it cant be a
window system because window is not NFS compatible. The NFS server exports one or
more directories to the client systems, and the client systems mount one or more of the
shared directories to local directories called mount points. After the share is mounted, all
I/O operations are written back to the server, and all clients notice the change as if it
occurred on the local filesystem.
A manual refresh is not needed because the client accesses the remote filesystem as if it
were local. Because access is granted by IP address, a username and password are not
required. However, there are security risks to consider because the NFS server knows
nothing about the users on the client system.
www.kerrneltech.com
Package
Daemons
Script
Port number
Configuration File
Other imp files
:
:
:
:
:
:
nfs-utils
rpc.nfsd, rpc.mountd, rpc.statd, rpc.lockd, rpc.rquotad
/etc/init.d/nfs
2049
/etc/exports
/var/lib/nfs/etab, /var/lib/nfs/rmtab
Workflow of NFS
www.kerrneltech.com
Step2: Create a directory or create a partition and mount it and make a mount point and add
data to it.
Create a partition, format it and mount it, access the mount point and add data to it
#fdisk /dev/vda create a partition
www.kerrneltech.com
Step3: Export the directory by editing /etc/exports file and using exportfs command
Edit the /etc/exports file
#vim /etc/exports
Mount Options
Dir name
/ktdir
192.168.10.0/24
:
:
(rw, sync)
:
:
:
no_wdelay
root_squash
Options:
-a
Exports or un-exports all directories
-r
Reexport all directories
-u
Unexports one or more directories
-v
Provides verbose output
Page 227 of 274
www.kerrneltech.com
Note: stop the iptables services by using #service iptables stop and chkconfig iptables off.
www.kerrneltech.com
Step3: Check which directory is exported for this machine using showmount command
To check the exported directories from server the syntax is
#showmount e <server ip address>
Step5: Add some data to it and check the same is updated on server side.
Note that it is showing permission error because on server side the directory does not
have write permissions neither for group nor for others.
Log into server and add write permission to NFS directory
Now , Again move back to client machine and try uploading some files
www.kerrneltech.com
All the resources of the server is valuable and needs to be available for usage, when we
mount a NFS directory over client the network resource gets busy, even when the work is
finished the network resource will still be busy as mounting occupy it.
Autofs automatically mounts file systems for you when they are requested. This has a
very handy feature: It's great for handling removable media. Just CD to the right directory,
or execute ls or do anything that sends a request to the mount point: and the daemon
mounts it. After all, it's the kind of job that's beneath the dignity of a human being First;
you need to install the "autofs" package. It should include some appropriate config files.
The files you need is /etc/auto. Master
Standby time
Step3: Create /etc/auto.ktnfs file and /ktnfs directory if not created earlier
#vim /etc/auto.ktnfs
Permissions
www.kerrneltech.com
Step5: log into the given directory in /etc/auto.master i.e. /ktnfs and check that if NFS is
mounted by mount command
Note: Still NFS will not be mounted
Step6: change the directory to the name given in /etc/auto.ktnfs i.e. ktnfs and then auto
mounting will be done.
#cd ktnfs
#mount
Note:- if you dont have DNS and you dont want use IP but want to use hostname instead,
update hostname with its ip in /etc/hosts file and then you can use hostname instead of IP
Okay now finally weve done with all NFS activities.
Page 231 of 274
www.kerrneltech.com
SAMBA SERVER
The whole point of networking is to allow computers to easily share information. Sharing
information with other Linux boxes, or any UNIX host, is easytools such as FTP and NFS
are readily available and frequently set up easily out of the box. Unfortunately, even the
most die-hard Linux fanatic has to admit the operating system most of the PCs in the world
are running is one of the various types of Windows. Unless you use your Linux box in a
particularly isolated environment, you will almost certainly need to exchange information
with machines running Windows. Assuming you're not planning on moving all of your files
using floppy disks, the tool you need is Samba.
Samba is an implementation of a Common Internet File System (CIFS, also known as SMB)
protocol server that can be run on almost every variant of Unix in existence. Microsoft
clients will use this protocol to access files and printers located on your Unix
box just as if it were a native Windows server.
Samba allows linux computers to share files and printers across a network connection. By
using its SMB protocol, your linux box can appear in Windows Network Neighborhood or
My Network Places just like any other windows machine. You can share files this way, as
well as printers. By using samba on my home network, for example, my Windows machines
have access to a printer directly hooked up to my Linux box, and my Linux box has access to
a printer directly hooked up to one of my Windows machines. In addition, everyone can
access everyone else's shared files. You can see how samba can be very useful if you have a
network of both Windows as well as Linux machines.
Page 232 of 274
www.kerrneltech.com
Package
Daemons
Script
Portno
:
:
:
:
File system
Config file
:
:
www.kerrneltech.com
Step2: Make a directory and assign full permission to it ,which will be shared
#mkdir /ktsamba
#chmod 777 /ktsamba
.
Step3: Check the context of the directory and change it according to samba
#ls ldZ /ktsamba
#chcon t samba_share_t /ktsamba
Step4: Create a user or use any existing user who will be allowed to log in as samba user, add
that user to samba user
As we have a existing user ktuser, lets just make it samba user
#smbpasswd a <username>
#smbpasswd a ktuser
Give password twice and wait till it add the user
Step5: Go to the configuration file i.e. /etc/samba/smb.conf and make the following changes
Open the /etc/samba/smb.conf and copy the last seven lines shown below and paste it
at the last to edit it.
www.kerrneltech.com
Once pasted remove ; mark before it and change it according to following picture
Step5: Test the samba parameters andrestart the service and make it enable after reboot
To test the parameters us the following command
#testparm
www.kerrneltech.com
www.kerrneltech.com
It will prompt for user name and passwd, give samba user and passwd and click on OK
Now a window will be opened, start adding some data to it from both sides
www.kerrneltech.com
Log into Linux machine and check how many samba servers are there in your network
#findsmb
Check the share name of that samba server by using following command
#smbclient L //192.168.10.93
when prompted for passwd just press enter without giving any passwd
www.kerrneltech.com
www.kerrneltech.com
Like the telephone system, every device attached to the Internet has a unique number, its IP
address. Also like the telephone system there is a directory services to help you find those
numbers called DNS.
If you have someone's name and address you can call a directory services, give them the details
you know and they will (usually) give you the telephone number to call them. Likewise, if you
know a server's host name (maybe http://www.google.co.in/) you can give that name to a DNS
server and it will give you the IP address of that server.
Page 240 of 274
www.kerrneltech.com
A database is made up of records and the DNS is a database. Therefore, common resource
record types in the DNS database are:
A - Host's IP address. Address record allowing a computer name to be translated into an
IP address. Each computer must have this record for its IP address to be located. These
names are not assigned for clients that have dynamically assigned IP addresses, but are
a must for locating servers with static IP addresses.
PTR - Hosts domain name, host identified by its IP address
CNAME - Hosts canonical name allows additional names or aliases to be used to locate
a computer.
MX - Hosts or domains mail exchanger.
NS - Hosts or domains name server(s).
SOA - Indicates authority for the domain (Start of Authority)
TXT - Generic text record
SRV - Service location record
RP - Responsible person
HINFO - Host information record with CPU type and operating system
The package which is used in Linux for performing DNS activity is BIND (Berkeley Internet
Name Domain)
www.kerrneltech.com
:
:
:
:
:
:
:
www.kerrneltech.com
Step2: Update the /etc/hosts file with the servers ip address, and change the hostname with
fully qualified domain name.
www.kerrneltech.com
www.kerrneltech.com
Step5: Navigate to /var/named/ directory and create a forward and reverse zone files.
Navigate to /var/named/ directory and copy the named.localhost file with its permissions
as kt.flz and edit it.
#cd /var/named
#cp p named.localhost kt.flz
www.kerrneltech.com
Copy again named.localhost, this time as kt.rlz and edit it as shown below.
#cp p named.localhost kt.rlz
#vim kt.rlz
www.kerrneltech.com
Okay now weve done with DNS server configuration, check whether it is resolving IP to
hostname and hostname to IP using various commands.
Using dig command to check the DNS resolution
Check with giving hostname of server
#dig <FQDN> of server
#dig ktadm.kt.com
www.kerrneltech.com
With IP address:
#dig x 192.168.10.91
www.kerrneltech.com
www.kerrneltech.com
Log into client machine and add the DNS servers information in /etc/resolv.conf file
#vim /etc/resolv.conf
Now check with any of the options used previously like dig, ping, host or nslookup for dns
resolution
Do the same for every client and check it with various commands on every client
Also make sure that hostname should Fully Qualified Domain Name.
www.kerrneltech.com
Every Web site sits on a computer known as a Web server. This server is always
connected to the internet. Web servers are computers that deliver (serves up) Web
pages. Every Web server has an IP address and possibly a domain name.
A web server can mean two things - a computer on which a web site is hosted and a
program that runs on such a computer. So the term web server refers to both hardware
and software.
A web server is what makes it possible to be able to access content like web pages or
other data from anywhere as long as it is connected to the internet. The hardware
houses the content, while the software makes the content accessible through the
internet.
The most common use of web servers is to host websites but there are other uses like
data storage or for running enterprise applications. There are also different ways to
request content from a web server. The most common request is the Hypertext Transfer
Protocol (HTTP), but there are also other requests like the Internet Message Access
Protocol (IMAP) or the File Transfer Protocol (FTP).
www.kerrneltech.com
A simple exchange between the client machine and Web server goes like this:
1. The client's browser dissects the URL in to a number of separate parts, including address,
path name and protocol.
2. A Domain Name Server (DNS) translates the domain name the user has entered in to its IP
address, a numeric combination that represents the site's true address on the Internet (a
domain name is merely a "front" to make site addresses easier to remember).
3. The browser now determines which protocol (the language client machines use to
communicate with servers) should be used. Examples of protocols include FTP, or File Transfer
Protocol, and HTTP, Hypertext Transfer Protocol.
4. 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/1.jpg, the browser sends a GET 1.jpg
command to example.com 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 server sends an error message to the client.
5. The browser translates the data it has been given in to HTML and displays the results to the
user.
Page 252 of 274
www.kerrneltech.com
:
:
:
:
Document Root
Daemon
Script
:
:
:
Copy these lines and paste it at the end of the page, then edit it with your preferences.
Page 253 of 274
www.kerrneltech.com
Step2: Navigate to the document root folder i.e. /var/www/html/ and create an index.html
file which will be accessed through a web browser
#vim /var/www/html/index.html
Step4: Now open the Firefox web browser and try connecting the web server.
Open Firefox web browser and type the IP Address of the web server
http://192.168.10.95
To open the website from command line use the following command
#curl <IP/HOSTNAME of web server>
#curl 192.168.10.95
Also Try
#elinks --dump 192.168.10.95 and check the output
Page 254 of 274
www.kerrneltech.com
Open the DNS configuration file and add the canonical name as www, so that we can
use our domain as full fledge website.
#vim /var/named/kt.rlz
Okay now we are ready just open the web browser like Firefox and this type address as
follows
www.kt.com
Note: This will only work in your DNS range, for others in your network use ip address
Page 255 of 274
www.kerrneltech.com
Create an index.html
Open the Firefox web browser and type the following url
http://192.168.10.95/vcs
www.kerrneltech.com
Redirecting means whenever the name of a particular website is given it should take us
on some other website.
To redirect a website, navigate and open the configuration file of http i.e.
/etc/httpd/conf/httpd.conf and add the following line in it at the end.
#vim /etc/httpd/conf/httpd.conf
Open the Firefox browser and type the following website address
http://192.168.10.95/kt and it will take you to Kernel Technologies website
www.kerrneltech.com
Step3: edit the configuration file i.e. /etc/httpd/conf/httpd.conf add the configuration for
port based hosting in configuration file.
#vim /etc/httpd/conf/httpd.conf. Copy the same 7 lines and paste it at end edit it
Also search for the Listen 80 by using / and paste your port under it
www.kerrneltech.com
Step4: Restart the service, open web browser and search for your website with port no.
#service httpd restart
Name-based virtual hosts use multiple host names for the same web server IP address.
With web browsers that support HTTP/1.1 (as nearly all now do), upon connecting to a
webserver, the browsers send the hostname from the address that the user typed into their
browser's address bar along with the requested resource itself to the web server. The
server can use the Host header field to determine which web site (or virtual host), as well as
page, to show the user. The browser specifies the address by setting the Host HTTP header
with the host specified by the user. The Host header is required in all HTTP/1.1 requests.
For instance, a server could be receiving requests for two domains, www.example.com and
www.example.net, both of which resolve to the same IP address. For www.example.com,
the server would send the HTML file from the directory /var/www/user/Joe/site/, while
requests for www.example.net would make the server serve pages from
/var/www/user/Mary/site/.
Example: A blog server can be hosted using Name base hosting. blog1.example.com and
blog2.example.com
www.kerrneltech.com
Copy the same <VirtualHost> 7 lines, paste it at the last of the page and edit it as follows
Step3: Restart the server and open the web page from Firefox
#service httpd restart
www.kerrneltech.com
KICKSTART
AND
NETWORK INSTALLATIONS OF RHEL6
Kickstart files can be kept on a single server system and read by individual computers during
the installation. This installation method can support the use of a single kickstart file to
install Red Hat Enterprise Linux on multiple machines, making it ideal for network and
system administrators.
Kickstart installations can be performed using a local CD-ROM, a local hard drive, or via NFS,
FTP, or HTTP
www.kerrneltech.com
Lets see each option of kickstart file and create a new kickstart file.
www.kerrneltech.com
The first option in kickstart is basic configuration, Select the options required as below
Select the language, keyboard layout, Time Zone, assign root password, etc
The second tab is installation Method. For normal installation select CD-ROM
www.kerrneltech.com
To create partitions layout, click on Add button and follow the screens below
Select the mount points like /, /boot, /opt etc and create some partitions as usual
The layout after the creation of partition will be as follows
www.kerrneltech.com
The subsequent tab is Authentication where you can select the security type you want
After Authentication the next tab is Firewall Configuration, where we can configure
some firewall settings and SELinux settings.
www.kerrneltech.com
Note: If Firewall is enabled assign some services which are allowed in it.
Display Configuration Tab for selecting display environment of the O/S
The next tab after above is Package Selection where you can select various packages
that will be installed with O/S
After Package selection if you want to run any scripts pre and post- installation, you can
go for remaining two tabs, otherwise leave it.
Finally save the kickstart file in ftps document root, so that it can be accessible from any
machine in the network
www.kerrneltech.com
To modify the same, open system-config-kickstart application go to File -> Open and
navigate to the document root of ftp and select the file to be opened.
www.kerrneltech.com
Boot the system using RHEL 6 DVD and press Esc at splash screen
Type the following information about the kickstart file and its server and also assign some
IP address to the machine to communicate with kickstart server.
# linux ip=192.168.10.96 netmask=255.255.255.0 ks=ftp://192.168.10.95/pub/kt.cfg
After entering above information just press enter to continue with your kickstart
installation. Wait till installation is completed.
www.kerrneltech.com
NETWORK INSTALLATIONS
Network installations can be performed using following methods.
FTP
NFS
HTTP
Copy the entire RHEL6 DVD on document root of ftp i.e. /var/ftp/pub/
As we are trying to install RHEL6 from network still we require a boot media so that at
least we can get the boot screen where we can type our required command.
To get the boot screen we can have a media like CD/DVD or USB drive with boot.iso image
copied in it.
boot.iso image will produce a boot screen as follows
www.kerrneltech.com
After making the boot media, make the system boot with it, press Esc to type the
following command to take installation media from network
# boot: linux askmethod
After a while the following prompt will be display where you can select the preferred
language
It is the time now to select the medium from which you want to install the O/S
www.kerrneltech.com
Select URL for ftp and http, whereas NFS for installing from NFS
Define the network settings, if DHCP is configured in your environment select Dynamic if
not select Manual in iPv4 support
Assign some IP address to your machine so that it can communicate with the server. Make
sure that IP should be in the same range that of the server.
Once the network is configured automatically the following screen will appear, provide
the details of the ftp server as following
www.kerrneltech.com
Bingo, weve got the installation media from ftp server as follows.
www.kerrneltech.com
Give the information about the NFS server and directory as following
Copy the RHEL6 DVD dump in the document root of http i.e., /var/www/html , else just
create a soft link of the directory in the document root of http.
Restart the services of http and you are done with the server side configuration
Repeat all the steps as done for FTP installation, the only change would be In the URL
address which will as below
www.kerrneltech.com
We can select any method of installation from the list and specify the details regarding the
server.
If using ftp to access the kickstart file save it in document root of ftp
Observe that an automated installation will be perform and the installation media will be
taken from network.
Isnt it Amazing.!
Page 274 of 274
www.kerrneltech.com