You are on page 1of 27

/************************* PRACTICAL NO.

1 ***********************/

Aim: ~ Familiarize with UNIX / Linux logging / logout and


simple commands.
Theory: ~
Unix is one of the most popular multi user, timesharing operating system. It is a
product of AT & Ts Bell Laboratory. Ken Thompson of the research group at AT &
Ts Bell Laboratory, later joined by Dennis Ritchie, in the late 1960s developed the
first version of UNIX. The first version of UNIX was a single user system for the
PDP 7 and was written in assembly language. Because of written in assembly
language one of the major limitation of the UNIX operating system is its portability.
To overcome this problem Ken Thompson designed a new language B in 1970. The
B language was a simplified version of another high level language BCPL
designed by Martin Richards at Cambridge University. But unfortunately B was
too specific and could deal with only specific problems. After this Ritchie designed
another new language C in 1972 by inheriting the feature of B and BCPL and
added some of his own features. After the development of C language, both Denis
Ritchie and Ken Thompson write the major portion of UNIX (90%) in C language.
After that the problem of portability in UNIX is removed. Many features of UNIX
such as file system, command interpreter (the shell) as a user process, the use of
separate process for each command, and many other features came directly from
MULTICS (Multiplexed Information and Computing Services).. The initial
spelling of this system is UNICS (Uniplexed Information and Computing
Services). After some days, the spelling of UNICS was modified to UNIX.

Log in: ~
When you startup your system, the very first line that you see on your monitor is
Login:
This line means that the UNIX system is ready for you to login. Each user is given a
login name, also referred as user id. After entering your login name to the login:
prompt, the UNIX system prompts you to enter the password as:
Password:
Now you have to enter your password. Like user id, each user is given a unique
password. It is your password that allows you to use this user id. Your password
may be selected either by system administrator or by you. In either case, it is the
password by which the system recognizes that you are an authorized user to use this
user id. After accepting the correct login name and password some kind of welcome
message is printed on the screen. For example:
Login: User 1
Password: punit
Mon Oct 11 07:10:10
ISP 1999
*** Good Morning ***

This means it is ready to accept your command. The command prompt is $, if you are
working in Bourne Shell or a % if it is a C shell.

Log Out: ~
To end a UNIX session, you must log out. You should not end a session by just
turning off your terminal! To log out, enter the command exit. (In many cases, the
command logout will also work.) Depending on your shell, you may also be able to
log out by typing [CTRL-D].
What happens next depends on the place from which you've logged in:

If your terminal is connected directly to the computer, the "login:" prompt


should appear on the screen.
If you're using a window system, the window will probably close. If you have
additional windows open, you'll need to log out or close them, too. You may
also need to terminate the window system itself.
If you were connected to a remote computer, the system prompt from your
local computer should reappear on your screen. (That is, you're still logged in
to your local computer.) Repeat the process if you want to log out from the
local computer.
After you've logged out, you can turn off your terminal or leave it on for the next user.

Simple commands:
(1)

The date Command: ~


The date command is used to display the current date and time.
$ date
Mon Oct 1107:17
ISP 1999
$
You can also modify the format of date command by using the date command
as:
$ date + Day: %d %n Month: %m %n Year: %y
Day: 11
Month: Oct
Year: 1999

(2)

The who Command: ~


The who command display the information about all users who are currently
logged into the system. The who command is used as:
$ who
User 1
tty2a Jan 15 07 : 20
User 4
tty2d Jan 1507 : 31
User 2
tty2b Jan 15 08 : 12
User 6
tty4 Jan 15 10 : 11
$

(3)

The echo command: ~


The echo command displays or echoes, whether you type on the line after the
word echo, or the standard output, usually the monitor
$ echo My name is punit.
My name is punit.
The echo command also squeezes out the extra blanks between words as:
$ echo Punit
Kumar
Sharma
Punit Kumar Sharma

(4)

The cat command:


A file can be created by typing the cat command as:
$ cat > filename
And pressing the Enter key. After pressing Enter Key whatever you will type,
it will be stored in the file filename, and when we want toe stop entering the
matter, we would press Ctrl and d keys simultaneously.

(5)

The cp command: ~
Such command is used to copy the content of one file into another file. The
command statement is given below:
$ cp source_file target_file
Here the first argument source_file is the name of the file to be copied and the
second argument target_file is the name of the file to pace the copy content
into.

