Sunteți pe pagina 1din 110

RHCE

Session 1

 RHCE Certification Level


 History of Unix, Features of Unix & Distribution
 History of Linux, Features of Linux & Flavors
 About GNU, FSF & GPL
 Difference B/W Unix-Linux
 RHCE Course Details

Session 2

 Linux Architecture ( Kernel, Shell)


 Difference B/W Linux & Windows
 Types of Red Hat Linux
 Hardware Requirements for Linux Installation
 Types of Linux Installation
• Through CDROM – Text & GUI Mode
• Through Network – Text & GUI

Session 3 & 4

 HDD Basic, Types of HDD Partitions


 Boot loader & MBR
 Types of Boot loader In Linux
 Types of File Systems In Linux & Windows
 Difference B/W ext2-ext3, Fat-Ntfs
 Minimum Partitions Required For Linux
 Practical Installation ( LAB )
Session 5

 Linux & Windows File Structure


 All Linux System Directories Under /
 Installation According to RHCE EXAM
 Types of Modes in Linux – 1) TUI 2) GUI
 Types of User – 1) System 2) Non-System
 Types of Desktop – 1) GNOME 2) KDE 3) TWM
 Fully Qualified Domain Name (FQDN)

Session 6

 Basic Commands In Linux


pwd, cd, fdisk, df, du, hostname, dnsdomainname, ls, mkdir, rmdir,
rm, touch, cat, ifconfig, man, info, --help, cp, mv, cal, Date, logout, exit
Shutting Down Command – init 0, poweroff, halt, shutdown
Restarting Command – init 6, reboot, shutdown, ctrl+alt+del

Session 7

 Vi Editor & Its Operations – Copy, Cut, Paste, Delete, Undo, Redo, Search in
forward-Reverse, Set numbers & Others
 Mounting & Un mounting of CDROM, USB, Floppy & Windows Partitions
 Hostname Setting, IP Address Setting, ifup, ifdown

Session 8

 Types of Runlevel, Single User Mode, /etc/inittab file


 switchdesk & startx Command, Access GNOME, KDE, TWM
 Compressions-Decompressions, Archiving
Session 9

 About Inodes, Soft & Hard Links


 After installation Partition Creation
Creation of Ext3 Partitions
Creation of Vfat Partitions
Creation of Swap Partitions
Session 10

 Package Installation in Text & Graphical Mode ( RPM )


 Package Installation Through YUM

Session 11 & 12

 User & Group Administration


 Permission Bits ( rwx ), Suid, Sgid & Sticky Bits
 Access Control List (ACL)

Session 13

 User Quota
 Job Scheduler – Crontab

Session 14

 Process Management
 RAID – RAID 0, RAID 1, RAID 5
 How to Create RAID during Installation & after Installation
Session 15

 LVM ( Logical Volume Manager )


 How to Create LVM during Installation & after Installation
 Resize of LVM
 LVM Snapshot, Backup & Restore

Session 16 & 17

 Imp Files In Linux -


/etc/inittab, /etc/fstab, /etc/mtab, /etc/grub.conf, /etc/passwd, /etc/group, /etc/shadow,
/etc/gshadow, /etc/securetty, /etc/resolv.conf, /etc/hosts, /etc/hosts.allow,
/etc/hosts.deny, /etc/sysconfig/network, /etc/pam.d/login
 Basic shell Scripting

Session 18, 19 & 20

 Minor & Major Troubleshooting


 Rescue Mode Problems
 EXAM 1

Session 21

 RHCE Lab Setup


 Telnet Server & Telnet Client
 Security of Telnet Server (Th :-Xinetd)
 SSH Server (Secure Shell) & SSH Client, SCP, Slogin

Session 22
 DHCP Server & DHCP Client
(Dynamic Host Configuration Protocol)
 NFS Server & NFS Client
(Network File System)

Session 23

 DNS Server & DNS Client


(Domain name Service)
 Local DNS Configuration /etc/hosts file
Session 24

 Samba Server & Samba Client


 Samba Server Configuration in Windows
 Share File & Directory B/W Windows & Linux

Session 25

 NIS Server & NIS Client


(Network Information Service)
 NTP Server & Client
(Network Time Protocol)

Session 26

 Web Server & Web Client, Secure Web Server


 Web Site Accessing in TUI & GUI

Session 27 & 28

 Squid Proxy Server


 Allow & Deny Web Sites
 VSFTP Server & VSFTP Server
(Very Secure File Transfer Protocol)
 Uploading & Downloading Through System or Non System User &
Anonymous User

Session 29 & 30

 Sendmail Server
 IMAP-POP3 Server :- Mutt
 IMAP-SSL

Session 31

 Printer Server & Printer Client


 Syslog Server
 VNC Server

Session 32

 Tcp_Wrappers - /etc/hosts.allow, /etc/hosts.deny


 PAM – Pluggable Authentication Module
 Ipv6 Configuration, RADVD Server

Session 33

 IP Forwarding - /etc/sysctl.conf
 Firewall – Iptables
 Basic About SELINUX
(Security Enhanced Linux)

Session 34
 XEN With Virtualization :-
Installation of Packages, Defining Default Boot Loader, Installation of Virtual Operating
System

Session 35

 Modem Installation, ADSL Setup ( KPPP )


 Mp3 Songs, Movie Player Installation
 CD Writing & Acrobat Reader
 Open Office, GEdit, Graphical Tools
 How to Create & Run C, JAVA & SHELL Program
 EXAM 2
SESSION 1

 RHCE Certification Level


 History of Unix, Features of Unix & Distribution
 History of Linux, Features of Linux & Flavors
 About GNU, FSF & GPL
 Difference B/W Unix-Linux
 RHCE Course Details

Redhat Linux Certification

ARCHITECT
RHCA
SECURITY SPECIALIST
RHCSS
ENGINEER
RHCE

TECNICIAN
RHCT

RHCE Course Modules


 Redhat Linux Basic (RH 033)
 Redhat Linux System Administration (RH 133)
 Redhat Linux Network & Security Admin (RH 253)

History of Unix

 1969 BELL LAB’S DEVELOP A “PLATEFORM INDEPENDENT “


OPERATING SYSTEM THAT IS KNOWN AS “UNIX”

Features of Unix

 PLATEFORM INDEPENDENT
 OPEN SOURCE BUT NOT FREEWARE
 SMALL & SIMPLE PROGRAMME TO USE
 ALL HARDWARE DEFINE IN FORM OF FILES
 EXECUTION OF MULTIPLE COMMAND IS POSSIBLE BY USING PIPE ( | )
SYMBOL

Distribution of Unix

COMPANY OPERATING SYSTEM

 IBM AIX
 HP HP/UX
 SUN MICROSYSTEM SUN SOLARIS

History of Linux

 IN 1991 A STUDENT LINUS TORVALDS DEVELOP A KERNEL WITH


THE HELP OF UNIX PROGRAMMER THAT IS KNOWN AS “LINUX”
KERNEL + SHELL + APPL. S/W = OS
Features of Linux

 PLATFORM INDEPENDENT
 OPEN SOURCE & FREEWARE
 SMALL & SIMPLE PROGRAMME TO USE
 EVERYTHING DEFINE IN FORM OF FILE
 WE CAN EXECUTE MULTIPAL COMMAND

Distribution of Linux

COMPANY OPERATING SYSTEM

 REDHAT RHEL
 NOVEL SUSE
 MANDRAKE MANDRAK
 YELLOW DOG YELLOW DOG
 OPEN OPEN LINUX

How Linux Become Free

 IN 1992 LINUS TORVALDS SUBMITS HIS PROJECT IN AN


ORGANIZATION WHICH KNOWN AS “GNU”.
FSF (FREE SOFTWARE
GNU FOUNDATION)
GPL (GENERAL PUBLIC
LICENCE)

UNIX V/S LINUX


UNIX LINUX

OPERATING SYSTEM KERNEL

OPEN SOURCE BUT NOT FREEWAREOPEN SOURCE


&FREEWARE

SESSION 2

 Linux Architecture ( Kernel, Shell)


 Difference B/W Linux & Windows
 Types of Red Hat Linux
 Hardware Requirements for Linux Installation
 Types of Linux Installation
• Through CDROM – Text & GUI Mode
• Through Network – Text & GUI

Linux Architecture

HARDWARE

KERNEL

COMPILERS
COMMANDS & TOOL
APP. S/W
DATABASE PACKAGE

SHELL
USER

What Is Kernel & Shell


 Kernel - Kernel is main part of an O.S., Kernel is used to interact with hardware,
manage I/O devices, manage resources like CPU, RAM, HDD etc & used to
manage Processes.
 Shell - Shell is a text based program. Users can only interact with shell, then
shell interacts with kernel & finally kernel can interact with hardware.

WINDOWS V/S LINUX

LINUX WINDOWS

KERNEL OPRATING SYSTEM

OPEN SOURCE & FREEWARE N/A

VIRUS PROOF NO

MULTIPLE DESKTOP SINGLE DESKTOP

INBUILT APP. S/W NO

Type of Redhat Linux

1) Redhat Linux 2) Fedora 3) RHEL


Redhat Linux 3.0 Feodra 3.0 a) AS b) WS c) ES
Redhat Linux 4.0 Feodra 4.0 RHEL 3.0
Redhat Linux 5.0 Feodra 5.0 RHEL 4.0
Redhat Linux 6.0 Feodra 6.0 RHEL 5.0 -
Redhat Linux 7.0 Feodra 7.0 a) Server b) Client
Redhat Linux 8.0
Redhat Linux 9.0
Hardware Requirements for Linux Installation

 PIII - Min 800 Mhz


 PIV - Any
 RAM - 256 MB (512 MB)
 HDD - 10 GB
 CDROM

Types of Linux Installation

 Installation through CDROM (All Linux CD’s required)


 Installation through Network (Only Linux 1st CD required)
• NFS - Network File System
• FTP - File Transfer Protocol
• HTTP - Hyper Text Transfer Protocol

Installation through CDROM

 Insert Linux CD 1st & set cdrom 1st boot device

• a) For GUI Installation -- boot: Press Enter


• b) For TUI Installation -- boot: linux text

 Create Following Partition Manually through fdisk

• A) Minimal Installation Method



 a) / (ext3) 5000MB
 b) swap (swap) 2*RAM Size
 (B) Advanced Installation Method

a) /boot (ext3) 100MB
b) / (ext3) 1000MB
c) /usr (ext3) 5000MB
d) /home (ext3) 500MB
e) /var (ext3) 500MB
f) swap (swap) 2*RAM Size

 Define IP Address, Subnet Mask, Nameserver, Gateway & FQDN Information


 Define Time Zone (Aisa/calculta)
 Define root user password
 Select Packages for installation
• After it installation starts & changes CD’s

Installation through Network

 Insert Linux CD 1st & set cdrom 1st boot device

• For GUI Installation -- boot: linux askmethod


• b) For TUI Installation -- boot: linux text askmethod
 Select Installation Method (NFS)
 Define Local m/c IP address information

IP Address : 172.24.0.X
Subnet Mask : 255.255.0.0
Primary Nameserver : 172.24.254.254
Default Gateway : 172.24.254.254

 Define IP address of NFS Server & directory name


Server : 172.24.254.254 or Name of Server
Path : /var/ftp/pub
 Then press ok
Now Client M/C contact with server m/c, if server is ready then client connects to server
m/c & fetches all data from server directory.
 Create Following Partition Manually through fdisk

• A) Minimal Installation Method


a) / (ext3) 5000MB
b) swap (swap) 2*RAM Size

(B) Advanced Installation Method

a) /boot (ext3) 100MB


b) / (ext3) 1000MB
c) /usr (ext3) 5000MB
d) /home (ext3) 500MB
e) /var (ext3) 500MB
f) swap (swap) 2*RAM Size

 Define IP Address, Subnet Mask, Nameserver,


 Gateway & FQDN Information
 Define Time Zone (Aisa/calculta)
 Define root user password
 Select Packages for installation
