index

Units:
unit-1 unit-2 unit-3 unit-4 unit-5 unit-6 unit-7 unit-8 unit-9 unit-10 About the founder of Linux. Linux VS Windows. Linux Flavors. Introduction to Redhat 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 Linux, an operating 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. •Tux, is a chubby penguin that looks content and satisfied. •The concept of the Linux mascot being a penguin came from Linus Torvalds, the creator of the Linux kernel.

GNU’s (Not Unix)
• The GNU project was started in 1983 for developing a complete Unix-like operating system, including software development 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 programs to create a fully functional operating system.

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

Linux

Vs

Windows

Open Source Development ModelIt is not an open source and hence and so the programmer can redesigncannot be redesigned by the the OS. programmer. Linux is robust and very much secureWindows gets affected by virus very from virus. easily. The Linux servers has surpassedSecurity is the main issue which has windows server operating system inmade windows to think to survive. security. It costs less to design and implementIt costs more to implement Windows a Linux Network. Network administration, when compared to Linux. There are 250000+ developers behindCompared to Linux, windows is Linux for open source deployment. developed by few thousands of people.

Linux Flavors
• Red Hat Linux (Red Hat) • Fedora Linux • Open Linux (Caldera) • SuSE Linux (Novell) • Mandrake Linux (Mandrake) • Turbo Linux (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. • The Fedora project is an open source initiative whose Fedora Core release will be issued every six months.

Kernel
• The kernel is the essential center of a computer 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 than in IBM mainframe or Microsoft 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 at UC Berkeley • C shell (csh) – Added many features such as command, history and job control
Continue…

Shells
• Korn Shell (Ksh) – Written by David Korn • Implemented many csh features such as command completion and history

• The Enhanced C shell (tcsh) –a community effort • 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 cshell (csh)

Shells

command prompt for enhanced C 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 Action ls -l ls –R cd mkdir rmdir pwd rm List directory contents List directory recursively Change directory Make a new directory Remove a directory Display directory location Remove a file

DOS Vs Linux
DOS Command RMDIR /S (NT) DELTREE (Win 95...) COPY XCOPY RENAME or MOVE TYPE MORE HELP or COMMAND /? LINUX Command rm -r Action 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

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) Sort data alphabetically/numerically Edit a file. The Linux editor which looks most like DOS edit is probably Pico. Directory path delimiter Current directory Parent directory

vim / ./ ../

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

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 (Command borrowed from AIX)

ATTRIB +h or -h PRINT MEM

mv file .file lpr free top lsdev

MSD

DOS Vs Linux
DOS Command SCANDISK DEFRAG C: FDISK LINUX Command Action fsck Check and repair hard drive file system

fdisk mke2fs See: fdformat for floppy uname -a tar, gzip and bzip2 hostname

Tool to partition a hard drive. 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

FORMAT

VER

pkzip

HOSTNAME

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

TRACERT

traceroute