(6)

The mv command: ~
Such command is used to rename a file. Suppose you want to rename the file
old_letter to new_letter, you would use the mv command as:
$ mv old_letter new_letter

(7)

The rm command: ~
Such command is used to remove a file. The command is used as follow:
$ rm filename

(8)

The cat command: ~


Such command is used to display the content of a file. It is used as:
$ cat filename

(9)

The pwd command: ~


The pwd command displays the current working directory. The pwd stands for
present working directory. It is used as:
$ pwd
/user2
$
Here the current working directory is /user2. Here / represent the root
directory.

(10)

The ls command: ~
The ls command displays the contents of a directory. If your directory has
some files will be displayed typically one per line as:

$ ls
Amit
Punit
Ajay
$
(11)

The cd command: ~
Such command is used to change the directory. Suppose you are working in
/user2 directory and you want to change the directory to /user2/punit, so it can
be done as
$ pwd
/user2
$ cd punit
/user2/punit

(12)

The mkdir command: ~


The mkdir command is used to create a directory. Suppose you want to create
a directory name punit, then it can be done as:
$ mkdir punit

(13)

The rmdir command: ~


Such command is used to remove a directory. Suppose you want to delete a
directory having name punit. Then it can be done as:
$ rmdir punit

(14)

The cal command: ~


The cal command is used to display the calendar for any year in the range 1 to
9999. If you want to open the calendar of 2002 then it can be done as:
$ cal 2002.

/********************* PRACTICAL NO. 2 **********************/

Aim: Familiarize with vi editor.


UNIX Editor:
An editor is a utility program that is used to make modification to the contents of a
file or files. No doubt, editing is one of the most frequently used capabilities of a
general purpose system. User plans his activities via an editor. An editor is designed to
deal with text files. Many users prefer to use an editor to create or modify their files.
Therefore, an editor interactive utility program by which the user can make any
changes, that can be viewed by that time.
UNIX provides basically three types of editors in almost all its versions: ed, ex, and
vi. The ed also known as line editor and was the first editor. The ed editor assigns line
number to each line in the file. The ex editor is an improved version of an ed editor.
The vi editor stands for visual editor, which is more popular than the earlier tow
editors ed and ex.
The vi editor is developed by the university of California at Barclay by Bill Roy
when he was a student there.
The vi editor is a screen editor rather than a line editor that allows the user to see
some part of his file on the terminals screen. The vi editor shows the user as much of
the file contents as it can fit on the screen. The vi editor is the first full screen editor.

vi Editing Modes : ~
The vi editor works in three different modes:
(i)

(ii)

(iii)

Command mode: When the vi editor is started, it is placed in command


mode. In the command mode, whenever the user presses any key, it is
interpreted to be editor command. Note that the keys, that are hit, are not
displayed on the screen in command mode.
Text Input Mode: This mode is used when a new text is added; existing
text is edited or replaced. We can not come to text input mode directly. We
change over form the command mode to text mode with any of the
following subcommands: The a, A, s, S, i, I, R, o, O, c, C commands.
After using one of these commands, we can enter the text. After
completing the text work, we can return to command prompt by pressing
either the Esc key or the Ctrl c. This mode is also known as insert
mode.
The ex Command Mode: The subcommand with the prefix : (colon), ?
(question mark), / (Slash), or !! read input on a line displayed at the bottom
line of the screen. The bottom line of the vi screen is called the command
line. All commands entered in the ex command mode are displayed in the

command line. The vi editor uses the command line to display messages
and commands. Enter key is pressed to execute the subcommand or
interrupt (Ctrl c) key to cancel it.

Introduction to vi editor: ~
The vi editor is invoked by executing, just like any other UNIX command, along with
the filename as:
$ vi filename
After typing this and pressing Enter key, the contents of the specified file are stored
into the edit buffer, the terminal screen is cleared, a window is displayed in which you
can enter and edit text, and the cursor is initially set at the first character of first line in
the window.
Suppose you would like to create a file punit then invoke the vi editor as:
$ vi punit
it clears you previous contents of the screen and displays a window as shown in
figure.