Now no need to change CD’s, client
automatically fetches data from server.
SESSION 3 & 4

 HDD Basic, Types of HDD Partitions


 Boot loader & MBR
 Types of Boot loader In Linux
 Types of File Systems In Linux & Windows
 Difference B/W ext2-ext3, Fat-Ntfs
 Minimum Partitions Required For Linux
 Practical Installation ( LAB )

HDD Basic

 hda, hab, hdc, hdd for IDE or PATA HDD.


 Sda, sdb, sdc, sdd for SATA, SCSI & USB drive.
• hda - Primary Master
• hdb - Primary Slave
• hdc - Secondary Master
• hdd - secondary Slave
Types of HDD Partitions

 Primary Partition (Booting Partitions)


 Extended Partitions (Define Space for logical partitions)
 Logical Partitions under Extended Partitions (Used for data storage)
 Note - In a HDD we can create max. 4 primary partitions but after that we can’t
create extended & logical partitions.

Types of HDD Partitions

 Note - In a HDD we can create maximum 1 extended partition.


 Note - In Linux 1 to 4 numbers are reserved for primary & extended partitions &
logical always starts from 5.
 Example: hda1, hda2, hda3, hda5, hda6 means 2 primary, 1 extended & 2 logical
partition

MBR & Bootloader

 MBR stand for Master Boot Record. MBR is the zero or first sector of a HDD.
MBR is used to store bootloader & booting files information.
 Bootloader is a software that is used to define list of all installed O.S., bootloader
installed into MBR.

Bootloader in Linux

GRUB - Grant Universal Boot Loader (Default in RHEL 5.0)


LILO - Linux Loader

File System & Types of File system in Windows & Linux

 File System is known as indexing. File system is used to define no. of tracks,
sectors, cylinder, heads etc. For defining file system, we format the HDD drive.
Windows Linux
 FAT 16 EXT2, EXT3
 FAT 32 Swap
 NTFS LVM
RAID
VFAT

Difference B/W ext2-ext3

EXT2 EXT3

JOURLANING FEATURES

DYNAMIC INODES

FILE SYSTEM RECOVERY

ADVANCED FILE SYSTEM

Difference B/W NTFS-FAT32

NTFS FAT32

DISK QUOTA
COMPRESSION &
DECOMPRESSION

ENCRYPTION

SECURE

Minimum Partitions Required For Linux


 Minimum 2 partition required for Linux
• / (ext3) 5000MB
• swap (swap) 2*RAM Size

Practical Lab Setup Installation of Linux in GUI & TUI

SESSION 5

 Linux & Windows File Structure


 All Linux System Directories Under /
 Installation According to RHCE EXAM
 Types of Modes in Linux – 1) TUI 2) GUI
 Types of User – 1) System 2) Non-System
 Types of Desktop – 1) GNOME 2) KDE 3) TWM
 Fully Qualified Domain Name (FQDN)

Linux File Structure Concept

 Files and directories are organized into a single-rooted inverted tree structure, File
system begins at the root directory, represented by a lone / (forward slash)
character.
• Names are case-sensitive
• Paths are delimited by /

Linux File Structure Concept

 Example of some System Directories


• Home Directories: /root,/home/username
• User Executables: /bin, /usr/bin, /usr/local/bin
• System Executables: /sbin, /usr/sbin, /usr/local/sbin
• Other Mountpoints: /media, /mnt
• Configuration: /etc
• Temporary Files: /tmp

Linux File Structure Concept

 Example of More System Directories


• Kernels and Bootloader: /boot
• Server Data: /var, /srv
• System Information: /proc, /sys
• Shared Libraries: /lib, /usr/lib, /usr/local/lib

All Linux System Directories Under /

 The /dev Directory


The /dev directory contains _le system entries which represent devices that are
attached to the system.
These _les are essential for the system to function properly

 The /lib Directory


The /lib directory should contain only those libraries that are needed to
execute the binaries in /bin and /sbin. These shared library images are
particularly important for booting the system and executing commands within
the root _le system.

 The /etc Directory


The /etc directory is reserved for system & network Configuration files.

 The /media Directory


The /media directory is for temporarily mounted file systems, such as CD-ROMs
and floppy disks.
 The /opt Directory
The /opt directory provides an area for third party packages

 The /proc Directory


The /proc directory contains special "files" that either extract information
from or send information to the kernel.
Due to the great variety of data available within /proc and the many ways this directory
can be used to communicate with the kernel, an entire chapter has been devoted to the
subject.

 The /sbin Directory


The /sbin directory is for executables used only by the root user.
At a minimum, the following programs should be in /sbin:
arp, clock,getty, halt,init, fdisk,fsck.*, grub, ifconfig, lilo,mkfs.*, mkswap,reboot,
route, shutdown, swapoff,swapon, update

 The /usr Directory


The /usr directory is for files that can be shared across a whole site. The /usr
directory usually has its own partition, and it should be mountable read-only.

 The /var Directory


Since the FHS requires that you be able to mount /usr read-only, any programs
that write log _les or need spool or lock directories should write them to the /var
directory. The FHS states /var is for:
"...variable data _les. This includes spool directories and _les, administrative and
logging data, and transient and temporary _les."
Types of Modes in Linux

 A typical Linux system will run six virtual consoles and one graphical console
Server systems often have only virtual consoles Desktops and workstations
typically have both Switch among virtual consoles by typing: Ctrl-Alt-F[1-6]
Access the graphical console by typing Ctrl-Alt-F7

Types of User

 Two type of User in the Linux

1) System User or Root User (#)


ex :- [root@station1 ~]#

2) Simple User ($)


ex :- [r1@station1 ~]$

Note :- Here “Station1” is Host Name And “ ~ ” is Home Directory of Root User or a
Simple User

Types of Desktop

 The X Window System is Linux's graphical subsystem.


Open source implementation of X Look and behavior largely controlled by the desktop
environment.
 Three desktop environments provided by Red Hat
 GNOME: the default desktop environment – GNU Network Model
Environment
 KDE: an alternate desktop environment- K Desktop Environment
 TWM – Tab Window Manager

Fully Qualified Domain Name


 FQDN – Fully qualified domain name
 Host+domainname = FQDN
• EX. Station1+ example.com =
station1.example.com

SESSION 6

 Basic Commands In Linux


pwd, cd, fdisk, df, du, hostname, dnsdomainname, ls, mkdir, rmdir, rm, touch, cat,
ifconfig, man, info, --help, cp, mv, cal, Date, logout, exit
• Shutting Down Command – init 0, poweroff, halt, shutdown
• Restarting Command – init 6, reboot, shutdown, ctrl+alt+del

Basic Commands In Linux

 Commands have the following syntax:


command options arguments
Each item is separated by a space Options modify a command's behavior
 Single-letter options usually preceded by “ - “
Can be passed as -a -b -c or -abc

 Full-word options usually preceded by “ -- “


Example: --help

 [root@station1 ~]# date (display date and time)


Mon Nov 26 07:26:49 IST 2007

 [root@station1 ~]# cal (display calendar)


November 2007
Su Mo Tu We Th Fr Sa
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30

 The whatis Command

• Displays short descriptions of commands


• Uses a database that is updated nightly
• Often not available immediately after install

[root@station1 ~]# whatis cal


cal (1) - displays a calendar

 The Pwd Command

[root@station1 ~]# pwd


(show present working directory)
Result = /root
[root@station1 etc]# pwd
Result = /etc

 The cd Command

• cd (changes directories)
• To an absolute or relative path:

Ex:- [root@station1 etc]# cd


/home/ram/work
• To a directory one level up:

[root@station1 etc]# cd ..
• To your home directory:

[root@station1 etc]# cd
• To your previous working directory:

[root@station1 etc]# cd –

 The fdisk Command

[root@station1 ~]# fdisk –l (Show all hdd partition information)

Disk /dev/hda: 80.0 GB, 80026361856 bytes


255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Start End Blocks Id System
/dev/hda2 1913 1925 104422+ 83 Linux
/dev/hda3 1926 4475 20482875 83 Linux

 The df Command
[root@station1 ~]# df –h (Show all mounted Partition information)

Filesystem Size Used Avail Use% Mounted on


/dev/hda3 19G 12G 6.3G 66% /
/dev/hda2 99M 17M 78M 18% /boot
tmpfs 1009M 0 1009M 0% /dev/shm

 The du Command

[root@server1 home]# du -h /boot/ (disk usages- Show dir usage space)


12K /boot/lost+found
237K /boot/grub
11M /boot/

 The hostname Command

[root@server1 home]# hostname


server1.example.com

 The dnsdomainname Command

[root@server1 home]# dnsdomainname


example.com

 The nisdomainname Command

[root@server1 home]# nisdomainname


notexample

 The ls Command
[root@server1 home]# ls
s2 s1 t1
[root@server1 home]# ll (Details in list form )

total 3

drwx------ 2 s2 s2 4096 Aug 30 12:35 s2


drwx------ 2 s1 s1 4096 Aug 11 19:03 s1
drwx------ 3 t1 t1 4096 Sep 3 12:28 t1
[root@server1 home]# ls -a (Show hidden file also)
. .. guests ram s1 t1

 The ifconfig Command

[root@server1 ~]# ifconfig


(This Command is use for viewing information about LAN card & IP Address)

 The who & w Command


[root@server1 ~]# who
[root@server1 ~]# w
(Both Command’s show that how many user login, on which time, on which terminal)
 The --help Option

Displays usage summary and argument list


Used by most, but not all, commands
ex :- $ date –help
Display the current time in the given
FORMAT, or set the system date.

 The man Command

Provides documentation for commands


Almost every command has a man "page“ Pages are grouped into "chapters"
Collectively referred to as the Linux Manual

 The info Command

Similar to man, but often more in-depth


Run info without arguments to list all age
info pages are structured like a web site
Each page is divided into "nodes"
Links to nodes are preceded by *

 Copying Files and Directories (cp command)

cp - copy files and directories Usage:

[root@station1 etc]# cp [options] file destination

More than one file may be copied at a time if the destination is a directory:

[root@station1 etc]# cp [options] file1 file2 destination

 Moving and Renaming Files and Directories (mv command)

mv - move and/or rename files and directories Usage:

[root@station1 etc]# mv [options] file destination

More than one file may be moved at a time if the destination is a directory:

[root@station1 etc]# mv [options] file1 file2 destination


Destination works like cp
 Creating and Removing Files

[root@station1 etc]# touch - create empty files or update file timestamps

[root@station1 etc]# rm - remove files

[root@station1 etc]# rm [options] <file>..

Ex: [root@station1 etc]# rm -r directory(recursive)

[root@station1 etc]# rm -f file (force)

 Creating and Removing Directories

[root@station1 etc]# mkdir creates directories

[root@station1 etc]# rmdir removes empty directories

[root@station1 etc]# rm -r recursively removes directory trees

 Command for shutting down

[root@station1 etc]# init 0


[root@station1 etc]# poweroff
[root@station1 etc]# halt
[root@station1 etc]# shutdown –h now

 Command for restart


[root@station1 etc]# init 6
[root@station1 etc]# reboot
[root@station1 etc]# ctrl+alt+del
[root@station1 etc]# shutdown –r now

SESSION 7

 Vi Editor & Its Operations – Copy, Cut, Paste, Delete, Undo, Redo & Others
 Mounting & Un mounting of CDROM, USB, Floppy & Windows Partitions
 Hostname Setting, IP Address Setting.

VI Editor
 VI Editor is used to create a new file, edit in existing file, cut, copy, paste, insert,
delete, set numbers before the line etc. For creating new file we write down

#vi file name/destination add. with file name


Ex: #vi training or /home/ram/training