IPCONFIG (NT) WINIPCFG (Win 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.

route -n

Print routing table.

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

TRACERT

traceroute

IPCONFIG (NT) WINIPCFG (Win 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.

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. 400 MHz Pentium is recommended for a graphical interface and 200 MHz for text. Normally 64MB RAM for Text, and 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 have to change the boot sequence setting in your computer’s 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 share 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 to interact with the system. • 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.

Red Hat Installation

Type linux text, to install in Text mode.

Red Hat Installation

Type linux askm to install either th FTP, HTTP, Har and NFS.

Red Hat Installation

Type linux text askmethod to install either through FTP, 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.

Redhat Installations

Select the type of keyboard layout.

Redhat Installations

Select the appropriate type of installation.

Redhat Installations

Select the appropriate NFS type 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.

Redhat Installations

The AnacondaRed Hat Installer begins the Installation.

Redhat Installations

Hardware detection process

Redhat Installations

Redhat Installations

The Red Hat Linux Welcomes you.

Select the Partitioning Type

Select this for simpler automatic 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 for normal partition and swap for swap partition) Enter the size of the partitions here.

Creating Partition for / directory

Enter the mount points here.( / )

Select the file system type here.( ext2, ext3 for normal partition and swap for swap partition) Enter the size of the partitions here.

Creating Partition for swap directory

Enter the mount points here.(swap)

Enter the size of the partitions here.

Redhat Installations

The final view all the mounting point.

To Set Boot Loader
Click here to change the default boot loader

GRUB and LILO 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 to your machine No firewall option allows all network services to your machine

Redhat Installations

Activate your SELINUX options

Enable firewall 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.

Redhat Installations

Enter the password for the root (Super User)

Redhat Installations
Its reading package information's.

Redhat Installations
Select customize This is used to select options to customize the default package. the package selections

Package Selection

The Packages to be installed are selected 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.

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 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 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 your monitor and display card

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

Red Hat Login

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

Red Hat Login

If you don’t 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 registers the machine with Red Hat network So that the latest Software packages Get updated automatically

Click here to register with the Red Hat network

Click here to skip registration

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 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 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. • Device detection: kernel will compile 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 passed from kernel to this process.

• /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.

Run levels
init 0 : Shutdown the system or halt init 1 : Single-user mode. init 2 : Multi-user mode with out networking support. init 3 : Multi-user mode with networking support. init 4 : Unused. init 5 : Graphical user 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. • 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. 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. • Along with GNOME features, It also includes • • • • Konsole Konqueror Kmail Kdevelop : Highly configurable graphical terminal. : A file manager and web 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.

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

Start X

To get in to X window from run level-3

Start X

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

To get in to GNOME desktop.

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

If you click No, only 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 into GNOME desktop

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 user’s home directories. Holds administration-level commands commands used by the root user. and any

Holds file interface for devices such as the terminal and the printer. Holds system configuration files and any other system files. Holds system configuration files for application in /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 programs. Holds essential shared libraries and kernel modules.

/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, KDE on some distributions).

/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. 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.

/tmp /usr

/var

Linux Commands
• Commands have the following syntax: • Command [options] [arguments] • Each item is separated by space • Options modify the command’s 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 Action 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 file

DOS Vs Linux
DOS Command RMDIR /S (NT) DELTREE (Win 95...) COPY XCOPY RENAME or MOVE TYPE MORE HELP or COMMAND/? LINUX Command rm -r Action 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

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) Sort data alphabetically/numerically Edit a file. The Linux editor which looks most like DOS edit is probably Pico. Directory path delimiter Current directory Parent directory

vim / ./ ../

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

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 (Command borrowed from AIX)

ATTRIB +h or -h PRINT MEM

mv file .file lpr free top lsdev

MSD

DOS Vs Linux
DOS Command SCANDISK DEFRAG C: FDISK LINUX Command Action fsck Check and repair hard drive file system

fdisk mke2fs See: fdformat for floppy uname -a tar, gzip and bzip2 hostname

Tool to partition a hard drive. 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 compilation of a directory before compressing. Linux also has compress, gzip Print host name of computer

FORMAT

VER

pkzip

HOSTNAME

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

TRACERT

traceroute

IPCONFIG (NT) WINIPCFG (Win 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.

route -n

Print routing table.

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

TRACERT

traceroute

IPCONFIG (NT) WINIPCFG (Win 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.

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 List file with permission.

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

-R List directories , sub directories and their

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 No ofname of the group links to the Owner name, Thepermissionsthe directory the user who created which to assigned hasthe Time stamp or the directory. permissions over the owners, groups and Size of theFile files files or directories directory other users or directories names.

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.

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

Syntax : mkdir <dirname>

mkdir

This will create a directory 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

To the / (slash) directory

cd

This command will take you to the directory .

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

cd ..

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

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

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 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]  To append text to a file

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

cat
Enter cat <filename> 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 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 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

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

Copy Command
There is a file named ‘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.

Copy Command
Cp copies the file ‘a’ from the directory 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.

Copy Command

-r option copy the entire directory tree ‘old’

Copy Command

Thus the contents of old directory is copied to new directory.

Copy Command

Command l l shows the permission of the file

Copy Command

Using chmod, 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 permission is preserved.

Move Command
mv : This command is used to move and renaming files and 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

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

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 <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

rmdir command

The above screen shows that directory donic is removed

rmdir command

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

rm command

Using rm with 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’ 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 block special file) a

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

