You are on page 1of 800

index

Units:
unit-1 unit-2 unit-3 unit-4 unit 4 unit-5 unit 6 unit-6 unit-7 unit-8 unit-9 unit-10 About the founder of Linux. Linux VS Windows. Linux Flavors. Introduction to Redhat Linux Linux. Kernel. Types of shells Dos Vs Linux. Redhat Linux Installation Hardware Requirements Installation Methods

Unit -1

About the founder of LINUX


Linus Benedict Torvalds (born December 28, 1969) began the development of Li d l t f Linux, an operating ti system kernel, and today acts as the project coordinator. Inspired by Minix (a kernel and operating system developed by Andrew ) Tanenbaum), he felt the need for a capable UNIX operating system that he could run on his home PC. Torvalds did the original development of the Linux kernel primarily in his own time and on his equipment.

Evolution of Linux
Torvalds originally used Minix on his computer, a simplified kernel written by Andrew Tanenbaum for teaching operating system design. The Linux system quickly surpassed Minix in functionality. The first version of the Linux kernel was released to the Internet in September 1991. with the second version following shortly thereafter in October

TUX - the penguin


Penguin is the official mascot of the Linux operating system. th Li ti t Tux is a chubby penguin that Tux, looks content and satisfied. The concept of the Linux mascot being a penguin came from Linus Torvalds, Torvalds the creator of the Linux kernel.

GNUs (Not Unix)


The GNU project was started in 1983 for developing a complete Unix like Unix-like operating system including software development system, tools and user application programs, entirely of free software.

By the release of the first version of the Linux kernel, the GNU project had produced all the necessary components of this system except the kernel.

Torvalds and other early Linux-kernel developers adapted their kernel to work with the GNU components and user space p g programs to create a fully functional operating system. y p g y

FEATURES OF LINUX
Open source development model. Supports wide variety of hardware. Supports many networking protocols and configurations systems. Supports more File systems Linux has a reputation for fewer bugs (programming mistakes) than Windows.

Linux

Vs

Windows

Open Source Development Model It is not an open source and hence and so the programmer can cannot be redesigned by the p g g y redesign the OS. programmer. Linux is robust and very much Windows gets affected by virus secure from virus. very easily. The Linux servers has surpassed Security is the main issue which windows server operating system in has made windows to think to security. survive. It costs less to design implement a Linux Network. and It costs more to implement Windows Network administration, when compared to Linux.

There are 250000+ developers Compared to Linux, windows is behind Linux for open source developed by few thousands of deployment. people.

Linux Flavors
Red Hat Linux (Red Hat) Fedora Linux Open Linux (Caldera) SuSE Linux (Novell) Mandrake Linux (Mandrake) T b Linux (P ifi Hi T h) Turbo Li (Pacific Hi-Tech) Linux PPC (MAC Power PC version) Info magic Slack ware Linux Project Knoppix (Live CD) etc.,

Introduction to Red Hat Linux


Red Hat has split its Linux development into two lines : Red Hat Enterprise Linux and The Fedora Project. Red Hat EL features commercial enterprise products for servers and workstations, with controlled releases issued every two years. Th F d The Fedora project i an open source i iti ti whose j t is initiative h Fedora Core release will be issued every six months.

Kernel
The kernel is the essential center of a computer ope a g sys e , e co e a p o des bas c se ces operating system, the core that provides basic services for all other parts of the operating system. A kernel can be contrasted (compared) with a shell, shell is the outermost part of an operating system that interacts with user commands. Kernel and shell are terms used more frequently in Unix operating systems th ti t than i IBM mainframe or Mi in i f Microsoft ft Windows systems.

Shells
Bash shell (Bourne again Shell) Developed for the GNU Project The actual standard Linux shell Default shell for Red Hat Linux Borne shell (sh) Original Unix shell written by Bill Joy t J at UC B k l Berkeley C shell ( h) h ll (csh) Added many features such as command, history and job control
Continue

Shells
Korn Shell (Ksh) Written by David Korn ( ) y Implemented many csh features such as

command completion and history

Th E h The Enhanced C shell (t h) a community effort d h ll (tcsh) it ff t More features like command-line editing and more sophisticated completion

Shells
command prompt for bash shell

Type bash and hit enter

Shells
command prompt for c-shell (csh)

Shells

command prompt for h f enhanced C d shell (tcsh)

Shells

command prompt for bourne shell (sh)

Shells

command prompt for korne shell (ksh)

DOS Vs Linux
DOS Command DIR TREE CD MKDIR RMDIR CHDIR DEL LINUX Command C d Action A ti ls -l ls R cd mkdir rmdir pwd rm List directory contents List directory recursively y Change directory Make a new directory Remove a directory Display directory location Remove a fil R file

DOS Vs Linux
DOS Command C d RMDIR /S (NT) DELTREE (Win 95...) COPY XCOPY RENAME or MOVE TYPE MORE HELP or COMMAND /? LINUX Command rm -r Action A ti Remove all directories and files below given directory

cp cp -r mv cat more man

Copy a file Copy all file of directory recursively Rename/move a file Dump contents of a file to users screen Pipe output a single page at a time Online manuals O

DOS Vs Linux
DOS Command CLS LINUX Command clear Action Clear screen

EXIT

exit

Exit a shell

FIND

find

Look for a word in files given in command line

FC

diff

Compare two files and show differences. Also see mgdiff and tkdiff. Show environment variables

SET

set and env

ECHO text

echo text

Echo text to screen

DOS Vs Linux
DOS Command SET variable PATH DATE or TIME SORT EDIT filename.txt \ .\ ..\ LINIUX Command export variable name echo $PATH date sort Action Set environment variables Display search path for executables Show date. (also set date DOS only) l ) Sort data alphabetically/numerically Edit a file The Linux editor file. which looks most like DOS edit is probably Pico. Directory pa de ec o y path delimiter e Current directory Parent directory

vim / ./ ../

DOS Vs Linux
DOS Command LINUX Command Action BACKUP files A:\ tar -cvf /dev/fd0 files Save backup files to floppy

RESTORE A:\ files

tar -xvf /dev/fd0 files

Read files from floppy. See Using DOS floppies Change file to a hidden file - rename file with prefix " " "." Print a file Show free memory on system Show system info ( y (Command borrowed from AIX)

ATTRIB +h or -h PRINT MEM

mv file .file lpr free top lsdev l d

MSD

DOS Vs Linux
DOS Command C d LINUX Command C d Action A ti SCANDISK DEFRAG C: fsck Check and repair hard drive file system p y

FDISK

fdisk

Tool to partition a hard drive.

FORMAT

mke2fs See: fdformat for floppy uname -a

Format drive file system. For floppy drive use see YoLinux Tutorial Using DOS Floppies with Linux Operating system version Compress and uncompress files/directories. Use tar to create Linux also has compress, gzip Print host name of computer

VER

pkzip

tar, gzip and bzip2

HOSTNAME

hostname

DOS Vs Linux
DOS Command LINUX Command Action PING ping Send packets to a network host

TRACERT

traceroute

Show routes and router hops to given network destination destination.

IPCONFIG (NT) WINIPCFG (Win 95 ) 95...) NBTSTAT (Netbios info: n, -c) NBTSTAT -a host-name NBTSTAT -A IP-address ROUTE PRINT

ifconfig

Display/configure network interface

nslookup hostname

Print DNS info for host. host

route -n t

Print P i t routing t bl ti table.

Network Commands
DOS Command LINUX Command ping Action PING Send packets to a network host Show routes and router hops to g given network destination.

TRACERT

traceroute

IPCONFIG (NT) WINIPCFG (Win 95...) NBTSTAT (Netbios info: n, -c) NBTSTAT -a host-name a host name NBTSTAT -A IP-address ROUTE PRINT

ifconfig

Display/configure network interface

nslookup hostname

Print DNS info for host.

route -n

Print routing table.

Hardware Requirement
32-bit Intel based processor, at least an Intel or compatible 80386, 80486, or Pentium-class microprocessor is required required. 400 MHz Pentium is recommended for a graphical interface and 200 MHz for text. Normally 64MB RAM for Text, and y , 192 MB for graphical. (Linux can run on as little as 12 MB RAM). At least 2GB free hard disk space for a standard installation, including applications; 3 to 6 GB or more is recommended for a full installation (all applications).

Installation Methods
Red Hat Installation CD-ROM. NFS Image. Kick Start FTP HTTP

Red Hat Installation through CD


To boot from a CD-Rom or DVD-Rom, you may first CD Rom DVD Rom, have to change the boot sequence setting in your computers BIOS so that the computer will try to boot first from the CD-Rom.

NFS Image
NFS (Network File Sharing): It is a common method to h t share fil files. An image of an operating system is taken already which is connected remotely to install the image in a system. The image system is first mounted and operating system path is given to get into the installation.

Kick Start Installation


Till now we have seen attended installation, where the user have t i t h to interact with th system. t ith the t The kick start installation is known as unattended installation where the user appearance is not necessary. The system will automatically install the operating system into the machine including the device installation, hard disk partition, assigning of ip address etc.,

Red Hat Installation

Press Enter, to install in Graphical mode mode.

Red Hat Installation

Type linux text, to install in Text mode.

Red Hat Installation

Type linux askme install either thr FTP, HTTP, Har , , and NFS.

Red Hat Installation

Type linux text askmethod to install either through FTP, HTTP, HTTP Hard disk and NFS.

Installation Setup Screen


The Installation Mode is selected here

Type Linux Text and press enter for Text mode Installation

Just press enter for graphical mode Installation.

Hardware Detection

Hardware detection process

Select the Installation language. language

Redhat Installations

Select the type yp of keyboard layout.

Redhat Installations

Select the appropriate type of t f installation.

Redhat Installations

Select the appropriate NFS type t installation.

Redhat Installations

Select this option to assign an dynamic ip address.

Redhat Installations

Enter the appropriate ip address

Redhat Installations

Enter the information of server ip address and directory directory.

Redhat Installations

The AnacondaRed Hat Installer begins the I t ll ti th Installation.

Redhat Installations

Hardware detection process

Redhat Installations

Redhat Installations

The Red Hat Linux Welcomes y you.

Select the Partitioning Type

Select this for simpler automatic i l t ti partitioning.

Click here for manual partitioning. Raid and LVM also can be configured (Disk Druid tool can be used only while installation)

Redhat Installations

Click here to create new partition in the free space

Creating Partition for /boot directory

Enter the mount points here.( /boot )

Select the file system type here.( ext2, ext3 t h ( t2 t3 for normal partition and swap for swap p partition) ) Enter the size of the partitions titi here.

Creating Partition for / directory

Enter the mount points here.( / )

Select the file system type here.( ext2, ext3 t h ( t2 t3 for normal partition and swap for swap p partition) ) Enter the size of the partitions h titi here.

Creating Partition for swap directory

Enter the mount points here.(swap)

Enter the size of the partitions h titi here.

Redhat Installations

The final view all the mounting point. point

To Set Boot Loader


Click here to change the default boot loader

GRUB and LILO d are the Red Hat Linux boot loaders. GRUB is the Default Loader of Red Hat Linux 8.0 The default boot operating system can be changed or added here

Redhat Installations

eth0 means first Ethernet card its address getting from DHCP. Hostname also getting from DHCP server..

Firewall Configuration

No firewall option allows all network services t your i to machine No firewall option allows all network services to your machine

Redhat Installations

Activate your SELINUX options

Enable firewall p option allows specific network services to your machine

Redhat Installations

Redhat Installations

Choose the default language for the system.