For edit existing file


#vi existing file name or with add file name
#cd /etc after that #vi fstab
# vi /etc/fstab

Vi Editor Modes

 Keystroke behavior is dependent upon vi "mode"


 Three main modes:
Command Mode (default): Move cursor, cut/paste text, change mode
Insert Mode: Modify text
Ex Mode: Save, quit, etc
Esc exits current mode
Note:- Esc always returns to command mode

Vi Editor

 Opening a file in vim

To start vi: vim filename


If the file exists, the file is opened and the contents are displayed
If the file does not exist, vi creates it when the edits are saved for the first time
 Modifying a File

Insert Mode

i begins insert mode at the cursor

 Saving a File and Exiting vim

Execution Mode

Enter Ex Mode with “ : “


Creates a command prompt at bottom-left of screen

Common write/quit commands:

:w writes (saves) the file to disk


:wq writes and quits, wq! write forcefully
:q! quits, even if changes are lost

 Undoing Changes Command Mode

u undo most recent change


U undo all changes to the current line since the cursor landed on the line
Ctrl-r redo last "undone" change

 Cut/Copy/Paste Command Mode

dd for delete a line, 5dd delete 5 lines


yy for copy a line, 5yy copy 5 lines
p for paste a line

What Is Mounting
 Mounting means making a foreign filesystem look like part of the main tree.
 Before accessing, media must be mounted
 Before removing, media must be unmounted
 By default, non-root users may only mount certain devices
(cd, dvd, floppy, usb, etc)
 Mountpoints are usually under /media

Mounting of CDROM

 Automatically mounted in Gnome/KDE.Otherwise, must be manually mounted.


First we have to insert a line in “/etc/fstab” file.
/dev/hdb /media/cdrom udf,iso 9660 defaults 00

 CD/DVD Reader

mount /media/cdrom

 Un mounts and ejects


eject
Mounting USB Media

 Mounting USB Media


Detected by the kernel as SCSI devices
/dev/sdaX or /dev/sdbX or similar
Automatically mounted in Gnome/KDE
Icon created in Computer window Mounted under /media/Device ID
Device ID is built into device by vendor

Mounting Floppy Disks

 Must be manually mounted and un mounted


mount /media/floppy
umount /media/floppy
DOS floppies can be accessed with mtools
Mounts and unmounts device transparently
Uses DOS naming conventions
mdir a:
mcopy /home/file.txt a:

Mounting Windows Partitions

 For Mounting windows partition we have to write down following command


#mount -t vfat /dev/hdc1 /media/partition1

 Note:- this is temporary mounting, we only mount FAT32 partition in Linux,


for Permanente Mounting we have to enter details in “/etc/fstab” file like we
enter for cdrom

Hostname Setting

 Temporary change:
For temp. change we write down following command
#hostname station100.example.com

 Permanente change: For this we open


“#vi /etc/sysconfig/network” file and change host name when we restart our pc
we find new hostname.

IP Address settings

 Setting up new IP add. We write following command


#netconfig or
#system-config-network
#service network restart
 Note: if above command not run then we open a file
“#vi /etc/sysconfig/network-script/ifcfg-eth0” and write
IPADDR=, NETMASK=, GATEWAY=,

SESSION 8

 Types of Runlevel, Single User Mode


 switchdesk & startx Command, Access GNOME, KDE, TWM
 Compressions-Decompressions, Archiving

Intro of Runlevels

 Runlevels is system software of the operating system that defines no of process


exist for a level.
 In Linux there are 7 type of runlevels from 0-6
 These runlevels control by ”init” command.
 Init is the first process of the system and the process id is 1

Types of Runlevels

 Init 0 = for shutdown


 Init 1 = for single user mode / troubleshooting
 Init 2 = multi user, text mode without N/W support
 Init 3 = multi user, text mode with N/W support
 Init 4 = unused
 Init 5 = multi user, text + gui mode, with N/W support
 Init 6 = reboot

Runlevel setting

 For set a default Runlevel Open


“#vi /etc/inittab” file, change line in the file
“ld:3: initdefault” in place of 3 we enter 5 for GUI + Text support

 After that reboot pc.


 For check the current Runlevel
#runlevel

Single User Mode

 For access single user mode


 At the booting time press “e” on Linux boot loader line
 Come at second line or on kernel line again press “e”
 Go last of the line press “spacebar” then press “s or 1” then enter, Press “b” for
booting
 Now system starts in single user mode without username & password. We can
change any file of the system.

Accessing GUI directly from Runlevel 3

 For accessing GUI directly we run following command


#switchdesk gnome

 For run GUI


#startx
 Note : For run the switchdesk command we have to check
switchdesk package is installed or not

Archiving

 Archiving places many files into one target file Easier to back up, store, and
transfer tar - standard Linux archiving command Archives are commonly
compressed Algorithm applied that compresses file Uncompressing restores the
original file tar natively supports compression using gzip and bzip2
Archiving Configuration

 For compress some files we have to archive them first by using following
command.

#tar cvf f1.tar files name


Ex: #tar cvf s1.tar s2 s4 s5 s6

#tar tvf f1.tar (for check the .tar contain)

#tar xvf f1.tar (for extracting .tar file)

Compressions-Decompressions

 First we archive file and directories the use following command for compression
 #gzip f1.tar or #bzip2 f1.tar
Result: f1.tar.gz or f1.tar.bz2

 For decompression
 #gunzip f1.tar.gz or #bunzip2 f1.tar.bz2
Result: f1.tar

SESSION 9
 About Inodes, Soft & Hard Links
 After installation Partition Creation
• Creation of Ext3 Partitions
• Creation of Vfat Partitions
• Creation of Swap Partitions

Inodes

 An inode table contains a list of all files in an ext2 or ext3 filesystem


 An inode (index node) is an entry in the table, containing information about a file
(the metadata), including: File type, permissions, UID, GID.
The link count (count of path names pointing to this file).The file's size and various time
stamps. Pointers to the file's data blocks on disk. Other data about the file.

Directories

 The computer's reference for a file is the Inode number


 The human way to reference a file is by file name
 A directory is a mapping between the human name for the file and the computer's
Inode number

 cp and inodes

The cp command:

Allocates a free inode number, placing a new entry in the inode table.
Creates a dentry in the directory, associating a name with the inode number
Copies data into the new file.

 mv and inodes

If the destination of the mv command is on the same file system as the source,
Creates a new directory entry with the new file name.
Deletes the old directory entry with the old file name.
Has no impact on the inode table (except for a time stamp) or the location of data on the
disk: no data is moved!
If the destination is a different filesystem, mv acts as a copy and remove

 rm and inodes

Decrements the link count, thus freeing the inode number to be reused.
Places data blocks on the free list. Removes the directory entry.
Data is not actually removed, but will be overwritten when the data blocks are
used by another file.

Soft & Hard Links

 A hard link adds an additional pathname to reference a single file


One physical file on the filesystem
Each directory references the same inode number, Increments the link count
The rm command decrements the link count File exists as long as at least one link
remains
When the link count is zero, the file is removed Cannot span drives or partitions
ln filename [linkname]
 A symbolic link points to another file ls -l displays the link name and the
referenced file

“lrwxrwxrwx 1 joe joe 11 Sep 25 18:02 pf -


> /etc/passwd”

File type: l for symbolic link


The content of a symbolic link is the name of the file that it references
Syntax:
ln -s filename linkname

Partition Creation
 We can create following type of Partition
1. ext3 (Linux data partition)
2. vfat (fat 32 type)
3. swap (virtual memory partition)

For creating partition in Linux we use “fdisk” utility. By the help of this utility we can
done many task’s like partition type change etc.

Fundamental of fdisk utility

 Before creating partition we have to know what is the basic command of “fdisk”
• #fdisk /dev/hda (step 1 of the par. creation)

(here we suppose that hdd is primary master)


:n = create new partition
:d = delete a partition
:l = list all file system ID
:t = change the file system
:w = write partition table & quite
:q = quite without save
:p = show partition table

Ext3 Partition Creation

#fdisk /dev/hda
:n (new partition)
: press enter (enter the stating cylinder no)
: +100M (enter size of partition)
:w (write & quit)
#partprobe or reboot (for refreshing the table)

Format partition
#mkfs.ext3 /dev/hda10

Ext3 Partition Mounting

#mkdir /media/newpartition

Now open “#vi /etc/fstab” & enter new partition details

/dev/hda10 /media/newpartition ext3 defaults 0 0

:wq (save & quite)


#mount -a (mount all partition which in the fstab file)

Vfat Partition Creation

#fdisk /dev/hda
:n (new partition)
:press enter (enter the stating cylinder no)
: +100M (enter size of partition)
:t (for change the file system)
Partition no. [1-11]
New id = d (new file system id which know th l)
:w (write & quit)
#partprobe or reboot (refreshing table)

Format partition
#mkfs.vfat /dev/hda11

Vfat Partition Mounting

#mkdir /media/newpartition2
Now open “#vi /etc/fstab” & enter new partition details
/dev/hda10 /media/newpartition2 vfat defaults 0 0

:wq (save & quite)


#mount -a (mount all partition which in the fstab file)

Swap Partition Creation

#fdisk /dev/hda
:n (new partition)
: press enter (enter the stating cylinder no)
: +100M (enter size of partition)
:t (for change the file system)
Partition no. [1-11]
New id = 82 (new file system id which know th l)
:w (write & quit)
#partprobe or reboot (refreshing table)

Format partition
#mkswap /dev/hda12

Swap Partition On/Off

 For Enable Swap space


#swapon /dev/hda12

#free (for checking space of swap partition)

 For Disable Swap space


#swapoff /dev/hda12

SESSION 10
 Package Installation in Text & Graphical Mode ( RPM )
 Package Installation Through YUM

Redhat Package Manager

 In this section we learn how to install,search, update, and erase the packages.
Windows supports .exe files and Redhat support .rpm files In Redhat Linux all packages
extension is .rpm

RPM Management

 How to search all install packages?


#rpm -qa
#rpm -qa | less (page wise)

 How to search a specific package?


#rpm -qa telnet*
#rpm -qa | grep telnet*

 How to Erase a package?


#rpm -e package name*
#rpm -e --nodeps pack. Name
.
Installation thro. RPM

 How to install a package through cdrom or through dump?


 First mount your cdrom with a dir. Then write following command.

#cd /media/cdrom/Server
#rpm -ivh package name
#rpm -ivh --force package name
#rpm -ivh --nodeps package name
Updation thro. RPM

 How to upgrade a package?


First go to the destination of the packages. After that write down following command

#rpm -Uvh package name


Note : here “U” is in capital form and all command in small form.

 In graphical mode we write following command


#system-config-package

YUM

 YUM is a new software in RHEL5.0 by this we can install packages and also with
dependencies. We don’t want to remember dependencies name’s.
 By the help of this we can remove and update the packages.
 We have to create repositories either server site or locally for yum.
 We can use ftp and http methods for installing, erasing through yum.

Configuration of YUM

 First search yum package through rpm


#rpm -qa yum*
if the package is installed then open

#vi /etc/yum.repos.d/server1.repo (we create this file)


In file
[Server]
name= any name
baseurl = ftp://172.24.254.254/pub/Server
enabled = 1
gpgcheck = 0

Working of YUM

 Now YUM is ready to install, search, update and also for remove the packages.
By the help of following command we can done the described process

#yum install package name*


#yum remove package name*
#yum update package name*
#yum search package name*
SESSION 11 & 12

 User & Group Administration


 Permission Bits ( rwx ), SUID, SGID & Stricky Bit
 Access Control List (ACL)

User & Group

 Every user is assigned a unique User ID number (UID).


 UID 0 identifies root.
 Users' names and UIDs are stored in “/etc/passwd“
 Users are assigned a home directory and a program that is run when they log in.