more

l l command shows the contents at 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 by one

more

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

more

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

more
Now the more command is over and 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 Vi have three modes of operation •Command mode •Insert mode •Esc mode

vi Modes
Command mode: Operations such as cut, copy, paste, delete, undo, redo etc., are done in this mode. Insert mode: Type in new text 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 data’s hit escape to get into command mode

Ex- Mode

Press :wq to write and quit

Ex- Mode

Press 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 to yank three lines from the cursor position

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 cursor position 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 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 data to be searched and press enter

Search

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

Search

Then if we press ‘n’ it will shows the second match for that data.If we continue 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.

Find command

This command searches the password 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: locate [pattern]

Locate command

To search file named test1 from database.

Locate command

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

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

Man command

It displays manual pages for ls command.

Man command
The manual page of ls command is displayed here.

Enter q to exit from manual page.

useradd command
useradd : To create a new user account and login directory for that new 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.

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.

- /etc/passwd - /etc/group - /etc/shadow

Passwd file
To view password configuration file.

Passwd file

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

User login User home shell. directory.

Shadow file

To view shadow file.

Shadow file
Encrypted password for the user 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

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 assigned to the group 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

User’s 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 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. So the permission is restricted.

Group Administration

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

Group Administration

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

Group Administration

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

Group Administration

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

Changing owner

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

Changing owner

The owner and group name can be change using 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. -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 expiration.

User administration

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

Chagefield lists This –l : sets the account and the password for password the maximum information of valid 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 of days a user can exists with password.

User administration
The -E option is 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 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.

Set userID

Tom changes the password using passwd command.

Set userID

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

Set userID

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

Set GroupID

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

The user suresh logs get into the product directory and create a file.

Set GroupID

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

The groupid is set to the product directory.

Set GroupID

After setting the group id, user suresh creates a file win98. Using the command ls –l shows that the file is created under the group sales.

Sticky bit

The files remove is possible 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 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.

Switch user
su command is used to switch to another account from the command line. This command is most often used by system administrator to temporarily become the root user without logging out of their 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.

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

Each user can login in each terminal and can do multi processing which avoids logging off from the 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 terminal

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

W is the command to list the users logged in

Advanced 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. 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 Ctrl+u, Cursor go up half a screen.

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 command help you : – 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 – Syntax : starting line, endingline w <file name> – Example : 1,20w file2 – Example : 21,40w >> file2

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 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.

Example of Sed command . sed ‘s/ram/raju/g’ /root/file1

Sed Command

The output of the named.local is 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 sed command. Syntax: ex mode:1,$s/searchname/replacename/g 1,$ - address starting from line 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 the localhost as www.example.com.

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 file content to another file – Syntax : starting line, ending line w <file name> – Example : 1,20w file2 – Example : 21,40w >> file2

Advanced Reading and Saving

Here you can view 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 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 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

Redirecting Input and Output
The output of ls command is redirected to the Here the file file named ex.is overwritten by the output of ls command.

Redirecting Input and Output

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

Redirecting Input and Output

Here the output of ls command is appended to the 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 in capital letters, which is redirected through < symbol and the command translates the data to small letters.

Redirecting Input and Output

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

Redirecting Input and Output
2> redirects the error messages to the ex file.

Here we can see redirected error messages in the ex 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 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 example: find / -name passwd 2> file1 >file2

Redirecting Both Standard Output And Error

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

If there is no error the output will be redirected to the ex2 file.

tee Command
tee is useful to save the output at various stages from a long sequence of pipes. Example: ls | tee a1 | ls –l | tee b2 The above example shows the types of ls commands 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 the content of a file a line at a 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.

Example: awk ‘/bash/ { print }’ /etc/passwd

awk command

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