Redhat Installations

Time zone is selected here here.

Redhat Installations

Enter the password for the root (Super User)

Redhat Installations
Its reading g package information's.

Redhat Installations
Select customize This is Thi i used t select d to l t options to customize the default package. the package selections

Package Selection

The Packages to be installed i t ll d are selected l t d here. Even the office (Like MS-Office in windows) ) Packages are available inbuilt in Red Hat installation CD

Package Selection

Checking and installing the packages. packages

Beginning of Installation

Click next to begin the actual installation which begins writing the operating system in the hard drives.

Installing Packages

Creating the file system in the installation partition.

Installing Packages

The installation image is copied to the hard drive.

Installing Packages

Initializing the installation process

Installing Packages

Preparing for the installation process

Installing Packages

Installation of packages under progress

Installation of tzdata packages

Installing Packages

Installation of packages under progress

Installing Packages

Installation of packages under progress

Installation of packages under progress

Installing Packages

Installation of packages under progress

Installing Packages

Installation of packages under progress

Installing Packages

Performing the g post install configuration.

Reboot the System

The Red Hat Installation is completed successfully. Remove any Installation media and boot disks. And reboot the system.

Rebooting

GRUB boot loader

Highlight the operating g g p g system and press enter to boot.

Loading Kernel

Initializing hardware devices

Initializing services

Welcome to Red Hat Setup

The Red Hat setup agent will proceed some More basic configurations Before the system is ready to use.

Welcome to Red Hat Linux Setup agent

License agreement

Setting date and time

Graphics configuration
Select the screen resolution suiting y g your monitor and display card

Select the Colour depth depththe number of distinct colours required supporting the video g card Installed

Red Hat Login

To register the system to Red Hat enter the Login name and password.

Red Hat Login

If you dont have redhat login select this option to create a new login.

Red Hat Login

Enter this option to know the details

Red Hat Login

The update agent p g registers the machine with Red Hat network So that the latest Software packages Get updated automatically

Click here to g register with the Red Hat network

Click here to skip registration p g

System user creation.

Create non administrative user to access the system.

Sound Card Configuration

Sound getting Configured automatically

Tests sounds for the 3 channels in sound card can be heard by selecting play test sound

To Install additional softwares

Click here to install any additional y software.

Finishing Setup

The Red Hat setup agent Finishes the setup

Login Screen

Login Screen

Red Hat supports many languages, the language can be selected before login.

Login Screen

The kind of desktop can be selected here.

Login Screen

The system can be rebooted using the option.

Login Screen

The system can be restarted using g the option.

Login Screen

Enter the user Name

Login Screen

Enter the user Password.

Loading the user settings.

Red Hat Startup Screen

Now the Red Hat Linux is ready for use.

Kernel initialization
As systems boots, kernel get initialized and the following functions are occurred. D i Device d t ti detection: k kernel will compile th d i l ill il the device drivers and locate it to the corresponding devices. Mounts root file system: After the device detection the kernel will mount the root file system as read only. Load initial process: The very first process (init) is then loaded.

Initial process
Init :

It is the superior of all processes. As soon as init process is loaded the control is p passed from kernel to this process. p

/etc/inittab: File which contains the information on how init should setup the system in every run level, as well as the run level to use a default default.

Run levels
init 0 : Shutdown the system or halt init 1 : Single-user mode. init i it 2 : M lti Multi-user mode with out networking support. d ith t t ki t init 3 : Multi-user mode with networking support. init 4 : Unused. init i it 5 : G hi l user i t f Graphical interface. init 6 : Reboot the system.

Run level configuration file

Get in to the inittab file, the init configuration file.

Run level configuration file

The default run level can be changed here.

CONSOLES
Text-mode login at virtual console Multiple non-GUI logins are possible Default consoles are in text mode Available through CTRL-ALT-F[1-6]

Graphical login Graphical console comes through CTRL-ALT-F7

X Window System
It is the foundation for the graphical user Interface of Red Hat Linux. X applications communicate with a display via. The X protocol. X is OS Independent.

It is available on many platforms.

X Protocol

It hides the individual details of the OS and the underlying hardware.

X protocol is a asynchronous network protocol for the communication between X client and X Server.

It defines how the graphical primitives are communicated between X client and server.

Multiple Desktop Environments


The X Window System of Red Hat provides two Desktop Environments. GNOME (GNU Network Object Modules Environment). KDE (K desktop Environment).

GNOME
It is the default desktop environment for Red Hat Linux. Linux It is Power full and easy-to-use desktop environment consisting primarily of a panel and a set of GUI tools. GNOME is free and hence its source code can be downloaded form the GNOME Web Site:

www.gnome.org.

GNOME Interface
The GNOME Interface consists of a Panel and a Desktop. Panel appears as a long bar across the bottom of screen.

Panel holds Menus Programs and Applets Menus, Applets.

The Remainder Screen is the Desktop. Here you can place directories, files or programs.

GNOME Desktop

GNOME Menus

GNOME Menus

KDE
KDE provides an alternative desktop environment with full set of integrated network and internet applications. applications Along with GNOME features, It also includes Konsole Konqueror K Kmail Kdevelop : Highly configurable graphical terminal. : A file manager and web b fil d b browser. : A graphical email client. : Integrated development.

KDE Desktop

KDE Desktop

KDE Desktop

KDE Desktop

Starting X Window
The X window start automatically, If so then a Graphical login screen is prompted by the Display manager. manager

Alternatively use startx to get in to X window from non-windowing console. i d i l

Start X

To get in to X window from run level-3

Start X

Desktop Selection
Select failsafe y in case of any graphical failure To get in to the previously used desktop

To get in to GNOME desktop. desktop

To get the default desktop. To get in to KDE d k desktop.

KDE MODE
If you click yes the KDE desktop is set as default desktop for future sessions (or) login

If you click N only li k No, l the current session is set to KDE.

Switchdesk

To change the desktop environment.

Switchdesk
To switch from kde to gnome desktop

Switchdesk

Thus we switched h i h d into GNOME desktop p

Linux File System Directories


Directory / /boot /home /sbin /dev /etc /etc/opt Function Begins the file system structure called the root. Hold the kernel image files and associated boot information and files. Contains users home directories user s directories. Holds administration-level commands and any commands used by the root user. Holds file interface for devices such as the terminal p and the printer. Holds system configuration files and any other system files. Holds system config ration files for application in s stem configuration /opt

Linux File System Directories


Directory /etc/X11 /bin /lib Function Holds system configuration files for the X Window System and its applications. Holds the essential user commands and utility p g programs. Holds essential modules. shared libraries and kernel

/lib/modules Holds the kernel modules. /mnt Used to hold directories for mounting file systems like CD-ROMs or floppy disks that are mounted only temporarily. Holds added software applications (for example, pp ( p , KDE on some distributions).

p /opt

Linux File System Directories


Directory /proc Function Process directory, a memory-resident directory containing files used to provide information about the system. Holds temporary files. p y Holds those files and commands used by the system; this directory breaks down into several subdirectories. Holds files that vary, such as mailbox and FTP files. files

p /tmp /usr

/var

Linux Commands
Commands have the following syntax: Command [options] [arguments] Each item is separated by space Options modify the commands behavior Arguments are filenames or other information needed by the command Separate commands with semicolon (;)

DOS Vs Linux
DOS Command DIR TREE CD MKDIR RMDIR CHDIR DEL LINUX Command C d Action A ti ls -l ls R cd mkdir rmdir pwd rm List directory contents List directory recursivly Change directory Make a new directory Remove a directory Display directory location Remove a fil R file

DOS Vs Linux
DOS Command C d RMDIR /S (NT) DELTREE (Win 95...) COPY XCOPY RENAME or MOVE TYPE MORE HELP or COMMAND/? LINUX Command rm -r Action A ti Remove all directories and files below given directory

cp cp -r mv cat more man

Copy a file Copy all file of directory recursively Rename/move a file Dump contents of a file to users screen Pipe output a single page at a time Online manuals O

DOS Vs Linux
DOS Command CLS LINUX Command clear Action Clear screen

EXIT

exit

Exit a shell

FIND

grep

Look for a word in files given in command line

FC

diff

Compare two files and show differences. Also see mgdiff and tkdiff. Show environment variables

SET

set and env

ECHO text

echo text

Echo text to screen

DOS Vs Linux
DOS Command SET variable PATH DATE or TIME SORT EDIT filename.txt \ .\ ..\ LINIUX Command export variable name echo $PATH date sort Action Set environment variables Display search path for executables Show date. (also set date DOS only) l ) Sort data alphabetically/numerically Edit a file The Linux editor file. which looks most like DOS edit is probably Pico. Directory pa de ec o y path delimiter e Current directory Parent directory

vim / ./ ../

DOS Vs Linux
DOS Command LINUX Command Action BACKUP files A:\ tar -cvf /dev/fd0 files Save backup files to floppy

RESTORE A:\ files

tar -xvf /dev/fd0 files

Read files from floppy. See Using DOS floppies Change file to a hidden file - rename file with prefix " " "." Print a file Show free memory on system Show system info ( y (Command borrowed from AIX)

ATTRIB +h or -h PRINT MEM

mv file .file lpr free top lsdev l d

MSD

DOS Vs Linux
DOS Command C d LINUX Command C d Action A ti SCANDISK DEFRAG C: fsck Check and repair hard drive file system p y

FDISK

fdisk

Tool to partition a hard drive.

FORMAT

mke2fs See: fdformat for floppy uname -a

Format drive file system. For floppy drive use see YoLinux Tutorial Using DOS Floppies with Linux Operating system version Compress and uncompress files/directories. files/directories Use tar to create compilation of a directory before compressing. Linux also has compress, gzip Print host name of computer

VER

pkzip

tar, gzip and bzip2

HOSTNAME

hostname

DOS Vs Linux
DOS Command LINUX Command Action PING ping Send packets to a network host

TRACERT

traceroute

Show routes and router hops to given network destination destination.

IPCONFIG (NT) WINIPCFG (Win 95 ) 95...) NBTSTAT (Netbios info: n, -c) NBTSTAT -a host-name NBTSTAT -A IP-address ROUTE PRINT

ifconfig

Display/configure network interface

nslookup hostname

Print DNS info for host. host

route -n t

Print P i t routing t bl ti table.

Network Commands
DOS Command LINUX Command ping Action PING Send packets to a network host Show routes and router hops to g given network destination.

TRACERT

traceroute

IPCONFIG (NT) WINIPCFG (Win 95...) NBTSTAT (Netbios info: n, -c) NBTSTAT -a host-name a host name NBTSTAT -A IP-address ROUTE PRINT

ifconfig

Display/configure network interface

nslookup hostname

Print DNS info for host.

route -n

Print routing table.

Login screen

Enter the user name

PWD
PWD

Present working Directory Display the absolute path of the current directory.

PWD

The absolute path of the root directory is displayed.

ls
ls : List the Files and Directories within the current directory. Syntax: ls [options] Options: -l l Li t fil with permission. List file ith i i

-a List hidden file. -i List files and inode number.

-R List directories , sub directories and their contents.

ls

Lists the files and directories in the present directory.

ls -l

l option lists the long listing of Files and directory.

l l command

It defines the I d fi h No ofname of the group links to the Owner name, Thepermissionsthe directory the user who created which to assigned hasthe Time stamp h directory. File files permissions over the Size of theor directory the digroups and files owners, or directories names. or directories other users

ls -a

[a] option lists all files and directories including hidden files

ls -al

al option lists all files and directories including hidden files in long listin format.