(usually a shell)
 Users cannot read, write or execute each others files without permission.
 Users are assigned to groups.
 Each group is assigned a unique Group ID number (gid).
 GIDs are stored in /etc/group.
 Each user is given their own private group Can be added to other groups for
additional access.
 All users in a group can share files that belong to the group.
 When user accounts are created, a private group is also created with the same
name.
 Users are assigned to this private group.
 User's new files affiliated with this group.
 Advantage: Prevents new files from belonging to a “public” group
 Disadvantage: May encourage making files “world-accessible

User Administration

 How to add a User?


 There is two types to add a User. The commands is following
#useradd user name
#adduser user name

 How we secure a user?


 By giving a password we secure a user. The command is following
#passwd username

 How to Delete a User?


 For deleting the user we have following command
#userdel user name

 Note: By above command we can only delete user not his directories if we
want that then we write down following command
#userdel -r user name

Group Administration

 How to add a Group?


 The commands is following
#groupadd group name

 How to Delete a group?


 For deleting the group we have following command
#groupdel group name

 Note: we can’t delete a Primary Group

User & Group Administration

 A New User always create following


1. User (s1)
2. Group (s1)
3. Directories (/home/s1)

 User Id (UID) & Group Id (GID)


 All User & group have a unique identification which known as UID & GID.
System User: 0-499 (range of UID & GID)
Non System User: 500-65535 (range of id)

 What is the ID of the User?


 The command is following
#id user name
result: uid(500), gid(500), group(s1, r1)

User & Group Information file:

#vi /etc/passwd (this file store user info.)


#vi /etc/group (this file store group info.)
#vi /etc/shadow (user password info.)
#vi /etc/gshadow (group info. In encryption)

 In GUI mode we have to write following command for accessing User & Group
Administration
#system-config-user

 Some Important question related to User & Group Administration


 Create a User p1 with User ID 5000.
#useradd -u 5000 p1

 Cerate a User p2 with Primary Group p1.


#useradd -g p1 p2

 Create a user p3 with Secondary Group p1.


#useradd -G p1 p3
 Create a User p4 with Secondary Group p1,p3.
#useradd -G p1, p3 p4

 Create a User p5 & define Dire. Location /p5.


#useradd -d /p5 p5
 Create a User p6 without login prompt.
#useradd -s /sbin/nologin /p6
Note: we use service through this user but doesn’t login th. this.

Some question for existing Users.

 How to add a Secondary group in a User.


#usermod -G h2 h1

 How to add a Primary group in a User.


# usermod -g h2 h1

Permission Bits

 In Linux each file & directories has 10 permissions bits. By using “#ll” command
we see that

- --- --- ---


First bit is for
d = directories
- = file
c = character devices (Modem, Printer)
b = block devices (Hard Disk, CDROM)

Permission Bits for user


- --- --- ---

After 3 bites are for user, by the help of this we can give permission to user that they
access the file or not.
r = Read (4), w = Write (2), x = execute (1)
Permission Bits for group

- --- --- ---

After 3 bites are for Group, by the help of this we can give permission to Group that they
access the file or not.
r = Read (4), w = Write (2), x = execute (1)

Permission Bits for other

- --- --- ---


After 3 bites are for Other, by the help of this we can give permission to Other that they
access the file or not.
r = Read (4), w = Write (2), x = execute (1)

Note: if we give “x” permission to a file then white color change into green.

Permission Bits Details

Description of “rwx” :
r (Read) = If we give “r” to user then user read that file of dir. If we give “r” to
group that means group members read that file or dir. If we give
“r” to others that means other user’s also read that file & dir.
w (Write) = If we give “w” to user then user write that file of dir. If we give “w” to
group that means group members write that file or dir. If we give
“w” to others that means other user’s also write that file & dir.
x (Execute) = If we give “x” to user then user execute that file of dir. If we give
“x” to group that means group members execute that file or dir. If we give “x” to others
that means other user’s also execute that file & dir.
Permission Bits Setting

 How to change the Permission Bits?


 We have two type of method to change the Permission Bits.

1. Numerical Method: (4,2,1)

Ex: p1 = user = rwx, group = r-x, other = ---


#chmod 750 p1
.
2. Value Method: (r,w,x)
- = for delete permission
+ = for add a permission
u, g, o = for user, group, other
r,w,x = for read, write, execute.

Ex: p1 = user = rx, group = r-x, other = ---


#chmod ug+rx

Defaults Permission Bits

 Defaults Permission Bit’s


 Maximum permission of a dir is 777 & a file 666. But when we create a file or
dir we find permission 644 or 755. It’s change because default umask is 022,
means 022 less from the permission of the file & dir. umask is differ for system &
non system user.

UMASK

 For know the umask value we run following command

#umask
#umask 002 (this line change umask temp..)
 If you want to change permanently then open
#vi /etc/bashrc
Note:In this file we have first simple user umask, Second root user umask.

SUID, SGID & Stricky Bit

 Normally processes started by a user run under the user and group security
context of that user.
 SUID and/or SGID bits set on an executable file cause it to run under the user
and/or group security context of the file's owner and/or group
 Used to create a collaborative directory Normally, files created in a directory
belong to the user's the default group When a file is created in a directory with the
SGID bit set, it belongs to the same group as the directory. Normally users with
write permissions to a directory can delete any file in that directory regardless of
that file's permissions or ownership with the sticky bit set on a directory, only the
owner of a file can delete the file

Access Control List

 ACL is process by using we can define more then one user & group on a
directories and file, when group & others are not allowed through permission
bit’s.
 For using this feature we have to mount /home directories with a partition.
 Now we remount /home dir. with ACL option
#mount -o remount,acl /home

ACL Configuration

 Create a file or dir and check the permission by the help of following command
#getfacl /home/ram

 Cerate a new user


 Now we set user & group permission on a file
#setfacl -m u:s1:rwx /home/ram
 Remove the assign permission
#setfacl -x u:s1 /home/ram

SESSION 13

 User Quota
 Job Scheduler – Crontab

User Quota

 User Quota service is used to provides a fixed amount of space to users.


 In Linux User Quota service can provides two type of limitations
1. Number of blocks used by a user
2. Number of files used by user
 These two limitation can define soft & hard limit
 If a user cross soft limit then a warning message appear & a grace period starts
 But that user can used up to hard limit.
 After hard limit “write operation fail” message appears.
 For use this function we have to create a partition and mount with the /home dir.
 In “/etc/fstab” we have to add “usrquota” with defaults by the help of “ , ”
(comma)

User Quota Configuration

#mount -o remount /home


(This command is remount home dir with new operation)

#quotackeck -cvu /home


(For checking no. of files & dir in /home )

#quotaon /home (For enable the quota)

#repquota -a (For check the quota status)

#edquota user name (For edit quota)

#quotaoff /home (For disable the quota)

#edquota -t (For changing the grace period)

Note: create quota problem for simple user


“dd if=/dev/zero of=/home/kk/somefile bs=1024 count=30”

Job Scheduler – Crontab

 Job scheduler is used to scheduling a job previously base on minute, hours, date,
month & day of week.
 In Linux “ CRONTAB” is used as Job Scheduler.

 How to schedule a job through “Crontab”?


#crontab -e

Min Hour Date Month Day of week job/comment


(0-59) (0-23) (1-31) (1-12) (0-6/1-7) poweroff

#service crond restart


#chkconfig crond on

Crontab Configuration

 How to check all schedule job.


#crontab –l

 How to remove all schedule job.


#crontab –r

 How to view other user schedule through other user.


#crontab -u username -e

Crontab Question

 Schedule a crontab that display a message hello on login terminal daily 9.30.
#crontab –e

Min Hour Date Month Day of week job/comment


30 9 * * * echo “Hello” | wall
#service crond restart

 Schedule a crontab that display a message “shut down” on terminal 5 daily at


evening 6.30 pm.
#crontab –e

Min Hour Date Month Day of week job/comment


30 18 * * * echo “shut down” > /dev/tty5
#service crond restart
SESSION 14

 Process Management
 RAID – RAID 0, RAID 1, RAID 5
 How to Create RAID during Installation & after Installation

Process Management

 A program in execution condition is known as process.


 In Linux “init” is the first process of the system & process id 1
 Each process has a process id & a parent process id.
 There are two type of process.
 Foreground Process
 Background Process (deamon)
 Foreground Process use the terminal.
 Background Process doesn’t use the terminal.

#ps (show process)

#ps -aef (show back & fore ground process)

#ps -aef | grep service name (filter for service)

#kill 3458 (process id)


#pstree (list of all process tree)

#top (all current process show with time)

 How to access task manager in GUI Mode.

#gnome-system-monitor
#kpm (k process manager)

RAID

 Multiple disks grouped together into "arrays" to provide better performance,


redundancy or both.
 mdadm - provides the administration interface to software RAID.
 Many "RAID Levels" supported, including RAID O, 1 and 5.
 Spare disks add extra redundancy
 RAID devices are named, /dev/md0, /dev/md1, /dev/md2, /dev/md3 and so on.

RAID Configuration

 Create and define RAID devices using mdadm

mdadm -C /dev/md0 l 1 n 2 /dev/sda12 /dev/sda13

 Format each RAID device with a filesystem


mkfs.ext3 /dev/md0

 mdadm allows you to check the status of your RAID devices


mdadm --detail /dev/md0

 Software RAID Testing and Recovery


Simulating disk failures
mdadm /dev/md0 -f /dev/sda1

 Recovering from a software RAID disk failure replace the failed hard drive and
power on reconstruct partitions on the replacement drive
mdadm /dev/md0 -a /dev/sda1
mdadm, /proc/mdstat, and syslog messages
SESSION 15

 LVM ( Logical Volume Manager )


 How to Create LVM during Installation & after Installation
 Resize of LVM
 LVM Snapshot, Backup & Restore

Logical Volume Manager

 A layer of abstraction that allows easy manipulation of volumes. Including


resizing of file systems.
 Allows reorganization of file systems across multiple physical devices.
 Devices are designated as Physical Volumes.
 One or more Physical Volumes are used to create a Volume Group
 Physical Volumes are defined with Physical Extents of a fixed size.
 Logical Volumes are created on Physical Volumes and are composed of Physical
Extents.
 File systems may be created on Logical Volumes.
LVM Configuration

 Creating Logical Volumes


 Create physical volumes
#pvcreate /dev/hda3

 Assign physical volumes to volume groups


#vgcreate vg0 /dev/hda3

 Create logical volumes from volume groups


#lvcreate -L +256M -n data /dev/vg0
#mkfs.ext3 /dev/vg0/data

#mkdir /lvm | mount /dev/vg0/data /lvm

 Resizing Logical Volumes


 Growing Volumes
#lvextend -L +50M /dev/vg0/data
#resize2fs /dev/vg0/data

 How to check the volumes?


#pvdisplay (for physical volume)
#vgdisplay (for volume group)
#lvdisplay (for logical volume)

Logical Volume Manager Snapshots

 Snapshots are special Logical Volumes that are an exact copy of an existing
Logical Volume at the time the snapshot is created.
 Snapshots are perfect for backups and other operations where a temporary copy
of an existing dataset is needed.
 Snapshots only consume space where they are different from the
original Logical Volume.
 Snapshots are allocated space at creation but do not use it until changes are made
to the original Logical Volume or the Snapshot.
 When data is changed on the original Logical Volume the older data is copied to
the Snapshot.
 Snapshots contain only data that has changed on the
original Logical Volume
or the Snapshot since the Snapshot was created.

LVM Snapshots Configuration

 Create Snapshot of existing Logical Volume


# lvcreate -L 10 -s -n databack /dev/vg0/data

 Mount Snapshot
# mkdir /mnt/databack
# mount /dev/vg0/databack /mnt/databack

 Remove Snapshot