File Compressions
Several compression utilities are available for use on 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 Syntax: compress <filename> uncompress: It uncompress the compressed file. Syntax: uncompress <filename> .z for that file.

Compression command
The actual size of file is This 107 bytes. compresses the file a. The compressed file is indicated by the .z extension. Thus the file size is compressed to 39 bytes.

This uncompress the file a.

Compression with gzip
gzip utility compresses file . gunzip decompresses them. 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. Syntax: gzip filename (compression) 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 indicated by the .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. 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 indicated by the .bz2 extension. Thus the file size is compressed to 51 bytes.

This uncompress the file a .

Creating Archives
Tar: tar command is used to create archives on device or files. Originally, tar was used to create archives on tape devices, hence its name stands for tape archive. When creating a file for a tar archive, the filename is usually given the extension .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 Options: c - create new archive. 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 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 file back using xvf options .

Printer-configuration

Printer-configuration
Command to configure the Printer

Click New option to add printer

Printer-configuration

Now the system is loading printer information.

Printer-configuration

Click Forward option to add printer queue

Printer-configuration

Choose locally-connected option for local 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

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 queue in printer

Printer-configuration

lpq is a command to view the number of queue in printer

Introduction to process
Linux treats each task performed on your system as a process, which is assigned a number and 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 process is easy monitoring is provided by several GUI tools,like Red Hat Procman System Monitor.

ps Command
• • ps command is used to list the 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 display all process, not 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 process ancestry for all process running on the system.

ps –a command
Display all processes excluding processes not controlled by this terminal..

ps –l command

It list the processes along with the owners id.

ps –x command
Display all processes including processes controlled by this 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> • ps - aux is the command to view all process name and id • Example: kill -9 3743 (This example shows the kill command, option and the process id to kill.)

kill process

It kills the tty2 terminal bash 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)

• Syntax : renice - +(minus symbol or plus symbol) <priority number> -p <process id>

• Example : renice -15 -p 1970

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 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 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 – • • • • • For example: #!/bin/bash  used for bash shell script #!/bin/sh  used for borne shell script

#!/bin/csh  used for C shell script #!/usr/bin/perl  used for Perl shell script

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

Basic bash shell script
How to print a data in a console – echo “Red hat” <enter>

How to execute a command in echo statement – echo “hostname `hostname` “ <enter> 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 vi editor to create script file

Bash Shell Scripting
It denotes we are using bash shell scripts

This script executes the system hostname and date

