Linux Architecture
What is an Kernal ?
A set of functions that make up the heart of an OS.
• It is used to provide an application interface between
programs and physical devices.
• Services provided by the kernel
- Controls execution of processes.
- Scheduling processes fairly for execution
on the CPU.
• Allocating memory for an executing process.
What is Shell
Shell is the interface between the user and the kernel.
Services provided by the shell It interprets all the
commands to the kernel The kernel after processing the
commands gives back to the shell.
Shell Name Developed by Where Remark
BASH Brian Fox and Free Software Most common shell in
( Bourne- Chet Ramey Foundation Linux. It's Freeware
Again SHell ) shell.
CSH Bill Joy University of The C shell's syntax
(C SHell) California (For and usage are very
BSD) similar to
the C programming
language.
KSH David Korn AT & T Bell --
(Korn SHell) Labs
See the man -- TCSH is an enhanced
TCSH page. but completely
Type $ man compatible version of
tcsh the Berkeley UNIX C
shell (CSH).
Linux Architecture works
Linux Architecture works
History of Unix
MULTICS PROJECT
It was started in 1965 on Main frame GE 645 by the joint
effort of :
❖ AT & T Bell Labs
❖ General Electricals
❖ Massachusetts Institute of Technology (MIT)
Multics was written in Assembly Language.
In 1969 Multics project was dropped.
History of Unix
In 1969, Ken Thompson & Dennis Ritchie at Bell Labs -AT&T
redesigned the Multics and introduced New OS UNICS
(Uniplexed Information & Computing System)
It is written in 80 percent of C language and 20 percent
assembly language.
Later on totally rewritten in C language and named as UNIX
(1973 ).
History of Unix
In 1988, AT&T shocked the UNIX community by purchasing a
percentage of Sun Microsystems which became a threat for
other vendors.
So, other vendors quickly formed a consortium group called
OSF (Open Software Foundation) and former formed their
group named UI (Unix International).
History of Unix
In 1990 s, Linus Torvalds ,a graduate student form University
of Helsinky designed a UNIX like kernel on 386 Intel machine
and gave this to OSF.
Linux Kernel was bundled with many software's from various
distributors and it gave rise to many flavors of LINUX.
Unix Principles
Every thing is a file
UNIX system have many powerful utilities designed to
create and manipulate files.
Configuration data stored in text format
Text is a universal interface and many UNIX utilities exist to
manipulate text.
Small Single purpose programme
UNIX provide many small utility that perform one task very
well.
Unix Principles
Ability to chain Programmes together to perform complex
task:-
A core programme feature of UNIX is that the output of one
programme can be the input for another.
What is free software
The term “Free software” may have a different meaning than
you except. The term doesn’t refer to the cost of the software
but the fact that end user has the freedom to modify and
change the programm.
“Free software” refers to the users freedom to run, copy
distribute, study change and improve the software.
GNU Project
The GNU Project was launched in 1984 to develop a
complete Unix-like operating system which is free
software: the GNU system.
GNU's kernel isn't finished, so GNU is used with the
kernel Linux. The combination of GNU and Linux is
the GNU/Linux operating system, now used by
millions.
Sometimes this combination is incorrectly called
Linux. There are many variants or “distributions” of
GNU/Linux.
Why Linux ?
• Open Source -Free
• Multi-User Multitasking
That means one person can be logged on to the same Linux
computer at the same time and a user can have more than
one process executing at the same time.
• Wide hardware support
• Biggest servers on this planet running Linux without single
second of downtime from last 10yrs
• Security Inbuilt firewall (iptables)
Who uses Linux?
Linux is freely available, and no one is required to register their
copies with any central authority, so it is difficult to know how
many people use Linux. Several businesses now survive solely
on selling and supporting Linux, and the Linux newsgroups are
some of the most heavily read on the internet, so the number is
likely in the millions, but firm numbers are hard to come by. The
best market research currently indicates between 7.5 and 11
million users.
Linux Distributions
RedHat Linux Versions
RHEL- 4 Requirements
About Linux Certificate
RedHat Certified System
Administrations (RHCSA)
RedHat Certified Engineer-RHCE
Booting
Booting is a process in which your computer gets
initialized. This process includes initializing all your
hardware components in your computer and get them to
work together and to load your default operating system
which will make your computer operational.
Hardware Boot
Boot Loader
Kernal
Init
Login Screen
Hardware Boot
Boot Loader
Kernal
Init
Login Screen
Hardware Boot
Boot Loader
Kernal
Init
Login Screen
Hardware Boot
Boot Loader
Kernal
Init
Login Screen Local host login :
Local Logins
• Text Mode Login at Virtual Console
• Graphical Login
Virtual Console
The virtual console enable a user to have multiple logins even when
not using an X window System. They provide full screen non-GUI
access to the system. The virtual console available through
Ctrl+Alt+(F1-F6)
If X is running it is available as Ctrl+Alt+F7.
File System Hierarchy
/
This Directory is called as root Directory. It is the
top of the file system structure. All other
Directories are mounted under it.
/root
This is the default home directory of administrator (i.e., root).
/home
It contains all users home directories.
/boot
This Directory contains the Kernel, the core of the
operating system. This also contains the files related to
booting the system such as the boot loader and the
initial ramdisk.
/sbin
It contains administrative commands used by superuser.
/bin
This Directory contains command used by the
superuser and the normal users.
/usr
It contains the programs and applications
which are available for users (similar to
program files on windows)
/var
It contains variable information , such as logs and
print queues.
/dev
This Directory contains devices nodes through
which the operating system can access
hardware and software devices on the system.
/etc
It contains all configuration files.
/proc
This Directory is a mount point for virtual
information about currently running
system processes. This Directory is empty
until the proc file system is mounted.
/tmp
This Directory contains temporary files used by the
system
/opt
It contains the third party applications
ex:-Corel Word Perfect
Sun Star Office
/media
It contains default mount points of removable media
such as cdrom, floppy disk, pendrive.
/lib
It contains libraries need by no. of different
applications as well as linuxkernel.
Types of Backup
Full Backup
Complete back up of entire system.
Incremental Backup
It includes all files that were changed since the last
backup. It always smaller than differential backup.
Differential Backup
It includes all the files that were changed since the last
full backup. As time increases since the last full-backup
the size of differential backup increases.
Commands for Backup
tar (tape archive)
tar command
To take the backup
[root@comp1 ~]#tar <options> <destination> <source>
Options :
-c - Create
-v - Verbose
-f - File
-t - Table of content
-x - Extract to
tar Command
To take the backup
[root@comp1 ~]# tar -cvf<path><file name> <source>
To list the content of tar file
[root@comp1 ~]# tar -tvf<path><file name>
To extract the content of tar file
[root@comp1 ~]# tar -xvf<path><file name>
RPM’S
RPM stands for RedHatPackage Manager.
By using RPM utility the user can install the
new packages, can upgrade and can also
remove existing packages.
RPM Pattern
RPM -Install
To install the RPM package
[root@comp1 ~]#rpm <options> <package name-version>
--force --aid
Options :
-I - To install the package
-v - Verbose
-h - To Display the progress in hashes
--force - To install package forcefully
--aid - To install package along with dependencies
RPM -Upgrade
To upgrade the existing RPM package
[root@comp1 ~]#rpm <options> <package name.version>
Options :
-U - To Upgrade the existing the package
-v - Verbose
-h - To Display the progress in hashes
RPM - Remove
To remove the existing RPM package
[root@comp1 ~]#rpm <options> <package name> --nodeps
Options :
-e - To uninstall the package from the system
--nodeps - To uninstall package even if dependencies
are there.
RPM Options
To query the RPM Package
[root@comp1 ~]# rpm <options> <package name>
Options :
-qa - Queries all installed RPM
Does not require any package specification.
-qc - Lists only the configuration files stored in the queried RPM.
-qd - Lists only the documentation files stored in the queried RPM.
-qi - Displays complete information about the queried RPM.
-qs - Displays the states of files in the queried RPM.
-ql - Display all the files related to the queried RPM.
Naming Conventions
Commands
To view list of partitions
[root@comp1 ~]#fdisk-l <device name>
Creation of Partition
Creating a new partition
[root@comp1 ~]#fdisk<device name>
Creation of Partition
Commands
Updates the partition table to kernel without restarting
[root@comp1 ~]#partprobe
Ext2 vs Ext3
Ext2 Ext3
No journaling support Journaling supported
Less speed More speed
Less Secure More secure
Formatting of partition
To format partition using ext2 filesystem
[root@comp1 ~]#mke2fs <partition>
To format partition using ext3 filesystem
[root@comp1 ~]#mke2fs -j <partition>
Mounting Filesystem
Created a directory for mounting the partition
[root@comp1 ~]#mkdir <directory name>
To mount the filesystem on the created directory
[root@comp1 ~]#mount <partition> <directory name>
To unmount the filesystem
[root@comp1 ~]#umount<directory name>
Mounting Filesystem-Permanently
To mount file system permanently
[root@comp1 ~]#vi /etc/fstab
/etc/fstab
Converting from Ext3 to Ext2
Converting from Ext2 to Ext3 filesystem
[root@comp1 ~]#tune2fs -j <partition>
RAID’s available in Linux
RAID 0 (striping without parity)
RAID 1 (disk mirroring)
RAID 4 (parity)
RAID 5 (disk striping with parity)
RAID 0
Minimum -2 Hard Disks
Maximum -32 Hard Disks
Data is written alternately and evenly to two or more disks
Read & Write Speed is Fast
Fault Tolerance is not available
How RAID 0 works ?
RAID 1
Minimum -2 Hard Disks
Maximum -2 Hard Disks
Simultaneously data will be written to two volumes on two
different disks
Read Speed is Fast & Write Speed is Slow
Fault Tolerance is available
How RAID 1 works ?
RAID 4
Minimum -3 Hard Disks
Maximum -32 Hard Disks
Data is written alternately and evenly to two or more disks
and a parity is only written on one disk
Read & Write Speed is Fast
Fault Tolerance is available
How RAID 4 works ?
RAID 5
Minimum - 3 Hard Disks
Maximum - 32 Hard
Disks Data is written alternately and evenly to two disks and a
parity is written on all disk
Read & Write Speed is Fast
Fault Tolerance is available
Also Known as Striped with parity
How RAID 5 works ?
Steps
Create multiple partitions
[root@comp1 ~]#fdisk /dev/hda
To update the Kernel without restarting
[root@comp1 ~]#partprobe
RAID Commands
To club all the RAID partitions in to a single array
[root@comp1 ~]#mdadm -C /dev/md0 -n3 /dev/hda8
/dev/hda9 /dev/hda10 -l5
To display RAID device
[root@comp1 ~]#mdadm -D /dev/md0
To format RAID device
[root@comp1 ~]#mke2fs -j /dev/md0
RAID Commands
Create Mount Point of RAID Device
[root@comp1 ~]#mkdir /raid
Mount the Raid device
[root@comp1 ~]#mount /dev/md0 /raid
[root@comp1 ~]#cd /raid
RAID Commands
To make a partition faulty
[root@comp1 ~]#mdadm -f /dev/md0 /dev/hda10
To remove partition from RAID array
[root@comp1 ~]#mdadm -r /dev/md0 /dev/hda10
To add a new device into the RAID array
[root@comp1 ~]#mdadm -a /dev/md0 /dev/hda11
RAID Commands
To stop the RAID
[root@comp1 ~]#mdadm -S /dev/md0
To activate RAID
[root@comp1 ~]#mdadm -A /dev/md0 /dev/hda8
/dev/hda9 /dev/hda10
Basic File Permission
The Unix/Linux file has 8 attributes which
are listed with ls l
Access Permission
File Permission Modes
Permissions
Symbolic Mode Absolute Mode
r w x 4 2 1
Default File Permission
When a file created with the help of cat, touch, vi will
get the permissions as 644.
- rw- r-- r--
i.e.
read-write for the owner.
read-only for the owner’s group and
read-only for the others
Default File Permission
Actually in the basic UNIX system when a file is created it
gets the permission as 666.
But this lapses in security, so when ever a file is created in
UNIX system it masks some bits, with a mask value of 022.
After masking we get the default value of a file as
644. [666 - 022 = 644]
022 is as the UMASK value.
umask
To view the Umask value
[root@comp1 ~]#umask
To view Umask value from file
[root@comp1 ~]#vi /etc/bashrc
Default Directory Permission
When a directory is created with the help of
mkdir will get the permissions as 755.
d rwxr-xr-x
Default Directory Permission
Actually in the basic UNIX system when a directory is
created it gets the permission as 777.
But this lapses in security, so when ever a directory is
created in UNIX system it masks some bits, with a mask
value of 022. After masking we get the default value of a
file as 777. [777 - 022 = 755] 022 is as the UMASK value.
chmod Command
Chmod command is used to change the permissions of a
file/directory. chmod can be used by the owner of the file or
by root. With chmod command we can assign permissions
or remove permissions as required.
Applying permission to File or Directory
[root@comp1 ~]#chmod<permissions> <file/directory>
Permission parameters used with chmod command
Category u g o
Operators + -
Permissions r w x
Weight 4 2 1
Example of Permission -Absolute
Applying permission to Owner (u), Group (g) & Others (o)
for File1
Example of Permission -Symbolic
Applying permission to Owner (u), Group (g)
& Others (o) for File1
What is NFS?
The NFS environment contains the following
components:
NFS server
A system that contains the file resources to be shared
with other systems on the network.
NFS client
A system that mounts the file resources shared over the
network and presents the file resources as if they were
local.
Requirements
Packages
portmap-4.0-63.i386.rpm
nfs-utils-1.0.6-46.i386.rpm
Port Numbers
2049 Nfsd
111 Portmap
Configuration File
/etc/exports
Service
portmap
nfs
Daemons
nfsd
Configuring NFS Server
Create directory to be shared
[root@comp1~]# mkdir /var/hpes
Open configuration for editing
[root@comp1~]# vi /etc/exports
/etc/exports
To add the below
/var/zoom *
NFS Server
To restart the NFS services
[root@comp1 ~]# service nfs restart
To check NFS server
[root@comp1 ~]# showmount -e <server name or server ip>
Configuring Client
Create Mount point on client
[root@comp1 ~]# mkdir /nfs
Mount remote shared filesystem on local mount point
[root@comp1 ~]# mount 192.168.0.253:/var/zoom /nfs
[root@comp1 ~]# cd /nfs
What is SAMBA?
• Samba is the way a Linux computer communicates
with SMB (Server Message Box) and CIFS.
• With Samba, you can make your Linux computer a
part of a Microsoft-based network. Computers with
various Microsoft operating systems can communicate
with each other using the Server
• Message Block (SMB) protocol. When a Microsoft
operating system shares files or printers on a TCP/IP
network, it uses the Common Internet File System (CIFS).
Requirements
Packages
samba-common-3.0.10-1.4E.i386.rpm
samba-3.0.10-1.4E.i386.rpm
samba-client-3.0.10-1.4E.i386.rpm
Port Numbers
137 NetBIOS Name Service
138 NetBIOS Datagram Service
139 NetBIOS Session Service
Configuration File
/etc/samba/smb.conf
Service
smb
Daemons
smbd
Configuring SAMBA Server
Create directory to be shared
[root@comp1~]# mkdir /var/hpes
Open configuration for editing
[root@comp1~]# vi /etc/samba/smb.conf
/etc/samba/smb.conf
To change the options
[myshare]
comment = Hpes’s Share
path = /var/hpes
valid users = user1 user2
public = no
writable = yes
printable = no
create mask = 0765
Samba Server
To restart the Samba services
[root@comp1 ~]#service smbrestart
To test smb.conf file
[root@comp1 ~]#testparm
Samba Server
Create Users
[root@comp1 ~]#useradd user1
[root@comp1 ~]#useradd user2
Create directory to be shared Assign them Samba password
[root@comp1~]# smbpasswd -a user1
[root@comp1~]# smbpasswd -a user2
Samba password entries can be found at
/etc/samba/smbpasswd
Samba Client Windows
Map Drive Samba Drive
Right click My Network Places
Select Map Network Drive
In the dialog box provide
Drive : Z:
Folder:\\192.168.0.253\myshare
It opens authentication dialogbox, where
username : user1
password : ****
Open Windows Explorer to find Z: drive mapped to
Linux shared folder.