ls -R

[R] option lists working directory as well as contents in the directory. y

mkdir
mkdir : Make directory (or) To create a directory

Syntax : mkdir <dirname> kdi di

mkdir

This will create a directory advpro advpro.

cd
cd - Change directories Syntax : cd <directory name> cd .. - To a directory one level up (parent directory) cd cd / -

To your previous working directory

o the (s as ) d ecto y To t e / (slash) directory

cd

This command will take you to the directory .

cd ~
Previous slide we have seen cd along with any directory name. y This command cd ~ <enter> will take to your home directory

cd ..

cd .. Take you to the y parent directory of the current directory.

cd ..
Now we can see that we are in advpro directory, the parent directory of the test y

cd /
cd / will take you to / (Slash directory)

through pwd command

cd /
Confirmed through the pwd command

cd
Here the current directory is newdir when we enter cd -, it takes cd - is given as Again to the previously worked it will take shown. Nowdirectory. to the previously h i l worked directory i.e., ( (newdir) )

cd command will take you to the previous working directory

cat
cat it is the command to create and view files Syntax:

cat [options] [filename] cat > [filename] To create a file cat [filename] To view a file cat >> [filename] T append t t to a t [fil ] To d text t file

cat
As mentioned in the previous slide. cat is used to create a file The file is saved through ctrl -d th h tl d after typing the text

cat
Enter cat <filename> fil to view the content of file.

cat

To append the text in a file, Cat >> (symbol) and file name.

cat

The screen shows the appended file

cat

The -s option p trims multiple adjacent blank lines into single blank line

cat

The b option numbers the each text line of the output

cat

The A option shows all characters including control and non t l d printing characters Here the $ represents the end of the line

touch
touch command is used to update the time stamps of a file. touch is also used to create empty file. Syntax : touch [filename] touch can create multiple empty file too. Syntax : touch [filename1] [filename2]

touch
Here the empty file is created

touch
Multiple files are created using touch command

Copy Command
cp : cp command is known for copying files and directories. Syntax : cp [options] source destination

O ti Options : -r recursively copy an entire directory tree -p preserve permissions, ownership, and time stamps Example : cp File1 File2 e e

Copy Command
There is a file named i d a in the directory test .

Copy Command
Here we notice that test1 is a empty directory. Let us copy the file a into this directory. thi di t

Copy Command
Cp copies the file a from the directory f th di t test to the directory test1.

Copy Command

Thus the file a is copied to the test1 directory.

Copy Command

Directories new and old are listed with their contents. contents

Copy Command

-r option copy the entire directory tree old

Copy Command

Thus th Th the contents of y old directory is copied to new directory. directory

Copy Command

Command l l shows the permission of the file

Copy Command

Using chmod, p permission of the file is changed

Copy Command

Now, we copy the file one to the directory old

Copy Command
See the comparison of the file one shown above in the new and old directory

Copy Command

Now using command cp along with p option the p permission is preserved.

Move Command
mv : This command is used to move and renaming files and di t i d directories Syntax: mv <source> <destination>

Example mv file1 file2 (now the file1 is changed to file2)

Move Command

A file is available in the name of one in the directory old di t ld

Move Command

Here we see that using mv command the file is moved from old to new directory.

Move Command
Now check into the old directory where the file one is moved. Hence the directory is empty

Move Command

The file one is shown above in the new directory

Move Command

Here a file is created test in the old directory di t

Move Command

This example shows how to rename a file test to tested

Move Command

Using the l l command, the above screen shows the renamed file

rm and rmdir command


rm : This command is used to remove files Syntax: rm <fil <filename> > Example : rm file1 rmdir : This command is used to remove directories. Syntax: rmdir <directory name> Example : rmdir linux

rm command

This screen shows the contents of the new directory The above rm command is used to remove the file k

rm command

Here the file named k is removed from the directory

rmdir command

Here a directory is created named donic which is removed through the command rmdir d di

rmdir command

The above screen shows that directory donic is removed

rmdir command

In the above screen we see that directory tomy i unable is bl to remove

rm command

Using rm with g option r, the directory along with contents can be removed

rm -r command

Now the above screen shows that the directory is removed

rm command

The above screen shows the contents of directory jerry

rm -ri command

The rm with ri command is used to remove the contents interactively.

rm -ri command

We can see that the file for which we have given y n y is removed and n is preserved

File command
The file command is used to check the file content.

Syntax : file <filename> Example: file f1 (f1 is a file. File will show the format) file /dev/fd0 (The output shows that the fd0 is a block special file)

File format
The file along with file name (ss) shows the file format

File format

This shows the format of the file cat as executable file fil

more

l l command shows the contents at once. once

more

l l lists the content quickly, which makes the viewer to see only last page

more

More is used to lists the contents one screen at a time

more

More is been prompted after listing one b one by

more

Here it is the same process listing more contents, t t shown as above

more

Here it is the same process listing more contents, t t shown as above

more
Now the more command is i over and d we are in the end of the page

vi & vim editor


Vi is known as the visual editor. It is a standard editor under Linux and Unix system. Vim is the improved version of vi editor p Vi have three modes of operation Command mode Insert mode Esc mode

vi Modes
Command mode: Operations such as cut, copy, paste, delete, p , py, p , , undo, redo etc., are done in this mode. Insert mode: Type in new text y Ex-mode : Extended commands for saving, exiting, searchand-replace can executed here

Working with vi editor

exam is a file created or opened with the vi editor.

Command Mode

Press i to get into the insert mode

Insert Mode
This is the insert mode

Insert Mode

After typing the datas hit escape to get into command mode

Ex- Mode

Press :wq to write and quit

Ex- Mode

Press q ess q! to quit without saving the data

Yank

Like this example, you can copy any number of lines by typing numbers of lines and yy

Hit escape and type 3yy t yank t 3 to k three lines from the cursor position p

Text yanked

In the previous slide, we saw how to yank the text. After yanking we see the message as below

Text put

Now the yanked text is pasted from the th cursor position iti by hitting the p

delete

To delete text, place the cursor in the beginning of the line and give the total number and dd

delete

Now 3 lines are deleted and message get displayed as 3 fewer lines as shown below

cut and put

To cut a line after curser position hit 1cc.

cut and put

Get into insert mode and place the cursor p where the data should be pasted. Press esc to get in to command mode

cut and put

Now hit p to paste the data.

Search

Get into ex mode type / followed by da a o data to be searched and press enter

Search

When we press enter it shows the first s o s e s found match from bottom to top.

Search

Then if we press n it will shows the second match for that da a we co a data.If e continue ue pressing n it will show successive matches.

Find command
Find: To search files and directories in a specified path. Syntax: find <directory> [conditions] [action] Condition: -name <file name> - to search a particular file -user <user name> - lists the files owned by user. -perm <mode> - search a file depending on permission. permission

Find command

This command searches the password fil f d file from / directory.

Find command

The above screen shows the execution of command

Locate command
Locate:

To search or locate files and directories from the database. It locate the files faster than the find command

Syntax: y locate [pattern]

Locate command

To search file named test1 from database.

Locate command

All the files and directories named test1 is located and displayed. p y

Man command
man : Display helpful information about commands. Syntax: man [option] command Option: k - search by command description rather than k command name.

Man command

It displays manual pages for ls command. d

Man command
The manual page of ls command is displayed h di l d here.

Enter q to exit from manual page. p g

useradd command
useradd : To create a new user account and login directory for that new account account. Useradd will create new entries in system files. Syntax useradd [options] [user] Options -c Comment field. -d Home directory -e Account expiration date.

useradd command
User named abdulkalam is created.

To set password for abdulkalam. abdulkalam

useradd command
Enter the password.

User home directory

When new user account is created ,a login directory for the user is created in /home dir.

User configuration files


When a new user account is created, its entries updates the following system files. p g y

- /etc/passwd - /etc/group - / t / h d /etc/shadow

Passwd file
To view password configuration file.

Passwd file

represents First field Groupid. Userx id. encrypted t d represent password is username. available in shadow file.

User login User home shell. directory.

Shadow file

To view shadow file.

Shadow file
Encrypted yp password for the user abdulkalam. abdulkalam

Groups file
To view group file

Groups file
Group id for the user abdulkalam.

User login
Abdulkalam logging in .

User login
User home dir or login dir

userdel command
User account can be deleted through userdel command

Creating groups
New group is created by hand-editing the file /etc/group or by using groupadd command. Syntax: groupadd groupname groupdel command is used to remove the group. Syntax groupdel groupname Groupmod is used to rename the existing groupname. Syntax: groupmod n newname oldname n

Groupadd command
A group is added in the name of india by using the command groupadd.

Usermod command

Using usermod command the user abdulkalam is added to group India

Groups file
To view group file

Groups file

The id number g group assigned to the g p india is 501 The last field shows the user abdulkalam added in India group

Groupdel command

Groupdel command deletes window group.

Group Administration

Create a directory named product and group named sales.

Group Administration

Users are added in the sales group using usermod command.

Group Administration

Open the group file.

Group Administration

This shows that the three users are added in the sales group.

Group Administration

Change the group name sales to product directory using chgrp command.

Group Administration

The screen sho s shows that the changes been made in the group field.

Group Administration

Three files created under product directory.

Group Administration

The permission for the product directory is changed.

Group Administration

The user tom is not a member of the group. f So the permission is restricted.

Group Administration

suresh logs in terminal. As g he is the member of the group, he have the privilege to access the file. file

Group Administration

rajesh logs in terminal. As j g he is the member of the group, he have the privilege to access the file. file

Group Administration

tom logs in terminal. he is g not the member of the group so does not have the privilege to access the file. file

Group Administration

The above screen shows the permission been restricted to the user tom tom.

Changing owner

After giving the The chown chown command command change th filis or h the owner the file changed from directory owner. root to suresh.

Changing owner

The owner and group name can be change using h i chown command.

chage command
The chage command let you specify an expiration limit for a user's account and password . Syntax: chage [option] username Option -l lists the current password expiration l expiration. -m set the min. days to change the password. -M set the max. days to change the password. -E specific expiration date for user account. -I set inactive period (in days) -W warning period number of days before W period, expiration.

User administration

Inactive period is used to give grace time to change the p password.

Chage l : lists This field sets the the account and password for the password maximum valid information of days given. user tom.

User administration

The password The M expires field is command with updated as the 100 sets by +100 days from user maximum days. creation date.

User administration

Allowable account inactivity period after which password will expire.

User administration

The -W option shows the warning message before expiration.

User administration

The -m option for minimum number o of days a use user can exists with password.

User administration
The -E option is E for specific expiration date for an account.

Set userID
It allows an executable file to run under the user or group security context with the permission of its owner.

SUID can be set as follows: chmod u+s [filename] (or) chmod 4xxx [filename]

Set userID

The passwd is the command which updates d hi h d t the password in the shadow file, instead of not having the execute permission.

The above screen shows file shadow and password along with the set user id permission. permission

Set userID

Tom changes the p password using g passwd command.

Set userID

The set userid permission is removed from the /usr/bin/passwd file. file

Set userID

Now we can view that tom user cannot change the password.

Set GroupID

The user suresh who create a file, file the group name is assigned as suresh.

The user suresh logs ge into the ogs get o e product directory and create a file.

Set GroupID

Note: the group sales is added to the product directory.

The groupid is se o e set to the product directory.

Set GroupID

After setting the group id, user suresh creates a file win98. Using the command ls l shows t at t e e s c eated that the file is created under the group sales.

Sticky bit