# umount /mnt/databackup
# lvremove /dev/vg0/databackup

Back up and restore ext2/3 file systems.Does not work with other file systems.
#dump -0u - f /tmp/data /dev/vg0/databack
#umount /mnt/databack
#lvremove /dev/vg0/databack
#umount /lvm
#mkfs.ext3 /dev/vg0/data
#mount /dev/vg0/data /lvm
#cd /lvm
#restore -rf /dev/data

SESSION 16 & 17

 Imp Files In Linux -


/etc/inittab, /etc/fstab, /etc/mtab, /etc/grub.conf, /etc/passwd,
/etc/group, /etc/shadow, /etc/gshadow, /etc/securetty, /etc/resolv.conf, /etc/hosts,
/etc/hosts.allow, /etc/hosts.deny, /etc/sysconfig/network, /etc/pam.d/login
 Basic shell Scripting

INITTAB

 inittab : Location :- /etc/inittab


Line 1: id:5:initdefault:
 By using this file we can change the run level permanently
 In place of the 5 we placed 3 for running Runlevel 3 at booting time

Line 2: si::sysinit:/etc/rc.d/rc.sysini
 This file know about where is our system
initialize
Line 3: l0:0:wait:/etc/rc.d/rc 0
 Which script run on the booting time

Line 4: ca::ctrlaltdel:/sbin/shutdown -t3 -r now


#ca::ctrlaltdel:/sbin/shutdown -t3 -r now

 Most important we can disable “ctrl+alt+delete” command on server site or any


side so no one can restart that pc by using above command. For this we have to
commented following line

Line 5: 1:2345:respawn:/sbin/mingetty tty1

 We increase and decrease the terminals. After increment & decrement the GUI
mode automatically change on to higher or lower level of the function key.

Line 6: x:5:respawn:/etc/X11/prefdm –nodaemon

 Also change that in which run level graphics starts. For this we have to changes
made in the place of the 5.

GRUB.CONF

 Grub.conf :- Location :- /etc/grub.conf


 Original location :- /boot/grub/grub.conf
 This file contain the boot loader configuration

Line 1: default=0
 By this file we can change the default booting operating system

Line 2: timeout=5
 Change the time of waiting

Line 3: splashimage=(hd0,6)/grub/splash.xpm.gz
 Know the location of the splash image

Line 4: title Red Hat Enterprise Linux Server(2.6.18-8.el5)


title LINUX
 We customize the OS name

Line 5: root (hd0,8)


 If the boot partition separately mount then the /dev/hdc9 is /boot. Otherwise
/dev/hdc9 represents “/ ”.

Line 6: kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/1 rhgb quiet


 We know kernel name and root label

Line 7: initrd /initrd-2.6.18-8.el5.img


 Define initrd image.

Line 8: title Other


title Windows
 And also change the other OS name.

Line 8: title Other


Line 9: rootnoverify (hd0,0)
Line 10: chainloader +1
 And also change the other OS name, in line no 8 we write down the name which
we want in place of “Other”
 Line no 9 and Line no 10 help us to start other OS when our Linux boot loader is
corrupt.
 How we secure our Linux to unauthorized access in single user mode.
 We can secure our Linux by applying password
 Write down “password = ” after the splash image line. By this we can apply
password on the entry of single user mode.

timeout=5
splashimage=(hd0,6)/grub/splash.xpm.gz
Password =

 How we secure our Linux to unauthorized


access in also simple mode.
 We can secure our Linux by applying password
 Write down “password = ” after the title line.By this we can apply password on
the entry of simple user mode.
title Red Hat Enterprise Linux Server
password = Redhat

FSTAB

 Fstab: Location :- /etc/fstab


Backup File: /etc/mtab
 This file is used for HDD, CDROM and Network Services mounting.
 By the help of this file we can define partition no., destination location, file
system, features of the file system, enable dump command and set file system
checking order.

LABEL=/1 / ext3 Defaults 11

LABEL=/boot /boot ext3 Defaults 12


Devpts /dev/pts devpts gid=5,mode=620 0 0

tmpfs /dev/shm tmpfs defaults 00

proc /proc proc defaults 00

sysfs /sys sysfs defaults 00

1 2 3 4 5 6

Defines HDD, Define mounting Define file Features Dump freq.fsck


CDrom, and position system type of file
other network system
services info.

 In the 1st column we have to define HDD Partition no., CD-Rom, Floppy Drive
and other Network Service Information.
 We define as a following
/dev/hdc12
Or
LABLE =/ram
 In the 2nd column we have to define mounting position where we want that
partition or drive.
 We define as a following
/home
 In the 3rd column we have to define partition or drive file system.
 We define as a following
ext3
vfat
swap
 In the 4th column we have to define features of the file system.
 We define as a following
defaults -> assign defaults feature
ro -> for read only
rw -> for read and write
usrquota -> for user quota unable
acl -> for access control list

 In the 6th column we have to define file system checking order by this we define
that which file system check first.
 We define as a following
0 -> never check
1 -> check first on booting time
2 -> 2nd preference on checking
We define up to 7.

SESSION 18, 19 & 20

 Minor & Major Troubleshooting


 Rescue Mode Problems
 EXAM 1

Minor Troubleshooting

1. Login Through root user & redhat Password.


2. Set your mode as graphical mode.
3. Successfully ping server1.example.com
4. Successfully dig server1.my133t.org
5. Create a 100 MB partition of ext3 File System & mount permanent under
/mnt/new directory
6. Solve NFS Server problem. Successfully run showmount –e localhost
command for /data directory.
7. Resize LVM (Logical volume size) – max. up to 300MB (280/320) LVM
Mount under /home dir. Create a LVM Snapshot of 10MB.
8. Set Userquota Problem. User jane can Successfully run Following Command
dd if=/dev/zero of=/home/jane/somefile bs=1024 count=30

But can not run this command

dd if=/dev/zero of=/home/jane/somefile bs=1024 count=70

Minor Troubleshooting Solution

 For solving the question of minor troubleshooting we have to enter in single user
mode by the help of following lines.
 At the booting time press “e” on Linux boot loader line Come at second line or
on kernel line again press “e” Go last of the line press “spacebar” then press “s or
1” then enter, Press “b” for booting now system starts in single user mode
without username & password. We can change any file of the system.

1. Login Through root user & redhat Password.

In single user mode

 For solving this problem we have take 7 steps.


 Step1: Check attributes of “shadow” and “passwd” files. For checking the
attributes we have following command
#lsattr /etc/shadow
#lsattr /etc/passwd
See that “ia” is here in attributes.
 If we find “ia” attribute we have to remove that one by using following command.
#chattr -ia /etc/shadow
#chattr -ia /etc/passwd
 For add this attributes we just replace “ - ” with “ + ”.

Step 2: Change Root user password by using following command


#passwd

Step 3: Check Root User A/C expiration information. Check information by


following command.
#chage -l root
For changing the age of root user a/c we have to write following command
#chage root

Step 4: Check “/etc/securetty” file.


We find following entries in this file
Console
Vc/1 to Vc/11
Tty/1 to Tty/11
Check that the all entries is proper after this we have to check permission of the file it
should be 600.

Step 5: Open “/etc/pam.d/login” file and check the following line


auth [user_unknown=ignore success=ok ignore=ignore default=bad]
pam_securetty.so
We have to check both underline words.

Step 6: Check #vi /etc/passwd file if the file is missing then we have to copy
“/etc/passwd-” file and rename it as “/etc/passwd”.
All important files like shadow, group, gshadow etc. have the backup files

Step 7: We have to find “nologin” directory in the “/etc”. If we find this directory then we have
to delete this directory. If we didn’t delete “nologin” directory we can’t use Root user
for login.

2. Set your mode as graphical mode.


 For solving this problem we have to open following file.
#vi /etc/inittab

Now we change 3 into 5 in line no. 1.


After this run following command
#service xfs restart
#chkconfig xfs on

Also check #system-config-display

3. Successfully ping server1.example.com


4. Successfully dig server1.my133t.org
 Both question solve simultaneously, for solving, we have to run following
command
# netconfig
In this command we have to enter “Default Gateway IP” and “Namesever IP”
add. it may be 172.24.254.254.

 If the commands not working then we have to manually enter in the files. The
files are following
#vi /etc/resolve.conf

In this file we have to enter following information “nameserver 172.24.254.254”.

 Now we open following file


#vi /etc/sysconfig/network-scripts/ifcfg-eth0
In this file we enter
“GATEWAY= 172.24.254.254”

5. Create a 100 MB partition of ext3 File System & mount permanent under
/mnt/new directory.
 To create the partition we have to follow below steps
#fdisk /dev/hda
:n (new partition)
: (enter the stating cylinder no)
: +100M (enter size of partition)
:w (write & quit)
# partprobe or reboot
Format partition
#mkfs.ext3 /dev/hda10
#mkdir /mnt/new

#vi /etc/fstab enter new partition details


/dev/hda10 /mnt/new ext3 defaults 0 0
:wq (save & quite)
#mount -a

6. Solve NFS Server problem. Successfully run showmount –e localhost


command for /data directory.
 For this we have to open “#vi /etc/exports”
If we find space between IP & permission then just delete the space.
#service nfs restart
#service portmap restart
#chkconfig nfs on
#chkconfig portmap on
7. Resize LVM (Logical volume size) – max. up to 300MB (280/320) LVM
Mount under /home dir. Create a LVM Snapshot of 10MB.
 For this we have to write down following command.
#lvextend -L +50M /dev/vg0/data
#resize2fs /dev/vg0/data
For checking
#lvdisplay
#df -h
 Now we create snapshoot by using following command
# lvcreate -L +10M -s -n databack /dev/vg0/data
# mkdir /mnt/databack
# mount /dev/vg0/databack /mnt/databack

8. Set Userquota Problem. User jane can Successfully run Following Command
dd if=/dev/zero of=/home/jane/somefile bs=1024 count=30
But can not run this command
dd if=/dev/zero of=/home/jane/somefile bs=1024 count=70

 For solving the above problem we have to write following commands


#repquota -a (For check the quota status)

 Now we login through jane user and create a dir. And check the size of the dir.
 Now we check quota status again and find that how many block size increase.
Now we enter soft & hard limit for the jane user by following command
#edquota jane

 For example if the size of dir. Is 1kb and 2 block increase and used total used
block is 20 then we define following limit
Soft limit :- 80
Hard limit :- 85
 Means when we create 30kb file it takes 60 block and previous block is 20 then
total is 80.
 Now 30 kb file created but 70 kb file show writing operation file message which
we want.

Major Troubleshooting

1. Problems in /etc/fstab & /etc/grub.conf solve that.

 First we have to know what we define in the file and how we define.
LABEL=/1 / ext3 Defaults 11
LABEL=/boot /boot ext3 Defaults 12
 Now we have to know what is the common problem occur in this file, normally
they delete underline words which called labels.
 when we start our pc it shows “kernel panic error”.
 To solve this problem we used “rescue mode”.
 Follow the steps for solving this problem
 First insert 1 CD of RHEL 5.0 after that write “Linux rescue askmethod”.
 Now system start into rescue mode, in rescue mode “/” mounted under
/mnt/sysimage.
 Now we change the original position of the root with the following command.
#chroot /mnt/sysimage
 If this command successfully run then we can solve all problem by checking
fstab & grub.conf.
 If this command doesn't execute we follow these step
Step 1: fdisk -l (show partition info.)
Step 2: e2lable /dev/hdc9 (check label of part.)
Step 3: e2label /dev/hdc9 /boot1
(by using command we can change the label)
Step 4: mkdir /mnt/redhat
Step 5: mount /dev/hdc10 /mnt/redhat
Step 6: open fstab file
#vi /mnt/redhat/etc/fstab
Check the label and correct it after that save it.
Step 7: mount /dev/hdc9 /mnt/redhat/boot
 Now we mount boot in new location to solve the grub.conf