~
~
~
~
~
punit
Except the first line and the last line, the window shows a character ~ (tilde), the
symbol of empty line. The first line has an underscore (_) in the first colon that waits
for a command to entered by you.
By default the vi editor is placed in command mode and thats why it waits for you to
enter a command. If you want to insert text to the file punit then press i key to
enter the insert mode of vi. When you press the i key, it is not displayed on the screen.
Now you can enter the text whatever you want to insert in figure.
Punit Sharma
Mukesh kumar
Ajay kumar
~
~
punit 3 lines and 31 characters

After typing these names, press the Esc key to return the command mode from the
current mode.

Editing a file: ~
If you want to edit a file then it is necessary to load the file form a disk into buffer and
then move to the part of the file you want to edit. And it is achieved as:
$ vi punit
The vi program will clear your screen and fills it with file you are editing as shown in
fig.
The cursor is placed at first character of the first line. You can move the cursor by
using the different commands.
Punit Sharma
Mukesh kumar
Ajay kumar
~
~
punit 3 lines and 31 characters

Moving within a file: ~


Following screen command are used to move the cursor.
h
I
K
J

moves the cursor one character to the left


moves the cursor one character to the right
moves the cursor one line up while it remains in the same column
character to the left
moves the cursor one line down while it remains in the same column
character to the left

These commands are displayed on the screen. The current window screen contains
only the contents of the file. After placing the cursor to the right position you can edit
the file. Unfortunately if you see these commands on the screen then it means that you
are still in insert mode. Therefore, firstly press Esc key to return back to command
prompt and then try these motion commands again. You can also proceed h, j, k, l
command with numbers that allows you to move the cursor a corresponding number
of spaces or lines. Let you want to move 4 lines down then either press j four times or
just type 4j.
some other commands that help in positioning the cursor :
Backspace
Spacebar
$
+

one character left


one character right
moves the cursor to the end of the current line
moves the cursor up to the beginning of next line

Enter

moves the cursor down to the beginning of previous line


moves the cursor up to the beginning of next line

Adding Text: ~
The first thing you have to do is that place the cursor at position where you want to
add and then press a. the a stands for append. Now whatever you will type is
appended to the text buffer after the current cursor position.
Now when you press Esc key, the cursor returns back to the last character you
entered. It tells you that you are no longer in insert mode.
The vi editor provides another command i command that works similar to a
command. The only difference between the a and i command is that it inserts the
new characters before the current cursor position. Therefore after pressing i
whatever you type, it will be added to the left of the characters on which your cursor
is placed

Deleting Text: ~
The vi editor provides two commands, x and dd, that delete text. If you want to
delete a character then firstly place the cursor at the appropriate position . and, then
press x key. After pressing x, the character at the current cursor position will
disappear and the rest of the line would be moved one position left side.
If you want to delete the 4 characters of a line then just type 4x, this delete the four
characters of the current line and move the line to the left side.
Whereas dd command is used to delete the complete line. You can also used
numbering with dd command. E.g if you want to delete 3 lines, then just press 3dd,
it will delete the 3 lines of the files.

Undo command: ~
UNIX also provide undo command. For this we use character u. suppose after
deleting three lines, you think that you had to delete one line only instead of three
lines then use an u command to get back the most recently deleted lines.

Overwriting Text: ~
The vi editor provides a R command to overwrite the existing contents of a file.
Therefore, whenever you want to overwrite, place the cursor at that special position
and then press R. Now whatever you type next would be overwritten the existing text
at the current cursor position.

Saving a file: ~
The vi editor also provides the ZZ command to save all the changes that you make
to the file and quit. This command is used in command mode.

Moving from word to word: ~


The vi editor provide the facility of moving the cursor from word to word such as
using w command for next word and b command for previous word. Some
commands are given below:
w
b
e

moves the cursor to the first character of next word.


moves the cursor to the first character of previous word.
moves the cursor to end of the current word.

Scrolling command: ~
Scrolling is the property of a video terminal that makes the top line to leave the screen
as each new line is displayed at the bottom. The vi editor provide following command
for scrolling purpose
Ctrl U
Ctrl D
Ctrl F
Ctrl B

scroll up one half screen


Scroll down one half screen
Scrolls forward one screen
Scrolls backward one screen