The files remove is possible b ibl because the sticky bit is not set to the product directory.

The user rajesh logs and he removes the file bios created by suresh.

Sticky bit

Using +t option the y sticky is set to the product directory.

Sticky bit

After assigning the sticky bit, user rajesh try to delete the file created by other user but he is unable to do it it.

Switch user
su command is used to switch to another account from the command line. This command is most often used by system y y administrator to temporarily become the root user without logging out of their non privileged account non-privileged account. Syntax su - [user] -c command

Switch user

Here the root user switching to another account.(user joe)

Switch user

It executes root privileged command from the ordinary user account. account

Multi user login


Like unix operating system where multi user login can be done in same sense the Linux operating system done, supports multi user login.

Each user can login in each terminal and can do multi processing which avoids logging off from the system system.

Multi user

tom, is the user who log in the first terminal

Multi user
Joe, is the user who log in the second terminal

Multi user
harry, is the user who log in the third terminal

Multi user
wilson, is the user who log in the fourth terminal

Multi user

bill, is the user who log in the fifth t terminal i l

Multi user
thano, is the user who logs g in the sixth terminal

W is the command to list the users logged in

Advanced Ad anced Uses of VI and VIM

File Repositioning
Press G, Cursor go to last line of a file. Press 1G, Cursor go to first line of a file 1G file. Press Ctrl+f, Cursor forward one full screen. Press Ctrl+b, Cursor go back one full screen. Press Ctrl+d, Cursor go down half a screen. Press Ct l P Ctrl+u, C Cursor go up h lf a screen. half

Screen Repositioning
Press H, Cursor go to first line on screen. Press M, Cursor go to middle line on screen. Press L, Cursor go to last line on screen. Press Z+Enter, Make current line is first line on screen. Press - (hyphen) screen. Make current line last line on

Advanced Reading and Saving


It is also possible to read a other file content in your current files. The following Th f ll i command h l you : d help Go to exmode in a vi editor Syntax : r <filename> Example :r /root/file1 While working in a editor we can copy the file content to another file S Syntax : starting line, endingline w <file name> f Example : 1,20w file2 Example : 21 40w >> file2 21,40w

Filtering
A powerful feature of vi is the ability to include into your document the output of Linux commands. For example if you want to display any command output in your file see following syntax . !!command The syntax will be working in exmod in editor. For example to display date ,type following command in exmod. !!date

Filtering

Open the file in vi mode.

Filtering

This will replace the current line with output of the date command.

Filtering
The output of the p date command is written here.

Sed Command
Sed command just like find and replace .

To display a file , the Sed command change the particular word in standard input only , but not change original content of file. g g

Example of S d command . E l f Sed d sed s/ram/raju/g /root/file1

Sed Command

The output of the named.local is displayed. displayed

Sed Command

Here sed command displays the output by replacing the localhost as www.example.com, but it wont write output in the file.

ex mode : search and replace


vi can perform search and replace operations much like d lik sed command. d Syntax: ex mode:1,$s/searchname/replacename/g 1,$ 1 $ - address starting from line one one. s g - String of character - replace multiple matches in a

line

ex mode : search and replace

Open the file in vi mode.

ex mode : search and replace

It searches and replaces h d l the localhost as www.example.com. p

ex mode : search and replace

Thus the localhost was replaced as www.example.com..

Advanced Reading and Saving


It is also possible to read a other file content in your current files. The following command help you : Go to ex mode in a vi editor Syntax : r <filename> Example :r /root/file1 While working in a editor we can copy the f content to file another file Syntax : starting line ending line w <file name> line, Example : 1,20w file2 Example : 21,40w >> file2 p

Advanced Reading and Saving

Here H you can view i output of test file. Open a file in vi mode.

Advanced Reading and Saving

To display the output of another file named test in the current file.

Advanced Reading and Saving

The output of test file is displayed..

Advanced Reading and Saving

The contents of the existing file.

Advanced Reading and Saving

To write the contents of the existing file in another file named test1.

Advanced Reading and Saving

The contents are h appended to the test1 file.

Advanced Reading and Saving

You can see the appended contents in the test1 file.

Configuring VI and VIM


Number of configuration are available in vi editor, see some of example . :set number - shows a line number on the left margin in a vi editor :set showmatch - when a right curly braces or a right paranthesis is typed, a cursor will jump to the matching left curly braces or left paranthesis. :set all - it shows all configurations.

Set number

File contents.

Set number

To assign numbers to all line in vi editor.

Set all

To view all the possibilities of configurations available in vi editor.

Set all

All the available option are displayed here.

Redirecting Input and Output


Ouput of a command is redirected to a file Command > filename Example ls -l > /root/file1 l Example ls -i >> /root/file1 Output of file redirected to a command Command < filename Example - cat < file1 Error message of a command redirected to a file - Command 2> file1 - Command 2>> file1 - Example ll L > file1 L

Redirecting Input and Output


The Th output of ls fl command is redirected to the Here the file i h fil file named ex.is overwritten by the p output of ls command.

Redirecting Input and Output

The output of ls command is redirected to the di d h file named ex1.

Redirecting Input and Output

Here the output of ls command is appended to the d d h ex1 file.

Redirecting Input
A command which accepts the input from a file is known as Redirecting Input. Syntax - command < file1

Example : tr A-Z a-z < file1

A file is created in the name file1 and text is entered i capital l tt t d in it l letters, which i redirected hi h is di t d through < symbol and the command translates the data to d t t small l tt ll letters.

Redirecting Input and Output

tr translates the upper case letters to lower case.Here output of file v is p redirected as input to the tr command.

Redirecting Input and Output


2> 2 redirects the di h error messages to the ex file.

Here we can see redirected error messages in the ex g file.

Piping
Pipes is used to execute more than one command at a time. See following command. Syntax : Example: command1 | command2 ls -l | more

It is also used to execute command result Example: cat file1 | grep station

Piping

Here the t d H th cat and grep command are executed in pipeline .

Redirecting Both Standard Output And Error

If find command is executed, its output can be stored in file2. if error occurs during execution, the error message is stored in file1. For F example: l find / -name passwd 2> file1 >file2

Redirecting Both Standard Output And Error

If there is any g error messages while execution the error message will be redirected to the file ex1.

If there is no error the t t ill b th output will be redirected to the ex2 file.

tee Command
tee is useful to save the output at various stages from al long sequence of pipes. f i Example: ls | tee a1 | ls l | tee b2 l The above example shows the types of ls commands p yp and options are used to store output to the files g1, g2 and g3.

tee Command
It saves the output of ls in file a1 and output of ls l in file b2.

grep command
grep - means general regular expression processor. -it analyze th content of a file a li at a ti it l the t t f fil line t time, returning a line that matches a pattern.

grep command

Grep prints the pattern matched with ganesh in the file /etc/passwd.

awk command
An awk program searches for lines in a file and performs some action on those lines. d f ti th li

Example: awk /bash/ { print } /etc/passwd p } p

awk command

awk display first field of the /etc/fstab file.

File Compressions
Several compression utilities are available for use on y Linux and Unix system. But most software for Linux system use three compression utilities. 1 - compress 2 - GNU gzip 3 - bzip2.

Compression command
compress: It compresses a file and give the extension as that file. Syntax: compress <filename> fil uncompress: It uncompress the compressed file. Syntax: uncompress <filename> .z for

Compression command
The Th actual l size of file is This 107 bytes. y compresses the file a. The compressed file is i di i indicated by the .z db h extension. Thus the file size is compressed to 39 bytes.

This uncompress the file a.

Compression with gzip


gzip utility compresses file . g gunzip decompresses them. p p To compress a file, enter the command gzip and the filename.this replace the file with compressed version of it,with the extension .gz. To decompresses a gzip file use command gunzip gunzip. Syntax: gzip fil i filename ( (compression) i ) gunzip filename.gz (decompression)

Compression with gzip


The actual size of file is gzip bytes. 107 command compresses the file a. The compressed file is i di i indicated by the db h .gz extension. Thus the file size is compressed to 38 bytes.

This uncompress the file a.

Compression with bzip2


It compresses files using the burrows-wheeler blocksorting text compression algorithm and huffman coding. You compresses files using the bzip2 command and decompresses with bunzip2 bunzip2. The bzip2 command create a file with the extension .bz2 Syntax: bzip2 filename (compression) bunzip2 filename.bz2 (decompression)

Compression with bzip2


The actual size of file is bzip2 command 107 bytes. compresses the file a. The compressed file is i di i indicated by the db h .bz2 extension. Thus the file size is compressed to 51 bytes.

This uncompress the file a .

Creating Archives
Tar: tar t command i used t create archives on d i or fil d is d to t hi device files. Originally, tar was used to create archives on tape devices, hence its name stands for tape archive. archive When creating a file for a tar archive, the filename is usually given the extension .tar. tar While tar is seldom used to back up entire file system.

Syntax for tar command


Syntax for tar command: tar [option] archivename tar filenames- and-directories archivename.tar filenames and directories Options: c - create new archive. t hi v - produce verbose message. f - archivename,a name of new file. archive will be extracted in the current directory. displays a list of file in the archive

x t -

tar command
It create backup for the files a,b,c,d,e and f in d i backup.tar. The backup files are indicated by .tar extension.

tar command
tf options display all the file in backup .

tvf options displays along with the user and group names.

tar command

If incase we miss the file then we can extract those g file back using xvf options .

Printer-configuration Printer configuration

Printer-configuration
Command to configure the Printer Pi

Click New option to p add printer

Printer-configuration

Now the system is loading printer gp information.

Printer-configuration

Click Forward option to add printer queue

Printer-configuration

Choose locally-connected option f local for printer

Printer-configuration

Choose forward option to proceed to next step.

Printer-configuration

Choose any one the manufacture name in he list.

Printer-configuration

Choose the serial number of the printer

Printer-configuration

Choose apply option for What you have selected l d

Printer-configuration

Now the printer configuration are been applying the changes to the system

Printer-configuration

Choose yes you will be getting an test page form the printer

Printer-configuration

lpq is a command to view the queue in printer

Printer-configuration

lpr is a command given to print particular file.

Printer-configuration

lpq is a command to view the th queue in printer i i t

Printer-configuration

lpq is a command to view the number of i h b f queue in printer

Introduction to process
Linux treats each task performed on your system as a process, process which is assigned a number and name name. You can examine this process and even stop them. Red Hat provides several tools for examining processes as well as your system performances. The Th process i easy monitoring i provided b several is it i is id d by l GUI tools,like Red Hat Procman System Monitor.

ps Command
ps command is used to list the process process. To display a information about process specific to the active terminal. Syntax: ps [option] Options available: -a : -x : -l : -u : owner. -e : To view the all process id To di l T display all process, not i l di ll t including process not controlled by a terminal To include all process not controlled by a terminal, such as daemon process. To long list including more information such as process owner's user id. To display user name of the process

pstree command
It shows the h th process ancestry for all process running on the system.

ps a command
Display ll Di l all processes excluding processes not controlled by this terminal.. terminal

ps l command

It list the processes along p g with the owners id.

ps x command
Display ll Di l all processes including processes controlled by this terminal. terminal

ps u command

It list the processes along with the user name.

kill process
Kill command is used to send a particular process to get clear. Syntax : Kill -9 <process id> y p ps - aux is the command to view all process name and id Example: kill -9 3743 (This example shows the kill 9 command, option and the process id to kill.)

kill process

It kills the tty2 terminal bash i lb h processes .

Altering process schedule


renice is the command to set the priority of a process. The priority value can range from -20 (highest priority) to 19 (Lowest priority)