#vi /mnt/redhat/boot/grub/grub.conf
Now open the file and edit it.
SESSION 21
 RHCE Lab Setup
 Telnet Server & Telnet Client
 Security of Telnet Server (Th :-Xinetd)
 SSH Server (Secure Shell) & SSH Client, SCP, Slogin
RHCE Lab Setup
Switch

IP 172.24.254.254
SM 255.255.0.0
Server1.example.com

IP 172.24.0.1
station1.example.com

IP 172.24.0.2 IP 172.24.0.3
station2.example.com station3.example.com

TELNET
 Telnet is used for remote login but only in text mode.
 Telnet based on TCP protocol & has port no 23.
 Telnet is possible between Linux to Linux, Linux to Windows & windows to
windows.
 In Linux, Xinetd daemon should be running properly.
 Telnet provides user authentication process, client always use server user for the
authentication.

Working of Telnet
Switch
Forwarding
Request
IP 172.24.0.10
Request for All user define here.
accessing Xinetd running properly.

Authentication
#telnet 172.24.0.10
Login :
Password :

Configuration of Telnet
 Step 1: search Telnet package
rpm -qa telnet*
 Result: 2 packages should be there.
 Step 2: open file #vi /etc/xinetd.d/telnet
in file change “disable = no”
 Step 3: #service xinetd restart
 Step 4: #chkconfig xinetd on (for run level 2, 3, 5)
Telnet Client side configuration :
Just search package of the Telnet on client side. If your system have the packages then
write down following
#telnet IP address of the server machine
Login : user name of the server side
Password : user password

Advanced Telnet Server Configuration


 For advanced conf. we have to open following file #vi /etc/xinetd.d/telnet
 In this file we have to enter following lines with in the brackets
only_from = 172.24.0.0/255.255.0.0
no_access = 172.24.0.10 172.24.0.20
per_source = 4
access_times = 08:00-10:00
Details of the entered lines :
only-from : Member of define Network Address can access telnet server.
no-access : The define IP address m/c can’t access telnet server.
per-source : Maximum connection allowed from a client m/c.
Access-time :Time limitation for client m/c.
# service xinetd restart
Access thro. Telnet Server
 How to allow root user to be used by telnet client m/c.
Step 1 : Open file “#vi /etc/securetty”
Step 2 : Now enter in last of the file “pts/0” “pts/1”.
Now we can use root user in telnet.

SSH Server
 SSH are stands for secure shell server.
 SSH is used for remote login but supports only Linux to Linux.
 SSH is based on TCP protocol and use port no. 22.
SSH Server Configuration
 Configuration :
 Step 1: Search for package
#rpm -qa openss*
result: 2 packages
 Step 2: restart the service
#service sshd restart
#chkconfig sshd on
SSH Client Side
 Client side :
#ssh IP of the server
#ssh y5@172.24.0.3
Slogin Server/ Client
 Slogin also use for remote login like SSH.
 For accessing it we have to write following
#slogin 172.24.0.3
# slogin y2@172.24.0.1
 SCP stands for secure copy server.
 SCP is used to copy files & directory form one m/c to another m/c securely.

SCP for Files :


#scp f11 172.24.0.4:/boot
SCP for Directories :
#scp -r hh 172.24.0.5:/data
SESSION 22
 DHCP Server & DHCP Client
(Dynamic Host Configuration Protocol)
 NFS Server & NFS Client
(Network File System)

Intro. of DHCP Server


 DHCP is stand for Dynamic Host Configuration Protocol.
 DHCP is used to assign static & dynamic IP address to client machine.
 By using “netconfig” command we manually assign IP address to all system’s.
 DHCP based on broadcasting technology.
 In a Local Network we can select maximum 1 DHCP Server.
 At server side DHCPD demon should be running properly.
 Both DHCP client and Server performs Broadcasting operation.
 DHCP server has two type of database
static database
dynamic database
DHCP Server Working

Switch

DHCP Server, Dhcpd running


Static: ip combine with mac address
Dynamic: range 1-20

#netconfig
Select DHCP or #dhclient
#service network restart
DHCP Server Configuration
 Step 1: Search package
#rpm -qa dhcp*
result: 3 package
 Step 2: Go to the specific location
#cd /usr/share/doc/dhcp-3.0.5
#cp dhcpd.conf sample /etc/dhcpd.conf
 Step 3: open following file
#vi/etc/dhcpd.conf
 Change in this file
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 192.168.1.1;
option time-offset -18000;
#option ntp-servers 192.168.1.1;
#option netbios-name-servers 192.168.1.1;
# option netbios-node-type 2;
range dynamic-bootp 192.168.0.128 192.168.0.254;
default-lease-time 21600;
max-lease-time 43200;
# we want the nameserver to appear at a fixed address
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
}
 For Dynamic IP we have to change following lines
subnet 172.24.0.0 netmask 255.255.0.0
option domain-name “example.com";
range dynamic-bootp 172.24.0.30 172.24.0.50
 After saving the file we have to write down
#service dhcpd restart
 For static IP assign. We have to change the following lines
host ns {
next-server marvin.redhat.com;
hardware ethernet 12:34:56:78:AB:CD;
fixed-address 207.175.42.254;
}
 First we have to change ns into system name.
 Second we change next-server into stationx.example.com

 Third we change hardware Ethernet.


 For check the machine add. we have to write “ifconfig” and write down the mac.
add. of the LAN card.
 Forth now we assign a unique IP to the system. This IP is different to our range.
DHCP Client
 Client Side Configuration :-
#netconfig
select DHCP
#service network restart
or
#system-config-network
select DHCP
#service network restart
or
#dhclient
Intro of NFS Server
 NFS stands for Network File Service.
 NFS is used for directory sharing between Linux to Linux, Linux to Unix and
Unix to Linux.
 NFS based on UDP Protocol & uses port no. 2049.
 NFS is a Remote Processor Call (RPC) based service.
 At Server side following demons should be running properly
nfsd, portmap, rpc.rquotad, rpc.mountd
 Nfsd: Manage NFS Server.
 Portmap: Manage port no. of all services.
 Rpc.rqoutad: Manage quota of NFS Server shared directory.
 Rpc.mountd: Manage mounting & un-mounting of NFS Server shared directory.
 At client side we used mount command to access server shared directory.
 NFS provides no authentication processor.
 Shared directories are listed in /etc/exports
Working NFS Server

Switch
without
authenticatio NFS Server
n permission Nfs: nfsd, rpc.rmount,
rpc.rqoutad
Portmap: portmap

mount
process

NFS Server Configuration


 Step 1: Search NFS Package
#rpm -qa nfs*
result: 2 packages
 Step 2: open file “#vi /etc/exports” add in this file.
Ex: shared dir. Client IP/ N/A Permission
/data 172.24.0.0/255.255.0.0(rw,sync)
/data *.example.com(rw,sync)
NFS Server
Save the file, after that make the “data” directory.
#mkdir /data
#service nfs restart
#service portmap restart
#exportfs -a (refresh the exports file)
#exportfs (show the shared dir.)
#chkconfig nfs on
# chkconfig portmap on
NFS access on Client side
#showmount -e 172.24.0.7
(by the help of this command we can see the shared dir. On the given IP add. M/C)
NFS Client:
 Temporary Mounting
#mount 172.24.0.7:/data /p1
 Permanent Mount
#vi /etc/fstab
172.24.0.7:/data /p1 nfs defaults 0 0
Q: Run #showmount -e localhost
Ans:
 For this we have to check “/etc/exports” file.
 In this file if we find space between IP & the Permission then just remove the
space.
After save the file
#service nfs restart
#service portmap restart
SESSION 24
 Samba Server & Samba Client
 Samba Server Configuration in Windows
 Share File & Directory B/W Windows & Linux
Samba Server
 Samba Server is used for directory shearing between Linux to Linux, Windows to
Linux, Windows to Linux.
 Samba Server provides authentication.
 Samba Server uses SMB Protocol.(Server Message Blocks)
 In case of Linux Samba Server and Linux client M/C then a Client M/C can
access only Server share directories.
 But in case of Linux Server & Windows client, then a client m/c can access server
shared directory user home directory, Printer & Fax m/c of server.
 At Linux samba Server side following demons should be running properly.
smbd :- Linux to Linux
nmbd :- Linux to Windows
 At client side (Linux M/C) we uses following command to access Samba Server
shared Directories.
#smbclient
#mount
Samba Server Working
Switch

SAMBA Server, smbd, nmbd running


properly, 172.24.0.10, /data,
all user’s define here

Linux Windows Unix


Client Client Client

]
Samba Server Configuration
Step 1: Search package
#rpm -qa samba
result: 3 packages
Step 2: open file “#vi /etc/samba/smb.conf” in this file we find 4 type of section.
1. Global
2. Home
3. Printer
4. Myshared
 In “Global” section we have to change following contents
Workgroup = Name of the group
Hostallow = 172.24.
 We don’t want to made change’s in “Home” ”Printer” directory.
 Now we copy last example of “Myshared” section and paste it in the last of the
file.
 In “Myshare” section we have to change following contains.
 First we change “samba share name” we define this within a [] brackets. Source
dir. info. No. one can archive from client side.
 After that we change the “path” actual dir. Add. Which we want to share with
others.
 We have to define ”valid user” by the help of these users we can access the
samba server from client side.
 We have to change the “writeable” permission by this client write in that
directory.
 After that we change the “createmask” value by this we can assign default umask
value for creation by client.
 After that we change “browseable” option we assign that client access shared dir.
Through IE or not.
 At last we change “write_list” option by this we can assign that which group or
group members access that directories.
 After that we save the file. We have to know that actual dir. Should be on
destination add.
 After that create new user & also assign password.
#useradd k1
# passwd k1
 Restart service now
#service smb restart
#chkconfig smb on
 Now we convert simple user into samba user.
#smbpasswd -a k1
Now enter password.
 For check the Samba Server we have following Checking tools:
#testparm
#smbclient -L Samba Server IP
Samba Client
 Samba Client (Linux M/C):
 For checking share dir we have to write
#smbclient -L Samba Server IP
 For accessing the share dir. We have to write
#smbclient //172.24.0.9/redhat -U k1
#mount -t cifs //172.24.0.9/redhat /mnt/ -0 username=k1
 Samba Client (Windows M/C):
 In windows client m/c click on my network place now right click and click on
search computer.
 Enter the samba server IP add. After that enter username and password.
Samba Server / Client
 Window Samba Server & Linux Client
 Share dir. On windows so its automatically become Samba Server
#smbclient -L 192.24.0.20
#smbclient //172.24.0.20/c -U administrator
#mount -t cifs //172.24.0.20/c /mnt/ -0 username = administrator
#password = redhat

SESSION 25
 NIS Server & NIS Client
(Network Information Service)
 NTP Server & Client
(Network Time Protocol)
Intro of NIS Server
 NIS stands for Network Information Server.
 NIS is a centralize user authentication server & centralize user database server.
 NIS client login at local M/C but uses server user’s.
 NIS is possible between Linux to Linux, Linux to Unix and Unix to Linux.
 NIS known as “YP” but “YP” is the tread mark of the yellow pages that’s why it
name change in to NIS.
 At server side following demons should be running properly.
ypserv: start and manage NIS & NFS.
yppasswd: NIS user password info. manager
 All demons of the NFS Server.
 At client side following demons should be running properly.
ypbind: used to attach with NIS & NFS server
autofs: used to auto mount user home dir.
 In NIS we define a NIS domain name, only members of NIS domain name can
access server user’s.
 Type of NIS server
Master NIS Server
Slave NIS Server
 Master NIS server has main database of user.
 Slave NIS server has a backup database of Master Server and has a connection
with Master Server.

NIS Server Working