Executing script - First Method
Bash example (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, as executable

Second Method

./ example (file name) to execute the file

Arithmetic Calculation

Example script file for calculation

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

Using expr we can add values

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 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. 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 – 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 Starting and the Available partitions, Size of ending Star cylinder for each indicates hdb represents thatthe boot the partitions in blocks hard disk is connectedpartition one partition. = 8.3MB as 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 cylinder or just Type n to create a press enter to take new partition the default cylinder

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

Partitioning with fdisk
Instead of restarting to update the partition table 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. - ext2 - ext3 - minux - reiserFS (under research)

ext filesystems
ext : Extended 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 file system containing many small files and large directories

Creating file system
Once you create a partition, you have to create a file system on it. To do this, use the mkfs command. To build the Linux file system and pass the name of the harddisk partition as a parameter. 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. Syntax : 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 (it will create ext3 filesystem for hda1 partition)

Creation of file system

It creates ext2 file systems for device hdb7.

View the file system type

Sparse_super 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 partitions Mount the Linux, like any other device the hda6 in data1 partitions should directory and hda7 in be 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 file system checking tools. Example : e2fsck /dev/hda1 fsck : This command checks and repair a Linux file 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.

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.

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 size in the power 1000 instead of 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.

Performance tools
free command lists the free ram memory and as well as what is used for buffers and swap 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 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

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 daemon are only started up when 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.

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 httpd service is status on 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 tooptionsfor theto alladd a service, links used not there.httpd creating links in list the service in all defaultsdirectories. runlevels. runlevelservice.

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 editing mode and a shell like command line interface available at boot time.

LILO
• LILO means Linux 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 • lilo -v Configuration file To install or update 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.

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

Lilo installation

Thus the lilo boot loader is installed.

This command displays the current boot loader, thus we can see the lilo got 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. without any user Locates thea To display intervention. Boots the second stage text message It specifies image. kernel the file boot loader. at that boot time. Incasecontain of dual images to be OS it boots the loaded it to initial other. RAM disk.

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 /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 this options The options rhgb quiet to boot through text will start xserver mode. while booting.

Grub Configuration

Save the file and exit.

GRUB Configuration

Now reboot the 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 reboot the 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 /dev/hda .

GRUB installation
Open the grub configuration file.

GRUB installation
Label the This representsdefault to If thatfor ItBoots the kernel loads the initial Flash screen is following be first toin 5th filesimage. at are zero set stanza. RAM disk. displayed partition of the hard boot then it disk boot time. on 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. 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 file.

GRUB installation

Open the configuration file.

GRUB installation

Here we can see the appended password.

GRUB installation

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

GRUB installation
Type p to enter grub see the Here you canpassword if you want to go grub loader prompting to for thesingle user mode. 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 (rpm)

Using rpm command
• rpm command is used to manage and install software packages. • This command performs installation, removal and verification of software 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

Using rpm command
rpm command is used either for installing or uninstalling package. Syntax: rpm [parameter] package name [options] parameter: (hyphen) -i - Installs package. -U - Updates package. -e - Remove a package. -qi Displays information for an 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. Install or remove without doing any dependency checks. 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. rpm –e command 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.

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 before installation.

Using rpm command

rpm –ivh is to install a package.

Using rpm command

rpm -Uvh, to upgrade a package.

Using rpm command

rpm –qi shows the information about the package after installation.

Using rpm command
rpm –ql shows the list of files in a package after installation.

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 active interfaces.

Ifconfig command

Here it displays the information of eth0 interface.

ip a command

Here it displays the information about all 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.

ifup / ifdown command

Now you can notice the interface eth0 is 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 netconfig command.

Assigning ip address

Press yes to assign ip address.

Assigning ip address

To assign ip address automatically from dhcp server.

Assigning ip address

To assign ip address manually.

Assigning ip address

ip a command shows the assigned ip address.

Using ifconfig command ip address can be assigned.

Assigning ip address

As said earlier, ifconfig is used to 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.

Assigning ip address

Ip address can be removed using ip a d command, once network service is restarted it get 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 in permanent way get into the sysct1.conf.

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: a audible ping b to ping the broadcast address c stop sending packets after count.

ping command

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

ping command

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

ping command

-b option used to ping a broadcast 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. • The partitions type can be any standard Linux partitions type, such as ext2 or ext3.

Volume groups
• Physical volumes are organized into logical groups, known as Volume groups

• Volume groups that operate much like logical hard 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 Create partition how many using fdisk partitions available command in hard disk

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

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

To know the partition id, use the option l.

LVM Configuration

Here 8e represent lvm partition id.

LVM Configuration
Here below after giving ‘t’ option the partition id is To change the changed to lvm We have to partition id as lvm id,mention the use T option. hex code of the partition

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

LVM Configuration

We save the lvm partition through w option. Previous versions of redhat needed to restart system after creating 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 volume size.

LVM Configuration

Vgcreate creates vgdisplay command group as displays the test0 for lvm partition information about hdb6 volume group test0.

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

LVM Configuration
Make2fs, creates an ext3 file system for data. (logical 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 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 using the extended volume using 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.

LVM Configuration

Now the screen shows that test volume group is 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.

LVM Configuration

Extend the logical volume size upto 50mb using lvextend command. Now create filesystem for the extended volume using 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 Remove remove volume group will be we must group first removed volume name is data using vgremove decativate the volume using lvremove command. group using vgchange command. command.

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 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. • 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. • 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.

0

Striping

Implements disk stripping across drives with no redundancy.

1

Mirroring

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

5

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.

Raid Configuration

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

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

Raid Configuration
Now use ‘p’ to check created partitions.

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

Raid Configuration

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

Raid Configuration
To set the partition type use t options.

Raid Configuration
Option p lists the partition id and show the changes.

Raid Configuration

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

Raid Configuration

Using mdadm tool 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.

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 mounted on /data directory in /etc/fstab file for permanently.

Raid Configuration

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

Raid Configuration

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

Raid Configuration

Raid Configuration

Mdadm – manage command set fault or fail particular Cat /proc/mdstat partitions (/dev/hda9). command show disk the disk is failed.

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 command .

Raid Configuration

Here you can see mdadm –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 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.

Raid Configuration

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

Raid Configuration

Here you can see mdadm –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: 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. Quotaoff It turns off the quota. Edquota: It is used to set disk quotas for a user. 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 the fstab file.

Implementing quota

Replace this defaults as usrquota.

Implementing quota

Now usrquota is assigned to the /home directory.

Implementing quota
Here Remountsee that you can the the/home directory user quota is not 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 validity of quota information database of the for all users. /home directory.

Implementing quota

Turn on the quota.

Implementing quota
Let us set disk quota for the user jack.

Implementing quota

To assign the quota for the user jack.

Implementing quota

The maximum This soft To set soft memory limit will Blocks for a user. This will space just To set Inode representsissue a warning if hard limit represents disk for the access, if deny thelimit. to he exceeds soft user limit for inode. of files and number . space in KB.inodethe quota limit. he exceeds 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 limit as 50 KB soft as 20 inodes .so that limit as 15 memory space . usermemory space . inodes . can access only max of 20 inodes.

Implementing quota

It displays summary of disk usage. User jack has a hard User jack has a hard limit limit(block limits) of 50KB limits) of 20 inodes and (file and soft limit of 40 KB, he limit of 15 inodes , he soft already used 10KB. already 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., 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 is occurred.

Implementing quota

Here jack attempt to create a file named ‘2’ of 10KB . But since, he has exceeded hard limit write failed error occurred.

Implementing quota

Here we can notice that 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 and the mounting point. 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>

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 point.

Unmounting cd-rom

Unmount the CDROM after access

Unmounting cd-ROM

To eject the CD from the CD Drive.

Mount /unmount floppy

Unmount the floppy after access.

To mount the floppy on the mounting point /mnt/floppy.

Mounting Hard drive partitions
To mount a hard drive partition 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.

Mounting NFS
Mounting NFS (network file sharing) : – Before mounting we must know the filesystem are exported by a 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. .

Mounting NFS

We mount the el directory from remote machine into our /mnt 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 view windows shared files.

Mounting smbfs

The above screens displays window shared 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. 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 fstab file.

Auto mount

It represents Itrepresents It Itrepresents represents the devices. It represents file mount the systems. the dump different options the frequency. fsck. forpoints. mounting the file system.

Autofs
Autofs service mounts the file system automatically when the user access the mounting 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.

/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 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.

Autofs configurations files

Open the auto.misc file.

Autofs configurations files

Mounting device information's are entered here.

Autofs configurations files

Key, the name file It represents It represents of thethe device to subdirectory system type. where the data be 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 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 times or intervals. It contains a file which contains commands for cron, setting up and configuring jobs.

Creating cron
cron tab files are stored in /var/spool/cron. This file is accessed only by the root user, whereas the other users cannot access. User can access this file by using crontab command.

Creating cron
syntax for crontab: crontab [option] 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 file.

Scheduling Task: cron
If any values is not represented, we can mention * First field Second This field files Command represents fieldbe indicates indicates, can minutes(0 indicates the month day daythe of of given in -59). hours(0the month (1(1-12) this 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 service is restarted using service crond restart.

Scheduling Task: cron

Automatically “hello” message gets displayed in terminal.

Scheduling Task: cron
The permission is denied to the normal user joe when the user attempts to the 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 command.

Scheduling Task: cron

Now open the 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.

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

Service profile
Packages 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, this which provides 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 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 forward file and reverse forward Enter the name. and edit them as zones domain follows. name here. Enter the Enter the reverse IP address file name. in reverse order.

DNS Configuration

Save and exit the file

DNS Configuration

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

DNS Configuration

Open the forward file.

DNS Configuration
Enter the fully qualified name of It is interpreted as the name server. the name of the originating Enter the authorised Enter the fully domain. name server for this of qualified name zone. host. 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.

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 specified domain name. hostname. Set www as 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.

DNS Configuration

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

DNS Configuration

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

DNS Configuration

Open the 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 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

dig command shows ip 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. 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 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 the domain name into IP address.

DNS Configuration

It shows the simple Using host,thus its lookup of nslookup you can identifies MX record show the corresponding for particular domain. ip address to the 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 weadditional entry MX(mail can add additional entry station105record ) and its exchange machine and its corresponding ip address corresponding ip address 192.168.0.100. 192.168.0.100

DNS Configuration

Open the reverse file.

DNS Configuration

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

DNS Configuration

Now named service is restarted.

DNS Configuration

Using nslookup you can identifies MX record for Using nslookup you can particular domain. identifies address for particular FQDN. Using nslookup you can identifies PTR record for particular FQDN.

DNS Configuration

Open the configuration file named.conf.

DNS Configuration

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

Apache Web Server
• Apache web server: • The Apache Web server is a free HTTP (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 directories and configuration files

Service profile
Packages Configurations file Daemons Portnumber 80 httpd /etc/httpd/conf/httpd.conf httpd

Web server configuration

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

Web server configuration

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

Web server configuration

Open the httpd configuration file.

Web server configuration
You can see the first page file content, we need to edit the end part of the, so press shift+G in command mode the cursor will bottom of 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-mail Here specify field we Here specify the base enter ipaddress or fully Here specify address of and the Now save the quit directory from which qualified domainthe hostname administratorwill your the address. for befile. the httpd.conf html files server. web server. saved..

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 /var/www/html/ directory.

Web server configuration

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

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 page.

Web server configuration

To allow only Directives that canabe particular user tothe overridden by access Setting site we can our webup.htaccess entries in an /var/www/html/ access add directory session file. control directive . inside virtualhost session.

Web server configuration

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

Web server configuration
The authorization realm Type of the Selects user is given to the users that authentication for authenticated client so the user knows which directory. only Basic can access a directory. username and password of and Digest contain list This file are currently implemented. for users to send. and passwords user authentication.

Web server configuration

Set the httpd password for the user joe .

Web server configuration
httpd password is stored in htpasswd file.

Web server configuration

Set full permission for 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.

Web server configuration

Enter the username and 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 the web page from any network.

Web server configuration

To access the web page 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. Name-based virtual hosts Ip-based virtual hosts

Ip and Named-based Virtual Hosts
IP-based virtual hosts -Ip-based virtual hosts are used when a single 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 in a single of used in the name ip 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 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 service is restarted.

Name-based virtual hosts

This is the webpage for the 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. 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 then we can edit 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 to restrict the web 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.

Squid Configuration

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

Squid Configuration

Now restart the squid service.

Squid Configuration

To set the proxy get into the mozila wizard.

Squid Configuration

Select preferences to set the proxy server.

Squid Configuration

And select the option proxies.

Squid Configuration

Enter the IP address of the proxy server and the port number.

Squid Configuration

Now the time is in between the access time 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.

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.

Apache Encrypted Web Server
Package Port number Certificate Private key Self-signed cert mod_ssl 443 conf/ssl.crt/server.crt conf/ssl.key/server.key make testcert make certreq

Certificate signature req -

Apache Encrypted Web Server

Query is made to check whether the mod_ssl package is 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 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 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 Sendmail as its MTA 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 to be sent.

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

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

- 25(smtp),110(pop)

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 configuration file .

Sendmail Configuration

Sendmail configuration file.

Sendmail Configuration

Now we search for the text 127.0.0.1 .

Sendmail Configuration

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

Sendmail Configuration

commenting this line The word dnl is added in 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 sendmail.cf file, using 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 localhost-file.

Sign up to vote on this title
UsefulNot useful