Block Commands: ~
The commands that we have discussed so far deals with a single character, single
word or a single line. The vi editor provides block commands to work on a group of
lines rather that on a single line. For example, we may copy a group of lines from one
part of a file to another part, delete a group of lines from a file by using a single
command. The block command are used to work in ex command mode only. Although
it is not necessary to associate line numbers with the text because block commands
work on line number on which they are supposed to operate.
For example you have a file that contain 20 lines and you want to delete lines from 6
to 10, then you use the command;
6, 10d
Such command delete the 6 to 10 lines.
The vi editor provides a command set number or set nu in the ex command mode
that enables you to display line number. Thus if you are in command mode and want
to display line number then press the colon (:) key that takes you in ex command

mode. Now the cursor is placed at the bottom line of the screen and you type in the
command:
(Esc): set number
Or
(Esc): set nu
The vi editor provide some other useful block commands as:
(i)

:m,n w file
This command writes lines m to n to a file.

(ii)

:m,n w>>file
This command appends lines m to n to a file.

(iii)

:r files
This reads contents of the specified file at current cursor position.

(vi)

:r! command
It executes shell command and output of the command is read at the
current cursor position.

/************************* PRACTICAL NO. 3 *********************/

Aim: Develop advance shell program using grep, fgrep & egrep.
The grep command:
The name grep stands for global regular expression printer. The grep command is
used to search more than one file for particular bit pattern globally and displays the
line containing them, The syntax is:
grep char_pattern file[s]
After the execution of this command, each line of each file that contain the specific
char_pattern will be displayed on the display monitor. If you specify more than one
file then each line is also immediately preceded name of the file. If the char pattern
does not exist in the specified file then the grep command simply displays a new
prompt.

The grep command using a single file:


Let us search a particular char_pattern in a single file. For instance, let us suppose, we
are going to find every occurrence of word great in the file players. First the contents
of the file are:
$ ls players
Cricket is the most loving game in India. There are so many good players
that it is difficult to select which of them are great.
Sachin Tendulkar is one of the great player of all times.
He is the true son of India.
Of course Sunil Gavasker was a good one. But not great.
It is our good luck we are still watching Sachin playing for India.
$
If we want to search word great then we do as:
$ grep great players
that it is difficult to select which of them are great.
Sachin Tendulkar is one of the great player of all times
Of course Sunil Gavasker was a good one. But not great.
$
If we want to search for son of India , we write the grep command as:
$grep son of India players
He is true son of India.
$

Here if you dont use double quote signs then the spaces between son, of and India
would not produce correct result. Now watch carefully the execution of the following
grep command :
$ grep son of India players
grep: cant open of
grep: cant open India
$
Means here, son would be expected as a character pattern and of, India and players
are expected as a file to be searched. Since there is no file called of and India
therefore the grep command displays the message:
Grep: cant open of
Grep:Cant open India.
And then it proceeds to search the file players for the pattern son. Thus it, is
necessary to use single quotes or double quotes on the multi words pattern string is:
$grep son of India players
$grep son of India players

or

The grap command using multiple files: ~


The grep command is more helpful when we search for a character pattern in two or
more files. Let we search for the word great in three files players 1, players 2 and
players 3.
$grep great players1 players2 players3
player1: There are so many great players in the cricket
world.
player2: Mazor Dhyan Chand was a great player.
player3: Laila is daughter of great boxer Mohmad Ali.
$
Here the pattern great will found in file named as player1, player2, player3.

Options of grep command: ~


(i)
(ii)
(iii)
(iv)
(v)
(vi)

-c
-i
-l
-n
-s
-v

:
:
:
:
:
:

display only the number of matches.


ignore case while searching
displays only the name of files, as well as the text itself
displays the line number, as well as the text itself
displays no output or just error messages are suppressed
displays those lines that do not match the searched pattern

For example if we want to know how many times the pattern great occurred in a file
players, then we write

$ grep c great players


If we want to see only those lines, which do not contain the specific pattern, then we
use the grep command as:
$ grep v great players
We can also use more than one options with a grep command as:
$ grep great i c players 1 players 2.

Metacharacter: ~
We can also use metacharacters, special characters such as ?, *, ., [..]
For instance, the following grep command
$grep great players?
Searches all those files that matches upto players? To any 8 characters filenames
starting with players. Here the special character, ?, stands for any one characters.

The fgrep and egrep command: ~:


The fgrep and egrep command are advanced pattern matching command. The fgrep
command doesnt use any meta character for its searched pattern. The primary
advantage of fgrep it that it can also serch two or more than two strings
simultaneously.
The fgrep command can be used like this:
$fgrep good
bad
great userfile
$
Here a single quote is used to mark three strings as one argument. Here we are
going to search three different strings good, bad, and great. The egrep command is
used to search this in a more compact form than fgrep command:
$egrep good | bad | great userfile
The egrep uses an or ( | ) operator to achieve this. Therefore egrep command is more
compact and more versatile than fgrep. Another achievement of egrep is that we can
make groups of different patterns. If we use | as operator.
$egrep sunil | rohan gavasker players
Here sunil is first pattern and everything to the right is considered as second pattern.
If we want to search both sunil gavasker and rohan gavasker use this:
$egrep (sunil | rohan) players

Example: ~
The program given below represents the functioning of egrep and grep commands:
Read statements is the shells internel tool for taking input from the user that is
Making scripts interactive. It is used with one or more variables and input supplied .
the standerd input is read into these variables.Let us suppose a script named as
employee1.sh.
The script employee1 uses read to take a search string and file name from the
terminal.
$ cat employee1.sh
# script : employee1.sh-interactive version
# the pattern and file name will be supplied by the user
echo \n enter the pattern to be searched :\c
read pname
echo \n enter the file to be used :\c
read filename
echo \n searching for $ pname from file $ filename\n
grep $ pname $ filename
echo \n selected record shown above \n
\c put the cursor at the end of echo argument root to the next line

/*********************** PRACTICAL NO. 4 ************************/

Aim: ~ Compile & debug various C program using different

options.
GNU: ~
Gnu stands for GNU C Compiler, is a simple compiler on GNU/Linux systems.

Compiling program with gcc: ~


You can use your favorite editor to type it in. For the purpose of doing that save it as
test1.c.Here is the code
#include<stdio.h>
void main(void)
{
printf(hello world);
}
Now compile the program type:
$ gcc test1.c
When gcc runs with the above usage, it generates a file named a.out that contains your
program. You can run the program as follow:
$ ./a.out
hello world
you will enjoy using the o option of gcc, which enables you to change the names of
your program. To use this option, type the following command:
$ gcc o test1 test1.c
Now you would get file named as test1.c instead of a.out.
Hence, run the program like this:
$ ./test1.c
hello world
Now, on to another important topic: warnings. Warnings are controlled by the w
switch to gcc. You can enables all of the most common warnings with the Wall
command like so:
$ gcc Wall o test1 test1.c
Another useful option is the Werror switch, which causes gcc to treat all warnings
as errors. It can be used as:
$ gcc Wall Werror o test1 test1.c

Advanced gcc options: ~


In addition to gcc options that control basic file generation, there are also many other
operations that enables you to fine tune gcc operations. These are given as:
(i)

Specifying search path: ~

When building a project, gcc has a default search path to use for things like include
files and libraries. You will find that you will often add components to the path. For
instance:
If you are going to compile the program named as punit1, then you may need to add
an entry to the search path so that the gcc can find the header files for your program
punit1.
The options for adding the entry to the include file search path and library search
options are i, -l respectively.
For example, you have a program that wants to include a file named scsi.h, then your
system may have this file under /usr/include/scsi, which is not default search path.
Therefore you might have:
gcc wall i/usr/include/scsi o myprogram myrogram.c
This option would help the preprocessor to find the scsi.h file. The same concept will
be included for libraries. If your program needs to link to the X11 library, then you
may tell this to linker like this:
gcc l/usr/X11r6/lib wall o myprogram myprogram.c lX11

(ii)

Linking with libraries: ~

When writing many programs, you will need to link with the libraries. These library
can be anything from that implement mathematical function to ones that provide
support for using a graphical interface in the X Window System. They can be either
static or shared (dynamic); gcc can work with both.
The basic options to link in a library with your current program is -l( a lowercase L)
For instance, if you want to include the math library, you would probably include
math.h in your program. Then, when compiling, you would need to link in the math
library, names simply m. Therefore, a command such as the following would be
appropriate:
gcc Wall o mathprogram mathprogram.c lm

(iii)

Speeding compilation with pipes: ~

The build process requires many steps- preprocessing, compilation, assemble,