Switch
NIS Server, ypserv, yppasswdd,
nfsd, rpc.rmountd, rpc.rquotad,
portmap running properly,
172.24.0.10, NISdomain= CCNA
all user’s define here

#setup
[ ] NIS
Nisdomain= CCNA
IP = 172.24.0.10
autofs
NIS Server Configuration
 Step 1: Search package
#rpm -qa yp*
result: 3 packages
 Step 2: How to set NIS domain name.
 Tamp. Setting:
#nisdomainname (for searching)
#nisdomainname CCNA
 Permanent setting: open following file
#vi /etc/sysconfig/network
In file NISDOMAIN = CCNA
 Now we cerate new user
#useradd h1
#passwd h1
 Now we bind user database with NIS domain name.
#cd /var/yp
#vi Makefile
(:set nu: for set number before line)
Change in line no. 109
all : Passwd group
 Note: Erase all info. Rather then three words.
 After saving the file we write
#make
 Now we set current M/C NIS Master Server.
#cd /usr/lib/yp
# ./ypinit -m
After that press “Ctrl+D” then “Y”
#service ypserv restart
#service yppasswdd restart
 Now we share /home dir. By NFS server.
#vi /etc/exports
In this file we have to write following
/home 172.24.0.0/255.255.0.0(rw,sync)
#service nfs restart
# service portmap restart
NIS Client
 On the Client side we have to write down following command.
#setup
Authentication
Use NIS next
Domain Name
172.24.0.10 ok
 Now our M/C become NIS Client & member of NIS domain name, but at client