S Syntax : renice - +(minus symbol or plus symbol) i ( i b l l b l) <priority number> -p <process id>

Example : renice -15 -p 1970 15 p

Foreground and Background process


Fg command is used to run the background process in the foreground (Front End) jobs command helps you to view the background processes. Step 1: jobs <enter> to view the process running and job numbers Step 2: fg %2 (job number) bg command is used to resume the suspended command in the back grounded.

Foreground and Background process

Jobs displays the processes running in the background.

& makes the command to run in background.

Foreground and Background process

Fg bring back the back grounded p processes to the foreground.

Foreground and Background process


Here the command is suspended while execution by pressing ctrl+z.

Bg resumes the stopped jobs to the background.

Bash Shell Scripting


Scripting basics A shell script is a text file containing set of commands. Scripts are useful for automating process that you perform repeatedly at the command line. Instead of typing commands the commands are executed commands, through scripts. For example : Every morning when you login you can perform following operations. Checking system date and time Checking email How many users have logged in the server.

Creation of shell scripts


Shell script are written in vi editor The very first line mention what type of script is used line, For example: #!/bin/bash #!/bin/sh #!/bin/csh #!/ /bi / l #!/usr/bin/perl used for bash shell script used for borne shell script p used for C shell script used f P l shell script d for Perl h ll i t

#!/usr/bin/python used for Python shell script

Basic bash shell script


How to print a data in a console echo R d h t <enter> h Red hat t

How to execute a command in echo statement echo hostname `hostname` <enter> ec o os a e os a e e e How to execute a variable in echo statement A = 10 echo A value: $A <enter>

Execute bash shell script file


Two methods available to execute a script file are First method is Syntax : bash filename

Second method is

Syntax

:
Give the execute permission the script file through chmod command Run the file by ./<file name>

Bash Shell Scripting


Get in to the i dit th vi editor to create script file

Bash Shell Scripting


It denotes we are using bash h ll b h shell scripts

This script executes the system hostname and date

Executing script - First Method


Bash example l (file name) to execute the script Output is shown in the terminal

Executing script - Second Method


No execute permission for a file in default

Permission is set to the file, file as executable

Second Method

./ example (file name) to execute the file

Arithmetic Calculation

Example p script file for calculation

Arithmetic Calculation
Using read statement we read the value for A and B

Using expr we can add values l

The output is displayed

The values are entered for input

Partitions
The Linux supports four primary partitions and many logical partitions in the extended partition. The Linux kernel supports maximum number of 63 p partitions on each IDE disk. And maximum of 15 partitions on each SCSI device.

Partition Types
Linux-specific partitions would normally be one of the following types with a unique ID ID. 0X 5 0 X 82 0 X 83 0 X fd 0 X 8e Extended Linux swap Linux Linux RAID Linux LVM

Partitioning
In Linux, partitions can be created by either of the following three utilities f ll i th tiliti fdisk sfdisk disk druid (only available during installation) GNU parted

fdisk
fdisk - Fixed Disk - Menu driven programs to create and delete partitions

Before starting fdisk, identify the hard disk type that is whether primary master or slave and secondary master or slave by using command fdisk -l.

Partitioning with fdisk


l option list the Total hard disk available space with total partitions heads, sectors and cylinders li d Available partitions,Starting the partitions Size of and ending Starhdb indicatesfor each cylinderblocks represents that the the boot hard in disk i di k is connected as partition one d partition. = 8.3MB primary slave cylinder

Partitioning with fdisk

To create partition in the device hdb

Partitioning with fdisk

Type h or help to shows list of available commands in fdisk

Partitioning with fdisk

Type p to display the available partitions

Partitioning with fdisk

Enter the starting cylinderto create a Type n t or just press T t enterpartitionthe new to take default cylinder

Partitioning with fdisk

Enter the ending cylinder or type the size in MB. Type w to save and exit from fdisk. fdisk

Partitioning with fdisk


Instead of restarting to I d f i update the partition table j just enter the command partprobe.

Partitioning with fdisk

Thus a new partition named hdb6 is created

Red Hat Linux Filesystems


Red Hat supports following filesystems filesystems. - ext2 - ext3 - minux - reiserFS (under research)

ext filesystems
ext : E Extended fil d d filesystem. ext2 : Older standard Linux file system supporting for filenames and large file sizes.

ext3 : Standard Red Hat Linux file system, used for all hard disk volumes under Red Hat Linux by default.

It is the extension of ext2 with the feature of journaling (aware of unexpected power outages and disk errors)

minux & reiserFS


Minux : This file system is small , simple and mostly used for floppy disk .It support filenames up to 30 characters. ReiserFS : It is advanced journaling filesystem still under development for Linux. Its main difference between ext3 and reiserFS .Its use disk resource efficiently and is particularly effective with fil system containing many small fil and l ith file t t i i ll files d large directories

Creating file system


Once you create a partition, you have to create a file system on it it. To do this, use the mkfs command. To build the Linux file system and pass the name of the harddisk pa t t o partition as a parameter. pa a ete Syntax: mkfs -t <filesystem type> <partitioname>

Creation of file system

Current partitions are displayed here

Creation of file system

Hdb6,7and 8 are newly created partitions.

Creation of file system

It creates ext2 file system for the device hdb6.

To view the file system type


Dumpe2fs : this command is used to view which file system we are using. t i Syntax : y dumpe2fs <partitions> Example: dumpe2fs /dev/hda1

To view the file system type

It displays the file system information's.

Sparse_super represents the ext2 file system.