linking to the name a few. Normally, gcc handles many aspects of these tasks for you,
automatically invoking program as necessary.
But by default, this can be slow before there are many temporary files included. For
instance, gcc will create a temporary file holding the output of the preprocessor,
another one with the output of compiler, and perhaps the output of the assembler.
Hence reading and writing takes time.
The other way of communication that can be more efficient: - pipelining. With
pipelines, several programs can be invoked at once, with the output from one being
input of the other. The pipelining can be shown as:
$ gcc pipe wall -03 o test2 test2.c
(iv)

Peeking at gcc with v: ~

All the interaction between the various builds programs are normally hidden from
view.
There details are generally unimportant and distracting.However, you can request the
details to be shown as gcc runs; to do this use the v option.
$ gcc v Wall -03 o test2 test2.c
The output will be the detailed list of build process.

/******************** PRACTICAL NO. 5 ****************/

Aim: Learning and installation and up gradation of Linux


Operating system.
Introduction: ~
Linux, an implementation of UNIX, is an ideal operating system for power users and
programmers because it has been and is being developed by such people. The
development of Linux starts from the Netherlands. Linux is a UNIX like operating
system originally developed by Linus Torvalds, then a student a student at the
University of Helsinki in Finland. Linux began its work in 1991. Linux is a portable,
multitasking, multi-user and 32 bit support operating system. Moreover Linux can
use a portion of your hard drive as virtual memory, expanding your total amount of
available RAM. In addition Linux is a free operating system. It means that you need
not to spend anything. It can be downloaded from the Internet free of cost and it is a
secure and versatile OS. The installation of RED HAT LINUX 9.0 is given below

Installation of RED HAT LINUX 9.0: ~


We can install the RED HAT version of Linux from CD-ROMs, using the graphical,
mouse based installation program. Red Hat Linux 9.0 comes with three CDs pack.
Boot your system with first CD #1 in your CD ROM / DVD ROM drive. Perform
the installation as follows:
Step 1: Firstly you will see a screen containing the boot: prompt. The screen contains
the information on a variety of boot option. Press Enter to choose first item in
the first menu for install or upgrade in the Graphical Mode; otherwise you
can start a text mode installation using the following boot command:
boot : text
The resulting menu states that it found the CD and prompts to test it or not. If
you have not tested then test it first: otherwise Skip this.
Step 2: It checks the hardware and correctly identified the display adapter, etc.
Step 3: Click Next on Welcome Screen
Step 4: Click Next on Language Selection English (default)
Step 5: Click Next on Keyboard Selection U.S. English
Step 6: Click Next on Mouse Configuration Generic 3 Button Mouse (PS/2)
Step 7: The Upgrade Examine screen appears automatically if the installation
program detects a prior version of Red Hat Linux on your system.
If you want to upgrade then select Perform an upgrade of an existing;
otherwise select Perform a new Red Hat Linux install.
Step 8: Select the type of installation Personal Desktop.
Step 9: Next you have Disk Partitioning Setup. Now you have two options

Automatic Partition an Manually partition with Disk Druid. Select


Manually partition with Disk Druid.
It will warn you about the data loss Yes to continue initializing drive.

Partitions: ~
Highlighted Free under /dev/had has 28624 Mbytes of Free space. However you can
also install Red Hat Linux on any other partition. Here it is supposed that you are
installing Red Hat Linux on first partition.
Unless you have a reason for doing otherwise, we recommend that you create the
following partition:
Click the New button
Mount Point = /
File System Type = ext3 (default)
Allowable drives = default just the one in the computer
Size MB = 1.7GB 5.0 GB (1.7 GB root partition for desktop installation and
5.0 GB for installation of every package)
Click the New Button
Mount Point = /boot
File System Type = ext3 (default)
Allowable drives = default just the one in the computer.
Size MB = 100 MB.
Next create a swap partition. Red Hat says the swap partition should be twice the
memory or 32 MB, which ever is larger. For 256 MB Memory, it should be 512 MB.
Bootloader Installation left everything default
Use GRUB as the boot loader. You can also select LILO or even choose not to install
a boot loader at all.
Install Boot Loader record on /dev/hda1 Master Boot Record (MBR).
Default Boot Image : red Hat Linux
Click on Next
GRUB Password left default = no GRUB Password Click on Next
Network Configuration left as default (DHCP and activate at boot) its less
overall work to change it after Linux is up Click on Next
Firewall Configuration Selected No firewall (the broadband router does that
function) Click on Next.
Additional Language Support English (USA) (already checked) Click on Next.
Time Zone Selection Click on Time of area you want and then Click on Next.
Account Configuration Entered and Confirmed a password for Root Click on
Next
Authentication Configuration Left all settings at defaults.
Click on Next
Package Group Selection Unless you choose a custom installation ,the installation
program will automatically choose most packages for you. However if you have
chosen custom installation then select the following packages and rest unchecked:

X Window System
CNOME Desktop Environment
Graphical Internet
Web Server In details added all mysql and php options
Windows File Server
FTP Server
SQL Database Server In details added mysql server
Administrative Tools
System Tools
Printing Tools
Next
Remember one thing while selecting package group selection that one should not
select Samba (Windows Networking), you can install it later.
About to install screen Next you will see a screen preparing you for the installation
of Red HatLinux.
Installing Packages
Insert CD #2 in your CD ROM / DVD ROM drive when you are asked to do so.
Insert CD #3 in your CD ROM / DVD ROM drive when you are asked to do so.
Boot Diskette Creation Skip boot disketter creation , if you dont need it
Monitor Configuration Says my shop monitor is an Unprobed Monitor Click on
Next.
Customize Graphics Configuration left it at default: True Colour (24 bits), 800
X 600, Graphical
Click on Next
It ejected the CD
Exit
(If the screen goes bananas like minedid just wait and let the computer reboot)
It rebooted
Welcome Forward
User Account Created an account for myself Forward
Date and Time Did not check Enable network time protocol Forward
Red Hat Network opted not to register Forward
Additional CDs Forward
Finish Setup Forward
It rebooted.
Logged in as root.

/*********************** PRACTICAL NO. 6 ************************/

Aim: ~ Install, Linux on a PC having some other previously


installed operating system. All OSs should be usable.
Explanation: ~Installing Linux on a pre-existing UnixWare 7
nstallation
Installing Linux on a pre-existing UnixWare 7 system can cause problems attempting
to boot UnixWare 7. The suggested workaround is to boot the active partition at the
Boot Command Prompt (BCP). The procedure is described below:
St1:

Install UnixWare 7 is given below:


(A)

Select Customize disk partitions in the ``Disk Configuration'' screen.

(B)

In the ``Disk 1 Partitions'' screen divide your disk into 4 partitions so


that UnixWare 7 occupies one partition on the disk. Keep the other
partitions as ``Unused''. For example on a 4GB disk, one possible
layout is to put UnixWare 7 on the first partition, and make it occupy
25% of the disk..

St 2:

When your system reboots, insert the Linux installation media.

St 3:

At the start of the Linux installation, change to a virtual console screen


running a shell.

St 4:

If there is no device node for the disk, create a device node. For example, for
the first SCSI hard disk, enter:
mknod /dev/sda b 8 0
For more details, see the mknod (8) manual page in the Linux documentation.
For an EIDE hard disk, use the appropriate device such as /dev/hda.
/proc/partitions contains a list of major and minor numbers associated with all
the available partitions.

St 5: Modify the hard disk partition table using fdisk. For details, see the fdisk (8)
manual page in the Linux documentation. For example, for the first SCSI hard
disk, enter:
fdisk /dev/sda
For an EIDE hard disk, use the appropriate device such as /dev/hda.
St 6: Make new partitions for Linux root and Linux swap. For example you could
choose ``sda1'' for Linux root and ``sda2'' for Linux swap. Note down which

partition Linux root and Linux swap are on. For details of how to make new
partitions, see the fdisk (8) manual page in the Linux documentation.
St 7:

Press <Ctrl> <Alt> <Del> to reboot your system. A reboot is necessary as the
graphical partition tool may not recognize that you have changed the partition
table using fdisk.

St 8:

Restart the Linux installation. Select a ``Custom'' installation. Do not select to


have automatic partitioning

St 9:
St 10:
St 11:
St 12:

Add a mount point for the Linux root partition (/).


Ensure that LILO is installed in the first sector of boot partition.
Finish the Linux installation.
Reboot your system. Remember to remove the installation media.

/*********************** PRACTICAL NO. 7 ************************/

Aim: ~ Using Bash shell develops simple shell programs.