side a user can’t access it’s home dir. To access home dir we use Autofs Service.
Autofs configuration : Open file
#vi /etc/auto.master
in file add a line
/home /etc/auto.misc
(this file define server details)
After that open other file #vi /etc/auto.misc
Add a line
G1 -fstype = nfs 172.24.0.8:/home/*
 After saving the file we have to write down following line.
#service autofs restart
 How to check available user on server?
 By using following command we know available user name.
#ypcat passwd
#getent passwd
NTP Server
 Network Time Protocol :
 Workstation hardware clocks tend to drift over time without correction
 Many application require accurate timing
 Time synchronization makes system logs easier to analyze
 NTP counters the drift by manipulating the length of a second
 If the system's time is behind the average of the time servers the second is made
shorter so that the system clock races towards the correct time. Thus the time
difference is reduced gently without disturbing other applications.
 However if the time differs to greatly, NTP ceases to work. In this case the clock
must be reset manually with ntpdate.
NTP Server Configuration

 For NTP Server we have to login through GUI Mode.


 Now we enter following command on the terminal
#service-config-date
 Now select “Enable network time protocol” clock add is the Server IP add.
#ntpdate -u 172.24.0.10
#service ntpd restart
SESSION 26
 Web Server & Web Client, Secure Web Server
 Web Site Accessing in TUI & GUI
Intro of Web Server
 What is Webpage?
 Webpage is a collection of the text, images, objects, audio, video, hyperlinks etc.
 What is Web site?
 Collections of the web pages with some database is called web site.
 What is Web server?
 Web server is a M/C that is used to host a website, manage a web site & manage
database of that web site.
 Web server uses HTTP protocol & port no 80.
 We can host multiple websites on a single web server that is known as virtual
web hosting.
 Each web site has a home page for example index.html, index.asp etc.
 For Web Server DNS Server or local database server should be running properly.
 At client site we use web browser to access a site like windows :- IE,
Linux :- links.
 Web browser convert programming language into human readable format.
Multiple case’s for virtual web hosting :
 Case 1: In this case we host one site on Web Server and assign IP address with
hostname.
Ex: 172.24.0.10 yahoo.example.com
 Case 2: In this case we host multiple site on Web Server and assign different IP
address to all site with the help of aliases.
Ex: eth0 172.24.0.1 site 1
eth0:0 172.24.0.5 site 2
eth0:1 172.24.0.7 site 3
eth0:2 172.24.0.8 site 4
eth0:3 172.24.0.9 site 5 etc.
 Aliases: Aliases is a process where we virtually convert one LAN card into
multiple LAN cards. By this we can assign different IP’s to multiple
site’s and host multiple site on a Web Server.
Web Server Configuration
 Step 1: Search package
#rpm -qa http*
result: 2 packages
 Case 1:
 Step 2: open following file
#vi /etc/httpd/conf/httpd.conf
:set nu -> set number before line
Edit line no. 971 “Name Virtual Host” after this we have to write our system
IP address or DNS IP address.
 After that we have to copy last 7 lines.
#<VirtualHost *:80>
# ServerAdmin webmaster@host.example.com
# DocumentRoot /www/docs/host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/host.example.com-error_log
# CustomLog logs/com-access_log common
#</VirtualHost
 Now paste it in the last of the file, now made following changes in pasted lines.
#<VirtualHost *:80>
<VirtualHost yahoo.example.com>
 Note : remove comment and enter your site name like above example
# DocumentRoot /www/docs/host.example.com
DocumentRoot /var/www/html
 Note : remove comment and enter your site destination add., always made your
site in the “/var/www” directories.
# ServerName dummy-host.example.com
ServerName station10.example.com
 Note : remove comment and enter your system hostname in which web site
hosted.
#</VirtualHost>
</VirtualHost>
 Note : remove comment and complete the web server configuration.
 Now we go to the destination of the site which given in the file and made
following file
#cd /var/www/html
#vi index.html (:wq in this file)
Now open
#vi /etc/hosts (for local database server)
write down following lines in above file
172.24.0.10 yahoo.example.com station10
“172.24.0.10 yahoo.example.com station10”
 Means of line that the 172.24.0.10 is a site IP address and site address is
yahoo.example.com and station10 is for system where site hosted. This we do for
local database management by doing this we can access above site in a network.
After that
#service httpd restart
 For accessing the site we have to write down
#links yahoo.example.com
 Case 2: open following file
#vi /etc/httpd/conf/httpd.conf
Apply comment on “Name Virtual Host” by using #.
Made 2 more website and apply different IP’s in the place of the site name. like
<VirtualHost yahoo.example.com>
<VirtualHost 172.24.0.7>
Also change the destination add, server name remain same.
 How we create aliases?
For creating aliases we have to write down following command
#netconfig -d eth0:0
After that apply new IP add. on the duplicate LAN card by using
#netconfig command.
Now open #vi /etc/hosts and change the IP of the sites. After that
#service httpd restart

SESSION 27 & 28
 Squid Proxy Server
 Allow & Deny Web Sites
 VSFTP Server (Very Secure File Transfer Protocol)
 Uploading & Downloading Through System or Non System User & Anonymous
User
Intro of Proxy Server
 Proxy Server is used for internet connection sharing & provides security.
 By Proxy Server we can limit bandwidth for client M/C. allow and deny websites
& can allow & deny nodes to access Proxy Server.
 In Linux “squid” software is used as Proxy Server.
 Proxy Server uses TCP protocol & Port no. 3128.
 At client side we define IP address & port no. of a proxy server in a web browser.
Windows -> IE , Linux -> Links, Mozila
 Proxy Server also known as NAT. (Network Address Translator)
 By using Proxy Server Private IP add. Translate into Public IP add. And Public
IP add. to Private IP add. this process call NAT.
Proxy Server Working
Public IP (Real IP) Internet conn.

Req. Forward
Switch

PROXY Server, squid running


properly, port no 3128

yahoo Rediff
hotmail

Private
IP

Proxy Server Configuration


Step 1: Search package
#rpm -qa squid*
result: 1 package
Step 2: Open following file
#vi /etc/squid/squid.conf
:set nu -> set no. before line
 How to set Proxy Port No
Edit line no. 73 http_port 3128
 How to set Cache Memory?
Edit line no 738 Cache_mem 50MB
 How to allow a domain to access Proxy Server?
Copy line no 2396 and paste it after that line and edit pasted line
acl localhost src 127.0.0.1/255.255.255. 255
acl p1 src 172.24.0.0/255.255.0.0
Note: here p1 is a group name which have allow Network add.
 After that Copy line no 2524 and paste it after that line and edit pasted line
http_access allow manager localhost
http_access allow p1
Note: Here we allow p1 Network add. to access the internet connection.
 How to deny Website for Proxy Client?
Copy line no 2398 and paste it after that line and edit pasted line
acl to_localhost dst 127.0.0.0/8
acl p2 dstdomin .hotmail.com .yahoo.com
 Note: Here p2 is group of deny domain name
 After that Copy line no 2524 and paste it after that line and edit pasted line
http_access deny manager
http_access deny p2
 Note: we have to write this line before the allow line
 Now restart the service
#service squid restart
 Squid testing tool:
#squid -z
Intro of FTP Server
 FTP is stands for File Transfer Protocol.
 FTP is used for file downloading & uploading files and directories.
 In Linux we VSFTP software as a FTP Server.(Very Secure File Transfer
Protocol)
 FTP use TCP Protocol & Port no. 20 & 21.
 FTP connection possible between Linux to Linux, Linux to Windows and
Windows to Linux.
FTP Client M/C can uses following type users
1. System or Non system user:
by using above type user’s user name & password then client access complete
system.
2. Anonymous user:
by using anonymous username and any password the client access only /var/ftp
directory contains.
 FTP client uses “get” command for downloading and uses “put” command for
uploading.
 At client side we uses following command
#ftp IP of Server
Login:-
Pass:-
ftp >
 At server site “vsftpd” demon should be running properly.
 FTP client always uses FTP Server user’s & cerate a communication channel
between client & server.
FTP Server Working

Switch

FTP Server, vsftpd running properly,


172.24.0.10, all user’s define here

#ftp IP of Server
Linux Login:- Windows
Client Pass:- Client
ftp >

FTP Server Configuration


Step 1: search package
#rpm -qa vsftp*
result: 1 package
Step 2: open following file
#vi /etc/vsftpd/vsftpd.conf
:set nu -> no. before lines
Comment out all following lines and edit as we want
12 anonymous_enable=YES
15 local_enable=YES
18 write_enable=YES
22 local_umask=022
27 anon_upload_enable=YES
31 anon_mkdir_write_enable=YES
46 chown_uploads=YES
47 chown_username=daemon
48 anon_umask=022
Note : we have to change in line no 47 add “daemon” remove other entry and
we have to add line no. 48.
 Make files and dir. in /var/ftp for uploading and downloading.
#service vsftpd restart
#adduser g1
#passwd g1
 FTP Client :
#ftp 172.24.0.10
 In graphical
ftp://172.24.0.10
ftp://g1@172.24.0.10
FTP Client
 Downloading of a file:
First come to destination dir. Where you want to download that file
#ftp 172.24.0.10
Login:
Password :
ftp > cd /
ftp > get file name
ftp > quit
Uploading a file:-
Simple User: simple user can upload only in it’s home dir. Go to the source add. then
#ftp 172.24.0.10
ftp > put f4
ftp > quit
 Anonymous : only upload in /var/ftp/* dir.
FTP Authentication
 How to deny a simple user to access by FTP Client M/C?
 Open file
#vi /etc/vsftpd/ftpusers
Insert name of the user in this file after that
#service vsftpd restart
 How to allow root user to be access by FTP Client?
 Open file
#vi /etc/vsftpd/ftpusers
remove root user entry after that open another file
#vi /etc/vsftpd/user_list
remove root user entry from this file too after that
#service vsftpd restart
SESSION 29 & 30
 Sendmail Server
 IMAP-POP3 Server :- Mutt
 IMAP-SSL
Intro of Mail Server
 Mail Server is used to store mails.
 All user fetch mails from Mail Server for fetching mails from the Mail Server we
use IMAP/POP3 Server. (Internet Message Access Protocol/Post Office Protocol
3)
 IMAP use port no 143 and POP3 use 110 port no.
 Mail Server has all user mails with Inbox, Sent Items & Outbox.
 In Linux we use “dovecot” software as IMAP/POP3 Server and “send mail”
software used as Mail Server.
 Send Mail uses TCP protocol & port no. 25.
 Send Mail also known as MTA.(Mail Transport Agent)
 MUA (Mail User Agent) MUA is used to create new mails, edit, forward,
check mail etc.
Windows : MS Outlook
Linux : Mutt, Mozila Mail
Mail Server Working
 For Mail Server DNS Server should be running properly.
Mail Server +
NIS Server
Mail Server +
NIS Server SMTP

TP
SM
MTA Do
Inbox ve
co
Outbox tS
/W
Inbox Sent Mail
Outbox
MUA Sent Mail

MUA

IMAP/POP3 Configuration
 Step 1: Search package
#rpm -qa dovecot*
result: 1 package
 Step 2: Open file
#vi /etc/dovecot.conf
 We have to remove 17 no line comment after that
#service dovecot restart
#chkconfig dovecot on
 How to check IMAP/POP3 server.
#telnet 172.24.0.1 143/110
Mail Server Configuration
 Step 1: Search package
#rpm -qa sendmail*
result: 4 package
 Step 2: Open file
#vi /etc/mail/sendmail.mc
 We have to comment line no. 116 with the help of “dnl #”
 Now we put all changes into “sendmail.cf” file by using “macro”
#m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
 After that
#service sendmail restart
 Add a new user
#adduser k1
#passwd k1
 For sending mail we have to write following file
#mutt
Mail Server Authentication
 How to deny a node or a domain to send a mail on Mail Server.
 Open a file #vi /etc/mail/access
172.24.0.2 REJECT
*.example.com RELAY
172.25 REJECT
Connect:10.3 OK
y1@my133t.org REJECT
Mail Forwarding
 Mail Forwarding: For Example we want to forward all mails of t1 user to t2 user.
For this we have to open
#vi /etc/aliases
Go to bottom of the file and add one line
t1: t1, t2
 After saving the file write down a command
#newaliases
IMAP-SSL Server
 IMAP-SSL is stands for Internet Message Access Protocol-Secure Socket Layer.
 By using IMAP-SSL a user can access any other user account securely.
 For IMAP-SSL we have to create a certificate.
IMAP-SSL Configuration
 Go to the following destination add.
#cd /etc/pki/tls/certs
#openssl x509 -subject -noout < dovecot.pem
#rm dovecot.pem
#make dovecot.pem
 Define entries according to question.
#vi /etc/dovecot.conf
IMAP-SSL Client
 Now made changes in line no. 87 & 88 enter destination add of the certificate and
save the file. After that
#service dovecot restart
 On Client Side:
#mutt -f {t1@station1.example.com}
 By above command login user can access t1 user mail account.

SESSION 31
 Printer Server & Printer Client
 Syslog Server
 VNC Server
Intro of Printer Server
 Printer is a combination of print devices & it’s driver software.
Two type of printer we have.
1. Shared Printer
2. Network Printer
 Shared Printer: A printer directly attach with a pc & shared through out network
by that pc is called Shared Printer.
 Network Printer : This type of printer directly connected with HUB & Switch
each have a unique IP Add. & Port no.

Working of Printer Server:-


Switch

Printer Server

Linux Windows Unix


Client Client Client

Shared Printer: In GUI mode write down following command on terminal.


#system-config-printer
Printer Server Configuration
 Click on “New Printer”->Printer Name (any)-> Forward->select “LPT #1”-
>Forward->select “Makes” of the printer->Forward->select Model &
Recommended Driver->Forward->Apply
#service cups restart
#chkconfig cups on

Printer Client
 Checking Tools:
#lpq-> show default printer status
 Printing Command:
#lpr kk-> print file name
 Remove Job:
#lprm 5-> remove id no. job
Printer Client:
 Case 1: If Printer Server Linux & Clients are also Linux
#system-config-printer
Printer Server Configuration
 Click on “New Printer”->Printer Name (any)->Forward->select “LPD/LPR Host
or Printer” ->enter Hostname/IP->enter Printer name (Pre.) -> Forward->select
“Makes” of the printer ->Forward->select Model & Recommended Driver
->Forward->Apply
#service cups restart
#chkconfig cups on
 Case 2: Linux Printer Server & Client Windows
We share Printer by using Samba Server.
 Case 3: when Server is Windows & Client are Linux
#system-config-printer
Shared Server
 Click on “New Printer”->Printer Name (any) ->Forward->select “Windows
Printer via SAMBA”->enter IP of Server/printer name ->Forward->select
“Makes” of the printer -> Forward->select Model & Recommended Driver-
>Forward->Apply
#service cups restart
#chkconfig cups on
Network Printer
#system-config-printer
Click on “New Printer”->Printer Name (any)->Forward->select “AppSoceket/HP jet
Direct” ->enter IP of Server/printer name->Forward->select “Makes” of the printer->
Forward->select Model & Recommended Driver->Forward->Apply
#service cups restart
#chkconfig cups on
Printer Client Configuration according to exam
#system-config-printer
Click on “New Printer”->Printer Name (any)->Forward->select “IPP”->enter printer
name-> Forward->select “Generic” of the printer-> Forward->select Model &
Recommended Driver->Forward->Apply
Checking Printer Server
 Click on Print Test Page after it Open web browser in add. Bar
http://server3.example.com/Printers
Result
Station3 14k bytes received
#service cups restart
#chkconfig cups on
Log Server
 Log files is used to store user authentication information, service related
information, booting related information etc.
 Log file define in “/var” directory.
 Main Log file of the Linux is “/var/log/message”
#tail -f /var/log/message
#vi /var/log/secure
 In above file we know the login time of the user.
 All log file details define in “vi/etc/syslog.conf” file
VNC Server
 VNC stands for Virtual Name Computing.
 By using VNC we can access remote desktop.
 How to allow VNC settings.
System->Preference->Remote Desktop
Now check mark on allow other user then ok.
 How to access Remote Access M/C.
#vncviewer IP of the Remote Access M/C

SESSION 32
 Tcp_Wrappers - /etc/hosts.allow, /etc/hosts.deny
 PAM – Pluggable Authentication Module
 Ipv6 Configuration, RADVD Server

TCP Wrappers Authentication

 TCP Wrappers provides service based security.


 TCP Wrapper control by two files
#vi /etc/host.allow
#vi /etc/host.deny
 Deny only pc1 to access Telnet Server.
#vi /etc/host.deny
Service : 172.24.0.1
in.telnetd : 172.24.0.1

 By the help of this file we can manage following services


in.telnetd, vsftpd, sshd and nfsd.

 Allow only pc one to access Telnet Server.


in.telnetd : ALL EXCEPT 172.24.0.1

 Deny all nodes to access SSH Server


sshd : ALL
 Deny all members of my133t.org domain but allow example.com to access FTP
Server.
vsftpd : ALL EXCEPT 172.24.0.0/16
Or
vsftpd : .my133t.org EXCEPT .example.com

 Note: In TCP Wrappers we have to use one file at a time, we can’t use both files
simultaneously.
PAM
 PAM stands for Pluggable Authentication Module.
 PAM provides user based security.
 Deny all simple user to access a system.

For this just write down following command


#touch /etc/nologin

 Deny root user to access a system.


For this #mkdir /etc/nologin
 Allow Jane user to access your SSH server
Create a file #vi /etc/ssh_access

 In this file enter user name which want to allow


Open file #vi /etc/pam.d/vsftpd
Copy 3rd line of the file And inset this in the following file
#vi /etc/pam.d/sshd
now change in pasted line First change the sense=allow/deny and change file
destination add. Add previously file created address.

IPV6
 IPV6 use 128 bits for addressing.
 IP format is following
0000:F8b:0011:06AB:BA00:A80:BCAD:0001
 In Linux IPV6 defines by using prefix and MAC add. of LAN Card.
 Linux Client fetches prefix from Router Advanced Demon Server

RADVD Server Configuration

 Step 1: Search Package


#rpm -qa radv*
result: 1 package
 Step 2: Open file #vi /etc/radvd.conf
we have to uncomment all the lines in this file
#service radvd restart
we have to open following file
#cd /proc/sys/net/ipv6/conf/all
#vi forwarding
For changing 0(zero) into 1 we have to write following command
#echo “1” > forwarding
Client Side:
first we have to open following file
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
In file we have to add following
IPV6INIT=Yes
IPV6-AOTOCONF=yes
#service network restart
 For check the IPV6 we have following tools
#ip -6 addr show
#ping6 IP no. of the M/C
#ifconfig IP no. of the M/C
#ipconfig -a

Session 33
 IP Forwarding - /etc/sysctl.conf
 Firewall – Iptables
 Basic About SELINUX
(Security Enhanced Linux)

IP Forwarding

 How to enable IP Forwarding Permanently.


Open following file
#vi /etc/sysctl.conf
In line no 6 we have to change 0 into 1. By this we can enable IP Forwarding.
After this we have to write
#service network restart
# chkconfig network on
Firewall

 Firewall is a single security point of the network that filters un wanted packets.
 By using Firewall we can stop un-authorizes package but can’t stop virus attack.
 In Linux we use Iptables software as a firewall.
 Iptables is a command line firewall.
 Iptables uses Network Layer.

Firewall Working

 Packet header information always check with the topmost rule of a Firewall.
 If packet information header match with topmost rule then define operation
perform on that packets and further no matching take place.
 If the packet header information don’t match with top most rule then packet skip
first rule & match with next rule, until a match is made.
 If packet header info don’t match with any given rule then Linux firewall by
default allow the packet.

IPTABLES:

 Iptables is command line firewall also known as packet filtering firewall.


 Iptables use’s Network Layer

In Iptables we have to know some following characters.


-I :- Insert a rule
-A :- Append a rule
-L :- List all rules
-D :- Delete a rule
-F :- Flash a rule
Chains :- INPUT
OUTPUT
FORWARD
-s :- Source IP Address
-d :- Destination IP Address
-p :- Protocol
--sport :- Source port no.
--dport :- Destination port no.
-j :- REJECT/ACCEPT/DROP

 Allow only members of example.com to access IMAP & POP3 Server and deny
member of my133t.org domain.
 We have to write following for this type of limitation
#iptable -I INPUT -s ! 172.24.0.0/16 -d 172.24.0.10 -p tcp --dport 143 -j REJECT
#service iptable save
# chkconfig iptable on
 Deny pc1 to Ping Telnet Server.
For this we have to write following
#iptable -I INPUT -s 172.24.0.1 -d 172.24.0.10 -p icmp -j REJECT/DROP
 Deny pc1 to access Telnet Server.
#iptable -I INPUT -s 172.24.0.1 -d 172.24.0.10 -p tcp --dport 23 -REJECT/DROP

 How to restore rules.


#iptable-restore < /etc/sysconfig/iptables

SELINUX

 SELINUX stands for Security Enhanced Linux.


 SELINUX has set of rules called policies that determine how strike the control.
 SELINUX define either restricted control or un-confined control.
 SELINUX define three level of control Enforcing, Permissive and Disable.
#system-config-securitylevel
 SELINUX define following levels
user : role : type : sensitivity : category
#ls -z -> to check Security levels

#getenforce -> to check SELINUX unable/disable


#setenforce 1 -> for set Enable
#system-config-securitylevels -> in GUI mode

 How to change the context of a directory?


#chcon -t var_t zzz
#restorecon zzz

Note: for running the Iptables properly we have to write down following command
after saving the Iptables
#restorecon -R /etc/sysconfig

 Boolean Value : we have to change Boolean Value when SELINUX is in


Enforcing mode And we want to run specific services.
#getsebool -a | grep smbd
#setseboot service name on/off

 When SELINUX is in enforcing mode we have to set following services


Samba Home Dir., Anon Ftp Upload, NIS client

S-ar putea să vă placă și