Mke2fs command
Mke2fs : This command is used to create file system. Syntax : mke2fs [options] device Example: mke2fs /dev/hda1 (it will create ext2 filesystem for hda1 partition) mke2fs j /dev/hda1 ( will create ext3 filesystem j (it y for hda1 partition)

Creation of file system

It creates ext2 file systems for device hdb7.

View the file system type

Sparse_super p p represents the ext2 file system.

Converting ext2 to ext3 file system

It converts the file system of hdb7 from ext2 to ext3

View the file system type

has_journal represents the ext3 file system thus the ext2 is converted to ext3

Mount command

In I partitions Mount the Linux, like any h Li i i lik other device the hda6 in data1 p partitions should directory and hda7 in be y mounted. data2 directory.

Tune2fs command
tune2fs : It is a command used to converting from ext2 to ext3 file system without un mounting.. Syntax : tune2fs j <partitions> Example: tune2fs -j /dev/hda1

View the file system type.

Ext2 is the current file system for the device hdb6.

Tune2fs command

Here it converts the file system for hdb6 from ext2 to ext3.

View the file system type.

Now the file system is converted to ext3 file system.

Repair Filesystem
e2fsck : This command checks the consistency of the file system and repair it if it is damaged you can use damaged, file system checking tools. Example : e2fsck /dev/hda1 fsck : This command checks and repair a Linux file system. system Example : fsck /dev/hda1 The main difference is e2fsck it will work in ext2 and ext3 filesystem and fsck will work only in ext3 file system.

Repair Filesystem

fsck and e2fsck are the command used to check and repair the file system. y

Disk usage
df and du are used to check the disk usage.

df

: It reports the amount of space used and available on a mount file system as reported.

du

: It displays directories entries and the number of data block assigned to them them.

df command
df command displays the space used and available in the mounted file systems df -h, displays size in human readable format in the power of 1024 df -H displays the H size in the power 1000 instead of 1024. 1024

du command
du command displays the estimate file space usage available df -h & H, displays size in human readable format in the power of 1024 and 1000 respectively. respectively

Performance tools
free command lists the free ram memory and as well as what is used for buffers and swap memory memory.

top command lists the most CPU intensive processes.

Vmstat shows the performance of system components.

free command

free command display information about free and y used memory on the system.

vmstat
Report virtual memory statistics

top
Displays top CPU processes

top

It displays the listing of most CPU-intensive tasks on the system.

Daemon Process
Some process start at boot time and continue running until the system is shutdown. Such process are known as daemon processes. Two types of daemon process: standalone daemon Transient daemon

Daemon Process
Standalone daemon are a program that run all the time and are started up either directly by init or by a startup script under /etc/rc.d.

Transient d T i t daemon are only started up when th l t t d h they are needed, and are controlled by a standalone daemon called xinetd.

checkconfig command
The chkconfig command can also be used to activate and deactivate services.

The chkconfig --list command displays a list of system services and whether they are started (on) or stopped (off) in runlevels 0-6 0 6.

At the end of the list is a section for the services managed by xinetd.

checkconfig command
chkconfig can also be used to configure a service to be started (or not) in a specific run level. For example, to turn httpd off in runlevels 3, 4, and 5, use the following command:

chkconfig --level 345 httpd off

checkconfig command

--list options used to list the service.

checkconfig command

--list option lists xinetd services also.

checkconfig command

--list option list --list options This command httpd service used to list httpd p status on p httpd service is service status . stop on runlevel runlevel 0-6. 3-5.

checkconfig command

--list options --list --add Now deletes options used --del optionshows sendmail service is not p tooptionsfor theto alladd a service, links used , there. creating links in list the httpd service in all defaults runlevels. service. runlevel directories.

Standard Boot loader


There are two standard boot loader are used in Linux GRUB Grand unified boot loader LILO Linux loader

GRUB
GRUB Grand Unified Boot Loader is a multi boot loader that operates similar to LILO and default boot loader for Redhat Linux. Using GRUB user can select operating systems to run from a menu interface displayed when a system boot up Supports MD5 password protection a boot menu protection, editing mode and a shell like command line interface available at b t ti il bl t boot time.

LILO
LILO means Li Linux l d loader LILO is a program written to boot sector of a disk that loads the OS and starts execution. It is an older version of boot loader of Red Hat Linux. LILO loads the Kernel based on its actual sector location on the disk , rather than its file name

LILO
/etc/lilo.conf lil -v lilo Configuration file To i t ll T install or update th lil d t the lilo boot loader. Test the configuration before installation. To restore the MBR backup.

lilo -t

lilo -u

Grubby

bootloader-probe : to show the a current boot loader.

Lilo installation
Check the presence of the lilo package.

lilo v installs lilo boot loader. b l d

Copy the lilo.conf.anaconda to lilo.conf (lilo ( configuration file).

Lilo installation

Thus the lilo boot l d b loader is installed.

This command displays p y the current boot loader, thus we can see the lilo got installed. installed

Lilo installation

Open the lilo configuration file.

Lilo installation
Before booting Specify which the OS it will Denotes the OS will be Prompt presents to wait for five first stage loaded by boot prompt seconds. boot loader. default. y without any user Locateslthea To di the display intervention. Boots second stage text message It specifies image. kernel the file boot loader. at boot time. that containdual Incase of dimages I f l to be boots it OS it loadedtheto initial RAM disk. other.

Lilo installation
Prompts the user for a password before booting this image. This will prompt for password only when we go to single user mode.

Lilo installation

This will update the lilo configuration file.

GRUB installation
/boot/grub/grub.conf This is configuration file for grub boot loader. grub-install /d /hd b i t ll /dev/hda To install the grub boot loader in hda device.

grubby bootloader-probe To show the current boot loader .

GRUB Configuration

Open the grub configurations file.

GRUB Configuration

Remove thi options to R this ti t The options rhgb quiet willboot through text start xserver while mode. booting.

Grub Configuration

Save the file and exit exit.

GRUB Configuration

Now b N reboot the h system.

GRUB Configuration

Now system is booting in text mode .

GRUB Configuration

Now system is booting in text mode .

GRUB Configuration

Now system is booting in text mode .

GRUB Configuration

Now system is booting in text mode .

GRUB Configuration

Now system is booting in text mode .

GRUB Configuration

Now system is booting in text mode .

GRUB Configuration

Now system is booting in text mode .

GRUB Configuration

Open the grub configurations file.

GRUB Configuration

The options rhgb quiet will start xserver while booting.

GRUB Configuration

Now b N reboot the h system.

GRUB Configuration

Now system is booting in graphical mode.

In EL-4 redhat-config-* tools are renamed as system-config-*.

GRUB installation
Now the boot loader is lilo.

To install grub loader use the command grub-install grub install /dev/hda .

GRUB installation
Open the grub configuratio n file.

GRUB installation
Label for first This representsdefault is If that to ItBoots the kernel loads the initial Flash screenthe be stanza. stanza following filesimage. ero are set di zero RAM toat boot disk. displayed ink5th partition of the then it boot hard disk on time. hd0. through first stanza. Loads the dual OS. Label for second stanza.

GRUB installation
To set password to the grub boot loader.

It gives us the encrypted format of the password. password This password is supposed to be entered in the grub.conf file. This can be done by the following method.

GRUB installation

Following the above command type the password two times, this will append the encrypted password to the grub.conf fil d h b f file.

GRUB installation

Open the O h configuration file.

GRUB installation

Here we can see the h appended p password.

GRUB installation

Just cut and copy the password here. Save the file and restart the system.

GRUB installation
Type p to enter grub b password if you Here you can see the want to go to single g grub loader prompting g user mode. for the OS to boot.

GRUB installation

Enter the password here.

GRUB installation

Change the command prompt to get in to single user mode to do that press e.

GRUB installation

Enter 1 to get in to run level 1.

GRUB installation

Press b to boot.

Red Hat Packet Manager g (rpm)

Using rpm command


rpm command is used to manage and install software packages. This command performs installation, removal and verification of software package package. Each package is actually an rpm packages. rpm consists of an archive of software file and

information to install. Each archive is resides as a single file with a name that ends with .rpm rpm

Using rpm command


rpm command is used either for installing or uninstalling package. Syntax: rpm [parameter] package name [options] parameter: (hyphen) -i i - Installs package package. -U - Updates package. -e - Remove a package. -qi - Di l i Displays i f information f an i t ll d ti for installed package. -ql - Displays file list for installed package. -qpi Displays information from an rpm package file. (used for uninstalled packages) -qpl - Displays file list from an rpm package file. (used for uninstalled packages)

Using rpm command


Options:

--force

Forces installation despite conflicts. p Install or remove without doing any dependency checks. p y Automatic dependency to install a package. (While available of package rpmdb-redhat aid option will work)

--nodeps --aid -

Querying the packing

rpm q a command for querying a particular package

Using rpm command


rpm q checks whether the above package is installed. installed rpm e command p will remove the http package.

Using rpm command

For installing the package we must the mount the operating system cd-rom of RHEL and then only we can install the packages.

Using rpm command

Go to Redhat directory. di

Using rpm command

Go to RPMS directory.

Using rpm command

List the files in RPMS directory and we can see that the packages end with an extension .rpm.

Using rpm command

rpm qpi shows the information about the package before installation.

Using rpm command


rpm qpl shows the list of files in a package k before installation.

Using rpm command

rpm ivh is p to install a package.

Using rpm command

rpm -Uvh to upgrade Uvh, a package.

Using rpm command

rpm qi shows the information about the package after p g installation.

Using rpm command


rpm ql shows ql the list of files in a package after installation. i t ll ti

To view an IP-address
Two methods available in linux to view the ip address ifconfig : -shows the ip address of the active interfaces with hardware address. -it can show ip address of a particular interface by taking the interface name as argument example: ifconfig eth0 ip a : - simply shows the ip address of all interface.

Ifconfig command

Displays information on all currently ll l active interfaces.

Ifconfig command

Here it displays the information of eth0 interface.

ip a command

Here it displays the information about all i f i b ll the interfaces.

ifup / ifdown command


Ifup: -ifup command is used to activate the interfaces. Syntax: ifup <interfacename> Ifdown: -ifdown command is used to deactivate the interface Syntax: ifdown <interfacename>

ifup / ifdown command

It deactivate the the interface eth0. eth0

ifup / ifdown command

Now you can notice the i h interface eth0 is f h0 i deactivated.

ifup / ifdown command

It activates the interface eth0.

ifup / ifdown command

Now you can notice the interface eth0 is activated.

Assigning ip address
In linux ip address can be assigned by the following methods. netconfig: - to assign permanent ip address to the interface Ifconfig: - to assign temporary ip address to the interface. Syntax: ifconfig <interfacename> <ipaddress> subnetmask <subnetmaskaddress> broadcast <broadcastaddress> Ip a a : - to assign additional ip address temporarily Syntax: ip a a <ip/subnetmaskaddress> dev <interfacename>

Assigning ip address

To assign permanent ip address using p g netconfig command.

Assigning ip address

Press yes to assign ip address. address

Assigning ip address

To assign ip address automatically from dhcp server.

Assigning ip address

To assign ip address manually manually.

Assigning ip address

ip a command shows th h the assigned ip address.

Using ifconfig command ip address can b dd be assigned.

Assigning ip address

As said earlier, ifconfig is used to sed assign ip address temporarily.

When network service is restarted, the ipaddress assigned through ifconfig to the device is removed.

Assigning ip address

To update ip address the network service is restarted. ip a command shows the assigned ip address.

Assigning ip address

ip address can be assigned temporary using ip a a command. command

Assigning ip address

Ip address can p be removed using ip a d command, once network service is i restarted it get di removed.

Router configuration

The ip_forward file is assigned 1 for enabling the router or 0 for disabling.( This process for temporary.)

To enable the router bl h in permanent way get into the sysct1.conf. y

The 1 is assigned to enable the router and this file is for setting router in permanent manner.

Gateway can be added using the command route add.

ping command
It is used to detect whether a system is up and running. Syntax: ping [options] <domainname> or ping [options] <ipaddress> Options: p a audible ping b to ping the broadcast address c stop sending packets after count. t di k t ft t

ping command

It checks whether www.example.com l is up and connected to the network.

ping command

It checks whether 192.168.0.253 machine is up and connected to p the network.

ping command

-b option used to ping a broadcast b d address.

ping command
-c options stops sending packets after the specified count.

LVM Structure

LVM structure In this structure the LVM physical partitions are also known as extents, are organized into logical groups, which are in turn used by logical volumes.

Physical volume
Physical volume:

It is nothing but hard disk partition that you create with partition creation tools such as parted or fdisk. p p The partitions type can be any standard Linux partitions t titi type, such as ext2 or ext3. h t2 t3

Volume groups
Physical volumes are organized into logical groups, y g g g p , known as Volume groups

Volume groups that operate much like logical hard disk. disk

You assign collection of physical volume to different logical groups.

Logical Volumes
A logical volume is a virtual partition.

One or more physical volumes to be combined in to volume group to construct logical volumes.

Logical volume can be created in logical groups.

It functions much like hard disk partitions on a standard setup.

lvm

LVM Configuration

Type p to check how Create partition many partitions using fdisk available in hard command disk

LVM Configuration
Here 4 partition is created with equal sizes of 100mb through n option option.

LVM Configuration
Newly created partition is listed below as hdb6,7,8 & 9.

To know t e o ow the partition id, use the option l.

LVM Configuration

Here 8e represent lvm partition id.

LVM Configuration
Here below after giving t option t the partition theis To change id changed to lvm We have to partition id as lvm i h id,mention the use T option. hex code of the partition p

LVM Configuration
Now partition id is changed to 8e(LVM)

LVM Configuration

We save the lvm p partition through g w option. Previous versions of redhat needed to restart system after creating partition. partition In current version to avoid restart we use partprobe.

LVM Configuration

Physical volume is Pvdisplay command created for lvm show the details of partition(hda6.7.8&9) physical volume

LVM Configuration

pvdisplay command displays the physical p y p y volume size.

LVM Configuration

Vgcreate creates vgdisplay command group as displays the test0 for lvm b titi information about i f l i partition hdb6 volume group test0.

LVM Configuration

lvcreate l create creates a logical volume and we assign name as data in the lvdisplay, test0 group displays the information about logical volume.

LVM Configuration
Make2fs, Make2fs creates an ext3 file system for data. (logical l (l i l volume) )

LVM Configuration

The logical volume data is mounted to /data directory. Open fstab file for permanently mounted the logical volume data.

LVM Configuration

See the content of fstab file.

LVM Configuration

Logical volume name is data is mounted on /data directory permanently .

LVM Configuration

Here we can see free space of logical volume data.

LVM Configuration

Create a big file of size g Here40mb in see there is we can /data directory. no free space available in /data directory .

LVM Configuration

If the space assigned to data is not sufficient, we can resize the logical volume .

Extend create filesystem for Now the logical volume size upto 45mb usingsing p the extended volume using e tended ol me g lvextend command. ext2online. After extending volume now we see the free space available in /data directory.

LVM Configuration

Here we can see only 12mb free space ia available in the volume group. group

LVM Configuration

Now the screen shows that test volume group is vgextend, vgextend extends Note that increased to 200mb. the space from the total allocated size for hdb7. the test0 group is 100 mb.

LVM Configuration
The above command shows the increased space of logical volume data. data

LVM Configuration

Extend the logical volume g size upto 50mb using lvextend command. Now create filesystem for the extended volume using e tended ol me sing ext2online. After extending volume now we see the free space available in /data directory.

LVM Configuration

We can remove logical volume first we must unmount the logical volume (/data directory).

LVM Configuration

Remove the mounted entry of logiacl volume (data) in fstab file

LVM Configuration

After removing logical volume save and exit the file.

LVM Configuration

After deactivated the We can the logical Removeremove volume group will be iremoved volume name is data lgroup first we must d t using vgremove decativate the volume using lvremove command. group using vgchange command. command. d

RAID
RAID means Redundant Arrays of Independent Disk. RAID is a method of storing data across several disks to provide greater performance and redundancy. In effect you can have several hard disks treated effect, as just as one hard disk by your operating system.

Types of RAID
RAID can be implemented on a

Hardware level or

Software level

Hardware RAID
On a hardware level, you can have hard disk connected to a RAID controller, usually a special PC card. d Your operating system can accesses storage though the RAID hardware controller.

Software RAID
You can implement RAID as software controller, letting a software RAID controller program. g g The controller program manage access to hard disks treated as RAID device. The software version lets you use IDE hard disks as RAID disk.

Software RAID Levels


RAID levels Capabilities Description Linear Appending Simply treat RAID hard drives as one virtual drive with no striping, mirroring.

Striping

Implements disk stripping across drives with no redundancy.

Mirroring

Implements a high level of redundancy. Each drive is treated as mirror for all data.

Distributed Parity

Implements data reconstruction capability using parity information. Parity information is distributed across all drives.

RAID

rpm -q command checks, whether the mdadm installed

RAID

The partition is created using fdisk command.

Now the screen lists the partitions. partitions

Raid Configuration

The partition is lists Now the screen created using the partitions. p fdisk command.

Raid Configuration
4 Partitions is created using n option with equal size of 100 mb

Raid Configuration
Now use p to p check created partitions.

The l option, lists the file system. The fd denotes linux raid

Raid Configuration

The l option, lists the option file system. The fd denotes linux raid

Raid Configuration
To set the partition p type use t options.

Raid Configuration

Option lists h O i p li the partition id and show the changes. g

Raid Configuration

We save the raid partition through w option. Previous versions of redhat needed to restart system after creating partition. In partition current version to avoid restart we use partprobe.

Raid Configuration

Using mdadm tool g creating raid level 5 it use four partition /dev/hda6,7,8&9 and creating raid device is /dev/md0.

Raid Configuration

Watch command shows the online status of raid devices.

Raid Configuration

Here we see status of each raid disk.

Raid Configuration

Creating ext3 file system for raid device /dev/md0 using mke2fs command.

Raid Configuration

Here we see the ext3 file system is created.

Raid Configuration

mdadm detail command show the detail information about the raid devices. devices

Raid Configuration

Here we see each Its show the raid raid disk major & disk status (weather minor no. . raid disk active or not active ).

Raid Configuration

Now raid device (/dev/md0) is mounted on /data directory.

Raid Configuration

Now raid device (/dev/md0) is i mounted on /data t d /d t directory in /etc/fstab file for permanently.

Raid Configuration

Now go to /data directory and create the file name is file1 using df command showdd command. free f & used space d for the raid devices & partitions.

Raid Configuration

Mdadm query command show the information about particular raid device & partitions. partitions

Raid Configuration

Raid Configuration

Mdadm manage command set fault or fail particular partitions Cat /proc/mdstat (/dev/hda9). command show disk the di k is failed. h disk i f il d

Raid Configuration

Here see mdadm detail command show disk /dev/hda9 is faulty.

Raid Configuration

Now remove the /dev/hda9 partition from the raid device /dev/md0 using Mdadm manage manage command .

Raid Configuration

Here you can see mdadm detail detail command show disk /dev/hda9 is removed.

Raid Configuration

Now add the /dev/hda9 partition from the raid device /dev/md0 using Mdadm manage manage command .

Raid Configuration

Watch command shows the online status of raid devices.

Raid Configuration

Here we can see the status of online synchronization of raid disks. disks

Raid Configuration

Now the faulty disk is replaced and we can see the data.

Raid Configuration

Here you can see mdadm detail detail command show disk /dev/hda9 is active.

Disk quota
Disk quota is used to control how much disk space a particular user can access. Quota tools: quotac ec quotacheck quotaon quotaoff edquota repquota

Quota tools
Quotacheck: It scans the file system for the current disk usage and update the aquota.user file. Quotaon: It turns on the quota. t th t Quotaoff It turns off the quota quota. Edquota: It is used to set disk quotas for a user. q Repquota: It displays summary of disk quotas and and the quota usage .

Implementing quota
To implement disk quota for an user, set the user quota for the home directory by replacing its defaults entry with usrquota in fstab file.

The following slides will guide you how to implement disk quota for particular user.

Implementing quota
Open th O the fstab file.

Implementing quota

Replace this defaults d f l as usrquota.

Implementing quota

Now usrquota is assigned to the /home directory. directory

Implementing quota
Here Remount thethat you can see the/h quota is not user di /home directory updated for the /home to update. directory.

Now you can see the user quota got assigned to /home directory

Implementing quota

Create quota database file named It aquota.user to hold checks the the quota information validity of quota for all users. database of the /home directory.

Implementing quota

Turn on the quota.

Implementing quota

Let us set disk quota for the user jack.

Implementing quota

To assign the q quota for the user jack.

Implementing quota

The maximum This soft To setwill just memory limit soft limit Blocks for a user. To set hard represents a spacethe inode . This will issue warning if he Inode representsfor disk deny the user to access, if limit for inode. of files exceeds soft limit. number and space in KB. he exceeds the quota limit. q directories can be accessed by the user.

Implementing quota

Here we set soft Here we set limit Here we set hardhard Here we set limit as 40 KB as 20limit as 50 KB soft limit as 15 inodes .so that memory space . usermemory space . inodes . can access only max of 20 inodes.

Implementing quota

It displays p y summary of disk usage. User jack has a hard User jack has a hard limit (file limit(block limits) of 50KB of 20 inodes and soft limits) and soft limit of 40 KB, he of 15 inodes , he already limit already used 10KB. used 10 inodes.

Implementing quota

User jack created five files without any warnings. But when he create sixth file a warning message is displayed. This indicates the user had exceeded the soft limit.

Implementing quota

Now, when the jack attempt to create more than ten files i.e., i e the eleventh file then write failed message occurs.

Implementing quota

Here jack use dd command to create a file named 1 of 30KB. Since the user exceeds the soft limits a warning messages i occurred. is d

Implementing quota

Here jack attempt to create a file named 2 of 10KB . But since, he has exceeded hard limit i f il d h d li i write failed error occurred.

Implementing quota

Here H we can notice that ti th t the jack had used all this quota. So he is restricted to create files.

mount command
Mount Used to mount a file system It takes two argument : the storage device d the d i and th mounting point. ti i t The device is a special device file that connects the system to the hardware device. Mounting point is directory on which the storage device is to be mounted.

mount command
Syntax: mount [options] <device> <mountpoint> Options: -w -r -t -a mount the file system with read/write permission. mount the file system with read permission. to specify the type of file system to be mounted. mounts all the file systems listed in /etc/fstab.

umount command
It un mounts the mounted file system. The removable media like floppy disk, and cd are un mounted after use, by using umount command.

Syntax: umount <mountpoint> mountpoint

mounting CD-ROM

To mount the CDROM on the mounting point /mnt/cdrom

mounting CD-ROM

Now we can access the CDROM contents from the mounting mo nting point.

Unmounting cd-rom

Unmount the CDROM after access

Unmounting cd-ROM

To eject the CD from the C f h CD Drive.

Mount /unmount floppy

To mount the floppy on the mounting point /mnt/floppy. ppy Unmount the floppy after access.

Mounting Hard drive partitions


To mount a hard drive partition p The hard disk partition also can be mounted like any other file systems. Example : mount t ext3 /dev/hda4 /mnt/data

Mounting Hard drive partitions

To mount the Mount command hard disk partition (hda3 of ext3 lists the mounted file system) in /data device. directory. directory

Mounting NFS
Mounting NFS (network file sharing) : Before mounting we must know the filesystem are exported by a e o e ou g e us o e esys e a e e po ed remote system. The following command is used to know the directory shared.

showmount e remote_server

When the host and share name are known, the following command is used to connected the network file system to the local file system tree

mount remoteserver:/shareddir /mnt/newdir1

Mounting NFS

Showmount command displays the shared directory on 192.168.0.253 machines 192 168 0 253 machines. .

Mounting NFS

We mount the el directory from remote machine into our /mnt o r directory .

Mounting NFS

Mount command shows information's about mounted devices.

Mounting NFS

umount command used to unmount remote machine directory.

Mounting smbfs

This command helps to p view windows shared files.

Mounting smbfs

The above screens displays window shared y directory.

Mounting smbfs

umount command used to unmount remote machine directory.

Auto mount
/etc/fstab: We can also mount the file system by placing mount information in this file. g y y Using entries in this file the file system can be automatically mounted whenever the system boots. It consists of six field per line for each file system as follows

<device> <mountpoint> <fs_type> <options> <dump_freq> <fsck_order>

Auto mount

Open the O h fstab file.

Auto mount

It represents file ItItrepresents the represents It represents the devices. devices thed Itoptions hsystems. mount dumprepresents different the frequency. fsck. for points. mounting the file system. y

Autofs
Autofs service mounts the file system automatically when the user access the mounting p g point. The autofs to supports the removable media without recurring the user to do any thing more than insert the media Autofs configurations file are /etc/auto.master /etc/auto.misc

Autofs configurations files


/etc/auto.master: This file specifies that a mount root of /misc will be used for a file systems and that mounts will time out after 60 seconds of inactive. inactive

/etc/auto.misc: The device to be mounted and the corresponding file system is configured in this file.

Autofs configurations files

Open the auto.master file.

Autofs configurations files

Mounting information s information's should be entered here.

Autofs configurations files

It file having This specifies when Map represents information's about to the mounting unmounted the point. theauto mountedto be file systems file mounted. system. d

Autofs configurations files

Open the auto.misc file.

Autofs configurations files

Mounting device information's are entered here.

Autofs configurations files

Key,represents file It ep ese ts the t the name t Ityrepresents ofe thesystem type. subdirectory device to be where the data mounted. can be accessed .

Autofs configurations files

Now autofs service is restarted.

Autofs configurations files

The contents of the cdrom is now available in the mounting point /mnt/cdrom/cd .

Autofs configurations files

As soon as we come out from /mnt/cdrom/cd the file system will get auto at ca y u ou ted automatically unmounted after 10 secounds.

Scheduling Task: cron


Cron Schedules one-time maintenance tasks. Cron is ideal for setting up jobs that execute regularly at specified ti ifi d times or i t intervals. l It contains a file which contains commands for cron setting cron, up and configuring jobs.

Creating cron
cron tab files are stored in /var/spool/cron. This fil i Thi file is accessed only b th root user, whereas th d l by the t h the other users cannot access. User can access this file by using crontab command.

Creating cron
syntax for crontab: crontab [option] t b [ ti ] Option : -e : edit the crontab file. -l : lists the content of the crontab. -r : remove the content in crontab.

Scheduling Task: cron

Root user has the privilege to open this file.

Scheduling Task: cron

Now open the fil h file.

Scheduling Task: cron


If any values is not represented , we can mention * First field Second This field files Comman represents field indicates, indicates d can be minutes(0 indicates the daythe daymonth of of given in hours(0-59). )( month (1 (1the (1(1-12) this12) field 23) week(0-6) 31)

The above command gets executed at 13 hours, 34 minutes as daily basis at same time.

Scheduling Task: cron

Chkconfig command enables the crond services in runlevel 345 in next boot time.

The Th service is i i restarted using service crond restart.

Scheduling Task: cron

Automatically hello message hello gets displayed in terminal.

Scheduling Task: cron


The permission is denied to the normal user joe when the user attempts to the file. file As said before the root user only has the privilege to access the file.

Scheduling Task: cron


The user can access the file, using crontab e e command.

Scheduling Task: cron

Now open the fil h file.

Scheduling Task: cron

The above command gets executed at 13 hours, 40 minutes as daily basis at same time.

Scheduling Task: cron

Crontab l command used to display content of crontab file.

Scheduling Task: cron

Automatically hello joe message gets displayed in terminal2. terminal2

DNS
DNS - Domain naming system. DNS service l i locates and t t d translates d l t domain names i into corresponding associated IP addresses. DNS configuration. It requires the following software packages to be installed. bi d bind Caching-name server bind-utils bind utils

Service profile
Packages bind, bind-utils, bind bind utils caching-nameserver Configuration files /etc/named/named.conf /var/named/named.local Daemons Port number named 53

DNS Configuration

Install bind-utils Install bind, des w c provides which p ov this package includes many utilities like web page manuals host, dig and and documentation nslookup Install cachingname server which provides a working named.conf configuration file

DNS Configuration

Open this file for mentioning the home directory for DNS.

DNS Configuration

Here DNS home directory is /var/named/chroot.

DNS Configuration

View the home directory files.

DNS Configuration

Open the configuration file named.conf.

DNS Configuration
Now you are seeing the contents of named.conf named conf file.

DNS Configuration
This file contains the ip Forward zone mapping address and between fully qualified the to particular ip domain locations of all the dot address. servers.

DNS Configuration

DNS Configuration
Enter the and paste the Copy py p forward file and reverse forward Enter the name. and edit them as zones domain follows. follows name here. Enter th E t the Enter the reverse IP address file name. in reverse order.

DNS Configuration

Save and exit d i the file

DNS Configuration

Copying the syntax file named.local to example.for and example.rev. example rev

DNS Configuration

Open the forward file.

DNS Configuration
Enter the fully qualified name of the name server. Enter the authorised Enter the fully name server for this of qualified name zone. host.

It is interpreted as the name of the originating domain.

Enter the last number segment of the host address in the reverse zone file.

DNS Configuration

Replace local host to fully qualified name using as given below. b l

DNS Configuration

Now the localhost is replaced as server1.example.com.

DNS Configuration

Canonical name, is used Enter the ip address for to define an alias for a p specified domain name. hostname. Set www as h t S t the cname for server1.example.com.

DNS Configuration

Open the example.rev file.

DNS Configuration

DNS Configuration

Replace localhost to server1.example.com using as below. g

DNS Configuration

Now the localhost is replaced by server1.example.com.

DNS Configuration

In a PTR record, you can specify just that last p yj number segment of the address.

DNS Configuration

Open the O h resolve.conf file.

DNS Configuration

Mention the nameserver ipaddress and domain name here.

DNS Configuration

Now named service is restarted.

DNS Configuration

Thus the DNS makes it possible to p ping an host by its domain name by resolving the domain name into IP address. address

DNS Configuration

Thus the DNS makes it possible to p ping an host by its domain name by resolving the domain name into IP address. address

DNS Configuration

dig di command shows ip d h i address of the specified fully-qualified domain name .

DNS Configuration

Nslookup is a dns diagnostic tool used to Using nslookup query a dns server. you can identifies nameserver for Using nslookup you can particular doamin. doamin identifies address for Using nslookup you can particular FQDN. identifies FQDN for particular IP address.

DNS Configuration

Thus the DNS makes it possible to ping an host by its domain name by resolving the domain name into IP address.

DNS Configuration

Thus the DNS makes it possible to ping an host by its domain name by resolving the domain name into IP address.

DNS Configuration

In client side open the /etc/resolv.conf /etc/resolv conf file.

DNS Configuration

Mention the nameserver ipaddress and domain name here.

DNS Configuration

Thus the DNS makes it possible to ping an host by its domain name by resolving b resol ing the domain name into IP address.

DNS Configuration

It shows the simple Using l k U i host,thus its lookup of nslookup you can identifies MX record show the corresponding for ip address to the p particular domain. specified fully quailed domain name. Using nslookup you can identifies nameserver for particular domain.

DNS Configuration

Open the forward file.

DNS Configuration

In this file we can add In this file we can add additional entry MX(mail y additional entry station105 exchange record ) and it h d d its machine and its corresponding ip address corresponding ip address 192.168.0.100. 192.168.0.100 192 168 0 100

DNS Configuration

Open the O h reverse file.

DNS Configuration

Similarly we can add another pointer record 105 for station105.example.com.

DNS Configuration

Now named service is i i restarted.

DNS Configuration

Using l k U i nslookup you can identifies MX record for Using nslookup you can particular domain. identifies address for particular FQDN. Using nslookup you can identifies id tifi PTR record for d f particular FQDN.

DNS Configuration

Open the O h configuration file named.conf.

DNS Configuration

Forward zone li the F d lists h name servers outside the network that should be searched when the networks name server fails. fails

Apache Web Server


Apache web server: Th Apache W b server i a f The A h Web is free HTTP (W b) (Web) server developed by the Apache Server Project. It is a reliable, efficient , and easily extensible Web Server Free open source code

Apache Web Server


Important di I directories and configuration files i d fi i fil

Service profile
Packages P k Configurations file Daemons Portnumber 80 httpd htt d /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd conf httpd p

Web server configuration

Query a httpd package whether installed or not but the screen shows httpd packages is not installed. installed

Web server configuration

Now query the httpd package is package itusing g installed show package is rpm command. installed.

Web server configuration

Open the h d O h httpd configuration file.

Web server configuration


You can see the first page file content, we content need to edit the end part of the, so press shift+G in command mode the cursor will bottom of p g page.

Web server configuration


This screen show end of httpd.conf file. Copy the last seven lines .

Web server configuration


Paste the copied lines here .

Web server configuration


In virtual host the e we Here specify field mail specif Here specifyor e-mail enter ipaddress the base fully Here specify thethe addressfrom which of the Now save directory and quit qualified domainyour hostname for administrator for thefile. the httpd.conf web p html files will be saved.. address. address server. saved server.

Web server configuration

After editing the configuration file The service httpd is restarted.

Web server configuration

Creating index.html page and place this file in the p /var/www/html/ directory.

Web server configuration

After typing save Let us create and quit h lfile. . the file htmlfile fil

Web server configuration

Open the mozilla web browser and type the fully qualified domain name in address bar and press enter, it will open corresponding web p g p g page.

Web server configuration

To allow only Directives that cana ect ves t at ca be particular user to access overridden by the entries Setting upwe our an .htaccess can add in web site file. /var/www/html/ access y directory session inside control directive . virtualhost session.

Web server configuration

Create .htaccess file in htaccess /var/www/html/ directory and open the file fil .

Web server configuration


The authorization realm is SelectsTypeauthenticated the of user g users the client so the given tothat can access a authentication for user knows which directory. only Basic and directory. username file contain listto Digest are currently This and password of send. send implemented. implemented d for users and passwords f d user authentication.

Web server configuration

Set the httpd password f the user d for h joe .

Web server configuration


httpd password is stored in htpasswd file.

Web server configuration

Set full permission for p the htpasswd file to make sure that the user has the execute permission .

Web server configuration

To add another user in the htpasswd file.

Web server configuration

Restart the httpd service.

Web server configuration

Enter the fully qualified domain name in address bar.

Web server configuration

When we access the web page the mozilla will prompts for the username and password. password

Web server configuration

Enter th E t the username and d the password.

Web server configuration

Now you can see the web page.

Access Control
The web access can be controlled by using access control directives such as allow and deny.
Directive deny from host host . Description Determines hosts that can access a given directory: all, or partial or full domain name or ip address. Determines which hosts can access a given directory: all, or partial or full domain name or ip address.

allow from host host .

Web server configuration

This indicates that we can access th web page the b from any network.

Web server configuration

To T access the web page th b only from the above specified network.

Virtual host
Virtual hosts allow you to host multiple domains from a single machine. Apache supports two different type of virtual hosts hosts. Name based Name-based virtual hosts Ip-based virtual hosts p

Ip and Named-based Virtual Hosts


IP-based virtual hosts -Ip-based virtual h t are used when a single I b d i t l hosts d h i l machine has several different IP address. -To run a virtual host on each IP address. Named-based virtual hosts -It allow you to host many virtual hosts from a single IP address.

Name-based virtual hosts

Here we place two Two domains are domains i the name ip d used inin a single of i i l i address and we can example and test.com place number of in a single ip address domains using single 192.168.0.20. IP address.

Name-based virtual hosts

An ip address is p mentioned in the virtualhost field.

Name-based virtual hosts

The server fully qualified domain name is described here.

Name-based virtual hosts

A Directory is created in the specified path as above here copy test.com webpage..

Name-based virtual hosts

Httpd Htt d service is i i restarted.

Name-based virtual hosts

This is the webpage for the t t th test.com .

Name-based virtual hosts

This is the webpage for example.com.

Proxy Server: Squid


Squid

It is the proxy caching server used in Linux Linux. Handles the request from the local clients for web access. It supports all popular internet protocols including FTP, Gopher ad HTTP.

Service profile
Packages Configuration files Daemons Port number Squid /etc/squid/squid.conf Squid 3128

Squid Configuration

Install the squid package. Open the squid configuration file.

Squid Configuration

This is the default squid configuration file if we want to change the defaults th d f lt then we can edit dit the file.

Squid Configuration

3128 is the http port.

Squid Configuration

Search for the acl access control list

Squid Configuration
Create another acl named thano1 t th 1 to restrict the web t i t th b access by time. Thus here the web server can be accessed during 18:30-19:30 only. The specified range of IP address are allowed to access the web server by assigning them in acl named thano.

Search for http_access in command mode. d d

Squid Configuration

This deny other IP addresses except the IP addresses mentioned in access lists To allow the access lists allo thano and thano1

Squid Configuration

Now N restart the h squid service.

Squid Configuration

To set the proxy get into the mozila wizard. wizard

Squid Configuration

Select preferences to set the proxy server. pro ser er

Squid Configuration

And l t th A d select the option ti proxies.

Squid Configuration

Enter the IP address of the proxy server and the port number. d h b

Squid Configuration

Now the time is in between the access time g given in the acl so we can access web server.

Squid Configuration

Here you can see that the access is denied since the we are not allowed to access the web server in this time time.

Apache Encrypted Web Server


Apache can provide encrypted communications using the mod_ssl apache module.

To make use of encrypted communications, a client must request the https protocol.

Encryption is based on either the RSA or DSA algorithm. algorithm

Apache Encrypted Web Server


Package Port P t number b Certificate Private key Self-signed cert g mod_ssl 443 conf/ssl.crt/server.crt conf/ssl crt/server crt conf/ssl.key/server.key conf/ssl key/server key make testcert make certreq

Certificate signature req -

Apache Encrypted Web Server

Q y Query is made to check whether the mod_ssl package is installed. not installed if not, install the packages

Apache Encrypted Web Server


To generate the certificate signature request.

Apache Encrypted Web Server


The self signed certificate can be installed using the command make testcert.

Apache Encrypted Web Server

When we restart the httpd service it will prompts for the password.

Apache Encrypted Web Server

Open the mozilla browser and type fully q qualified name in the address bar using https protocol.

Apache Encrypted Web Server

Click here to view the certificate.

Apache Encrypted Web Server


Here you can view the certificate informations.

Apache Encrypted Web Server

After examining accept the certificate temporarily or p y permanent and then click ok.

Apache Encrypted Web Server

You can see a warning message indicating that this page can not be read by a third party.

Apache Encrypted Web Server

Now you can access the web page securely.

Sendmail Configuration
Sendmail: Red Hat Linux uses S d il as it MTA t d li R d H t Li Sendmail its to deliver messages. It listens for any mail messages received from other hosts and address to user on the network host it serves. It handles the remote messages determining the host messages, to be sent.

Sendmail Service Profile


package configuration file - sendmail sendmail-cf sendmail, sendmail cf - /etc/mail/sendmail.mc

m4 macro config. file - /etc/mail/sendmail.cf demon service p port number sendmail

- 25(smtp),110(pop) ( p), (p p)

Sendmail Configuration

Query is made to check whether the sendmail package is installed. if not, install , the packages.

Sendmail Configuration

Installing packages using rpm command.

Sendmail Configuration

Open the sendmail O h d il configuration file .

Sendmail Configuration

Sendmail configuration file. fi i fil

Sendmail Configuration

Now e No we search for the text 127.0.0.1 .

Sendmail Configuration

The cursor finds the 127.0.0.0 127 0 0 0 (this line is default for mail transferring only for local host.

Sendmail Configuration

commentingi this li d i ti line The Th word dnl is added in d d l thidd voids to send of this the the beginning mail to line other systems to comment.

Sendmail Configuration

M4 is a macro language that can help to configure the th sendmail.cf file, using d il f fil i sendmail.mc

Sendmail Configuration

Open the Virtusertable file, for mapping user virtual domain addresses.

Sendmail Configuration

The virutusertable configuration helps to define the domain name along with fully qualified domain name.

Sendmail Configuration

Open a localO l l host-file.

You might also like