What is Shell Script?
Normally shells are interactive. It means shell accept command from you (via keyboard) and
execute them. But if you use command one by one, then it was a very time consuming
process. To overcome this limitation we can store this sequence of command to text file and
tell the shell to execute this text file instead of entering the commands. This is know as shell
script.
Shell
script
defined
as:
Shell Script is series of command written in plain text file. Shell script is just like batch
file is MS-DOS but have more power than the MS-DOS batch file."
Why to Write Shell Script ?
1.
2.
3.
4.
5.

Shell script can take input from user, file and output them on screen.
Useful to create our own commands.
Save lots of time.
To automate some task of day today life.
System Administration part can be also automated.

Some simple programs related to shell scripts:


1. A program to print the name.
# cat > ajay
echo Enter the name
read name
echo Glad to meet you $name.
[ctrl +d]
#_

2. A program in which Addition, Multiplication ,Subtraction, division and


Modulus operation is applied on two numbers, which is enter by the user
or programmer.
#cat >firstprogam
echo Enter any two number
read a b
c = expr $a + $b
echo The addition of two number is $c
d = expr $a - $b
echo The subtraction of two number is $d
e = expr $a \ * $b
echo The multiplicaton of two number is $e
f = expr $a / $b
echo The division of two number is $f
g = expr $a % $b'
echo The modulus of two number is $g
[Ctrl + d]
#_

3. A program in which we calculate the area of rectangle and circle. A programmer


enter only Length, Breadth or rectangle and Radius of a Circle.
#cat > punitprogram
echo Enter the Length and Breadth and Radius
read len bre red
rectarea = expr $len \ * $bre | bc
circlearea = expr 3.14 \ * $red \ * $red | bc
echo The area of rectangle is $rectarea
echo The area of circle is $circlearea
[Ctrl + d ]
#_
4. A program in which we check out that two numbers are equal or not. The
numbers are entered by the user or programmer.
#cat > punit
# Find both number are equal or not
echo Enter the two numbers
read a b
if test $a eq $b
# here eq is a comparison
operator.
then
echo The two numbers are equal
else
echo The two numbers are not equal
fi
[Ctrl + d]
#_
5. A program in which we have find out which number is greater among the three
using the logical operator.
1. a
binary AND operator
2. o
binary OR operator
3. !
binary NOT operator
#cat > punit
echo Enter three numbers
read a b c
if [ $a gt $b a $a gt $c ]
then
echo The greatest number is $a
elif [$b gt $a a $b gt $c ]
then
echo The greatest number is $b
else
echo Largest number is $c
[Ctrl + d]
#_
6. A program in which swapping of two numbers in carried out with using third
variable.
#cat>Punit
echo Enter two numbers
read a b

echo The two numbers before swapping is


echo $a
echo $b
c =$a
$a=$b
$b=$c
echo The two numbers after swapping is
echo $a
echo $b
[Ctrl + d]
#_

7. Program to calculate the average of three numbers.


#cat>Punit
echo Enter three numbers
read a b c
avg = expr \($a + $b + $c\)/3|bc
echo The average of three numbers is $avg
[Ctrl + d]
#_
8. A program in which the comparison of two strings is carried out to check
that whether they are equal or not.
#cat > stringcheck
#comparison of two string
echo Enter two strings
read first second
if [ $first = $second ]
then
echo The two strings are equal
else
echo The two strings are not equal
fi
[Ctrl + d]
#_

9. A program in which the switch statement is used.


$cat > punit
#case statements
echo Enter any day number from 1 to 7
read no
case #no in
1) echo Monday;;
2) echo Tuesday;;
3) echo Wednesday;;
4) echo Thursday;;
5) echo Friday;;
6) echo Saturday;;
7) echo Sunday;;
*) The entered choice is wrong;;

esac
[Ctrl + d]
$_

Sr. No.

Objective

Familiarize with UNIX / Linux logging /


logout and simple commands.
Familiarize with vi editor.

2
3

Develop advance shell program using


grep, fgrep & egrep.

Compile & debug various C program


using different options.

Learning and installation and upgradation of Linux Operating system.

6
7

Install, Linux on a PC having some other


previously installed operating system. All
OSs should be usable.
Using Bash shell develops simple shell
programs.

INDEX

Teacher sign.

You might also like