0% found this document useful (0 votes)
192 views

Unix Programs

The document provides instructions on basic commands and operations for the ED text editor. It includes examples of searching for and replacing text, deleting characters, and formatting lines. The summary also covers using regular expressions and inverting matches. SED is introduced as a stream editor for performing text transformations on input streams.

Uploaded by

Srini Vasan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
192 views

Unix Programs

The document provides instructions on basic commands and operations for the ED text editor. It includes examples of searching for and replacing text, deleting characters, and formatting lines. The summary also covers using regular expressions and inverting matches. SED is introduced as a stream editor for performing text transformations on input streams.

Uploaded by

Srini Vasan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 33

BASIC COMMANDS-FILES

1.) date
Aim:- to display the system date and time.
Systax:- date
Example:- date
Output:- Thu Sep 17 14:02:42 IST 2009

2.) who
Aim:- to display the name of all the user who have currently logged in.
Syntax:- who
Example:- who
Output:-
root :0 Sep 17 13:42
root pts/1 Sep 17 13:42 (:0.0)
root pts/2 Sep 17 13:43 (:0.0)

3.) who am i
Aim:- to display the name of the current user.
Syntax:- who am i
Example:- who am i
Output:-
root pts/2 Sep 17 13:43 (:0.0)

4.) cat
Aim:- Display the content of the file.
Syntax:- cat
Example:- cat unix
Output:-
[root@localhost ~]# cat unix
unix is a operating system.
5.) ls
Aim:- Displayl list of all files and directories.
Syntax:- ls[option][file name]
Example:- ls
Output:-
[root@localhost ~]# ls
anaconda-ks.cfg forex forex2 forex4 install.log mohan vivek
Desktop forex1 forex3 forex7 install.log.syslog unix

a.) ls -l
Aim:- display all files in long formate.
Syntax:- ls -l
Example:- ls -l
Output:-
[root@localhost ~]# ls -l
total 152
-rw-r--r-- 1 root root 1159 Jul 14 14:08 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 Jul 14 14:11 Desktop
-rw-r--r-- 1 root root 31 Sep 14 09:32 forex

b.) ls -a

Aim:- list all files starting with .(dot)


Syntax:- ls -a
Example:- ls -a
Output:-
[root@localhost ~]# ls -a
. .eggcups .gnome .nautilus
.. .esd_auth .gnome2 .recently-used

6.) copy
Aim:- copy contents of file1 to file2.
Syntax:- cp file1 file2
Example:- cp unix linux
Output:-
[root@localhost ~]# cat linux
unix is a operating system.
7.) rename
Aim:- use to move or rename a file.
Syntax:- mv oldname newname
Example:- mv linux lin
Output:-
[root@localhost ~]# mv linux lin
[root@localhost ~]# cat lin
unix is a operating system.

8.) remove
Aim:- to remove a file from system.
Syntax:- rm filename
Example:- rm lin
Output:-
[root@localhost ~]# rm lin
rm: remove regular file `lin'? y
[root@localhost ~]# cat lin
cat: lin: No such file or directory

9.) wc
Aim:- To count the number of words,line,characters in a file.
Syntax:- wc[options][filename]
Example:- wc
Output:-
[root@localhost ~]# wc unix
1 5 28 unix
a.) wc -l
Aim:- it represents numbers of lines.
Syntax:- wc -l filename
Example:- wc -l unix
Output:-
[root@localhost ~]# wc -l unix
1 unix

b.) wc -c
Aim:- It displays the no. of characters.
Syntax:- wc -c filename
Example:- wc -c unix
Output:-
[root@localhost ~]# wc -c unix
28 unix
c.) wc -w
Aim:- It display the no. of words in a file.
Syntax:- wc -w filename
Example:- wc -w unix
Output:-
[root@localhost ~]# wc -w unix
5 unix

Directory Basic Command

1.) mkdir
Aim:- To create directory.
Syntax:- mkdir directoryname
Example:- mkdir computer
Output:-
[root@localhost ~]# mkdir computer
[root@localhost ~]# ls
anaconda-ks.cfg forex forex3 install.log unix
computer forex1 forex4 install.log.syslog vivek

2.) pwd
Aim:- To display your current working directory.
Syntax:- pwd
Example:- pwd
Output:-
[root@localhost ~]# pwd
/root

3.) cd
Aim:- to change the current working directory.
Syntax:- cd directory name
Example:- cd computer

Output:-
[root@localhost ~]# cd computer
[root@localhost computer]#
Example:- cd ..
Output:-
[root@localhost computer]# cd ..
[root@localhost ~]#
4.) rmdir
Aim:- to remove the directory.
Syntax:- rmdir[option]directoryname
Example:- rmdir computer
Output:-
[root@localhost ~]# cat computer
cat: computer: No such file or directory
5.) chmod
Aim:- To change the mode or permission.
Syntax:- chmod<category><operation><permission><filename>
or
chmod<octalno>filename
Example 1:- chmod ugo+x unix
Output:- ls-l
Before:- -rw-r--r-- 1 root root 28 Sep 17 14:24 unix
After :- -rwxr-xr-x 1 root root 28 Sep 17 14:24 unix
Example 2:- chmod 744 forex
Output:- ls -l
Before:- -rw-r--r-- 1 root root 31 Sep 14 09:32 forex
After :- -rwxr--r-- 1 root root 31 Sep 14 09:32 forex

6.) ps
Aim:- To give the status of your processer that are running.
Syntax:- ps
Example:- ps
Output:-
[root@localhost ~]# ps
PID TTY TIME CMD
3964 pts/1 00:00:00 bash
3992 pts/1 00:00:00 ps

DIRECTED TO A FILE

Aim:- To directed the input or output of a file to another file.


Syntax:- command 2>file->(filename)
Directed Symbols:-
< = standard input
> = standard output
>> = append
Example:- ls n* 2>e1
cat e1
Output :- cat ab
cat ab 2>cd
The ED Editor
Explanation :: ED is a line oriented text edtior
# cat files
Unix system recognize only three basic types of files : ordinary files, director
y files, and special files. An ordinay file is just that : any file on the syste
m that contains data, text, program instructions or just about anything else.
Syntax :: ed file_name
Explanation :: use to activate the editor
Output :: Show the number of characters contain by the specified fi
le
# E d files
231
Syntax :: 1,$p
Explanation :: Prints all the characters from first to last
Output ::
Unix system recognize only three basic types of f
iles : ordinary files, directory files, and special files. An ordinay file is ju
st that : any file on the system that contains data, text, program instructions
or just about anything else.
Syntax :: /. . ./
Explanation :: Search for given charactered word. Here search for three char
acter word. Then wil
display that line contains the word.
Output :: Unix system recognize only three basic types of files : or
dinary file, direc

Syntax :: /
Explanation :: Repeat the previous command
Output :: Unix system recognizes only three basic types of files : or
dinary file,direc
Syntax :: 1,$s/old_word/new_word/[ g ]
Explanation :: It will replace the old_word by new_word globally and will disp
lay all the lines that
contains the word
Output :: 1,$s/files/xxx/g
Unix system recognize only three basic types of xxx :
ordinary xxx, directory xxx, and special xxx. An ordinay file is just that : an
y file on the system that contains data, text, program instructions or just abou
t anything else.
Command:: ^
Explanation :: Matching the given character in the beginning of a line and pr
int the lines.
Output :: 1,$s/^/>>/g
Will add ( >> ) symbol to the beginning of all the l
ines.
>>Unix system recognize only three basic types of xxx
: ordinary xxx, directory xxx, and >>special xxx. An ordinay file is just that
: any file on the system that contains data, text, program >>instructions or jus
t about anything else.
Command:: $
Explanation :: Matching the given character in the eng of a line and print th
e lines.
Output :: 1,$s/\.$/g
Will search for the line ends with ( . ) and prints
the line
About anything else.
1,$s/$/>>/g
>>Unix system recognize only three basic types of xxx
: ordinary xxx, directory xxx, and>> >>special xxx. An ordinay file is just tha
t : any file on the system that contains data, text, program>> >>instructions or
just about anything else.>>
Syntax :: 1,$s/. .$//
Explanation :: Use to delete the given character. Here it will delete last tw
o character from each line
Output ::
>>Unix system recognize only three basic types of xxx
: ordinary xxx, directory xxx, and >>special xxx. An ordinay file is just that
: any file on the system that contains data, text, program >>instructions or jus
t about anything else.
1,$s/^$//
Will delete each line wich contains no character
>>Unix system recognize only three basic types of xxx
: ordinary xxx, directory xxx, and >>special xxx. An ordinay file is just that
: any file on the system that contains data, text, program >>instructions or jus
t about anything else.
Syntax :: 1,$s/[Matching character]//g
Explanation :: Use to delete matching characters and displays the lines
Output :: 1,$s/[A E I O U a e I o u ]//g
>>nxsystmrcgnznlythrbsc typsfxxx:rdnryxxx,drctryxxx,
nd >>spcl xxx.nrdnyflsjsttht:nyflnthsystmthtcntnsdt,txt,prgrm >>nstrctnsrjstbtny
thng ls.
Syntax :: 1,$s/^[Matching character]//g
Explanation :: It will invert the section .Use to delete characters except ma
tching characters and
displays the lines
Output :: 1,$s/^[A E I O U a e I o u ]//g
>>Uieeoieoeeaieooiaieoa eiaAoiaieiuaaieoeeaoaiaaeoa i
uioouaouaiee
Eg :: 1,$s/i.*e/+++/
Will replace all characters of a line from first I to last e by +++
Output ::
>>Un+++ ctory xxx, and
>>Spec+++xt, program
Eg :: 1,$s/[A-Z a-z][A-Z a-z]*/*/g
Will replace at least one alphabet,zero or more characters other than special ch
aracters by *
Output ::
*:*, *,*
.** :*,*,*
*.
SED :: This is a stream editor. It performs operation on a stream of bits. It i
s used to perform basic text tranformatio on an input stream. The related comman
ds are given below.
Syntax :: $ sed ‘command’ filename >tmp
mv tmp to filename
Explanation :: It will firstly save the output of the command to tmp and th
en the contains of the tmp
file will moved to the given file(filename)
Output :: $ cat abc
We are students of srm University
$ sed ‘s/srm/SRM/’ abc >tmp
$ mv tmp to abc
cat abc
We are students of SRM University
The -n option :: Supress automatic printing of pattern phase
Syntax :: $ sed -n ‘char p’ filename
Output :: $ sed -n ‘1-10p’ files
Prints first and second line
Unix system recognize only three basic types of xxx
: ordinary xxx, directory xxx, and special xxx. An ordinay file is just
that : any file on the system that contains data, text, program
Syntax :: $ sed ‘chard’ filename
Explaination :: Delete the specified line from a file
Output :: $ sed ‘1,2d’ files
Will delete the first and second line from the file “files”. And will p
rints the remaining lines
instructions or just about anything else.
Eg :: $ sed ‘Unix/d’ files
Will display the lines which not contain word Unix
Output ::
special xxx. An ordinay file is just that : any file on the syst
em that contains data, text, program instructi
ons or just about anything else.
# cat abc
Welcome to Linux
# ed abc
Syntax :: character\{min,max\}
Explanation :: It will match the given consucative characters
Output :: 1,$s/W\{1,10\}/g
Welcome to Linux
Eg :: 1,$s/^.\{10\}//g
Will delete first 10 characters from the file abc
Output :: Linux
The tr command :: Translate, squeeze, and/or delete characters from standard i
nput and writing to standard output.
Syntax :: # tr from_char to_char <filename
Output :: # tr e x <files ( filename )
It will changes all appearences of e to x.
>>Unix systxm rxcognizx only thrxx basic typxs of fil
xs : ordinary filxs, dirxctory filxs, and >>spxcial filxs. An ordinay filx is j
ust that : any file on the system that contains data, txxt, program instructions
or just about anything elsx.
# tr a-z A-Z <files
Will changes the lowercase letters to upper case letter
Output ::
UNIX SYSTEM RECOGNIZES ONLY THREE BASIC TYPES OF FILES : ORDINARY FILES, DIRECTO
RY FILES, AND SPECIAL FILES. AN ORDINARY FILE IS JUST THAT : ANY FILE ON THE SYS
TEM THAT CONTAINS DATA, TEXT, PROGRAM INSTRUCTIONS OR JUST ABOUT ANYTHING ELSE.
Syntax :: $ command | tr char_from ASCII_value
Explanation :: Take output of the command and perform operation as by given AS
CII char
Output :: $ date | tr ‘ ‘ ‘\12’
Will give new line instead of blank space
Thu
Jul
23
14:54:48
IST
2009

Syntax :: $ tr -s from_char to_char <filename


Explanation :: It will removes multiple occurrence of the from_char to to
_char.
Output :: $ tr -s ‘ ‘ ‘ ‘ < files
Unix system recognize only three basic types of files : ordinary files, director
y files, and special files. An ordinay file is just that : any file on the syste
m that contains data, text, program instructions or just about anything else.
Syntax :: $ tr -d Char-Set <filename
Explanation :: It will delete the given character set from the file
Output :: $ tr -d ‘ ‘ <files
Unixsystemrecognizeonlythreebasictypesoffiles:ordinaryfiles,directoryfiles,andsp
ecialfiles.An ordinayfileisjustthat:anyfileonthesystemthatcontainsdata,text,prog
raminstructionsorjust aboutanythingelse.
CUT, PASTE, GREP AND SORT COMMAND

AIM :: cut, paste, grep and sort command


Cut Command
Explanation :: It will extract specied character from the given file and prints
it.
Syntax :: # cut cchars filename
Eg. # cut c5 test
It will extract the fift character and print the result
Output ::
S
If the file is not specified then it will takes input from standard input
The -d and -f option
The -d and -f option are used with cut when you have data that is deliminated
by a particular character.
Syntax :: # cut -dchar -ffields filename
Eg. # cut -d: -f1 /etc/passwd
Output ::
root
corn
bin
uucp
asg
other
Paste command
The paste command is sort of the inverse of cut : Instead of breaking lines apar
t ,it puts them together.
Syntax :: # paste filename1 filename2 ….. …..
# cat names
Trideep
Rajeev
Raj..
# cat nums
9962864628
9176546670
9042508265
# paste names nums
Output ::
Trideep 9962864628
Rajeev 9176546670
Raj.. 9042508265
The -d option
Instead of tab character this option separate the fields with given character
Syntax :: # paste -d ‘+’ file1 file2 . . . .
Example :: # paste -d ‘+’ names nums
Output ::
Trideep+9962864628
Rajeev+9176546670
Raj..+9042508265
The -s option
This option allows us to paste lines from a same single file
Syntax :: # paste -s filename
Example :: # paste -s names
Output ::
Trideep Rajeev Raj..

The grep command


It allows us to search one or more files for particular character pattern.
Syntax :: # grep pattern files
Example :: # grep Raj.. names
Output :: Raj..
The -v option
It is used to search all the lines which are not contain the pattern.
Syntax :: # grep -v pattern files
Example:: # grep -v Trideep names
Output :: Rajeev
Raj..
The sort command
It is used to sort numbers , characters etc.
Syntax :: # sort filename
Example :: # sort names
Output :: Raj..
Rajeev
Trideep
The -r option
Allow us to sort contents in reverse order.
Example :: # sort -r names
Output:: Trideep
Rajeev
Raj..

QUOTES

SINGLE QUOTE
SYNTAX: $ grep text filename
EXPLANATNION: Single quote is to keep characters otherwise separated by white
spaces characters together.
EXAMPLE 1: $ grep susan goldberg phonebook
OUTPUT: susan goldberg 9987650800
EXAMPLE 2: $ file=/users/steve/bin/prog1
$ echo $file
OUTPUT: $file

DOUBLE QUOTE
SYNTAX: $ echo “textâ€
EXPLANATION: Double quotes are not restrictive.double quote say to ignore mo
st. But the three characters are not ignored inside double quotes.
Dollar signs
back quotes
backslashes
EXAMPLE 1: $ x=*
$ echo “$xâ€
OUTPUT: *
EXAMPLE 2: $ address=†39 east 12th street
> new york, N. Y. 10003
$ echo “$addressâ€

OUTPUT: 39 east 12th street


New york, N.Y.10003

BACKSLASH
SYNTAX: \c
EXPLANATION: The backslash quotes the single character that immediately foll
ows it.The general format is \c. where c is the character we want to quote. Any
special meaning normally attached to that character is removed.
EXAMPLE 1: $ x=5
$ echo “The value of x is \†$x\†â€

OUTPUT: The value of x is “5â€


EXAMPLE 2: $ x=*
$ echo \$x
OUTPUT: $x

BACKQUOTE  
SYNTAX: command
EXPLANATION: Backquote tells the shell to execute the enclosed command and
to insert the standard output from the command at that point on the command line
.
 
EXAMPLE 1: $ echo The date and time is: date
OUTPUT: The date and time is: wed sep 16 14:28:43 EDT 2002
 
EXAMPLE 2: $ echo current working directory is pwd
OUTPUT: current working directory is /root
PASSING ARGUMENTS

Aim:
To learn the how to pass arguments to program

Commands:
1. Argument passing
Syntax:
$# variable
Example:
$cat args
echo S# argument passed
echo arg1=:$1:
echo arg2=:$2:
echo arg3=:$3:
$sh args 10 20 30
Explanation:
This will take three arguments as input and display them
OutPut:
Argument passed
arg1=10
arg2=20
arg3=30
2. Another method for argument passing
Syntax:
$*variable
Example
$cat args2
echo $#
echo they are:$*
$sh args2 12 3 4 5 60
Explanation:
This will take many arguments and display them
Output:
they are:12 3 4 5 60
3. This is used to search the name from another file
Syntax:
grep $1 filename
Example:
$cat lu
grep $1 phonebook
$ sh lu chebba
Explanation:
This will search the given name is available in exiting file are
not.
Output:
Chebba 977-764-786
4. This will add new text to exiting file
Syntax:
echo “$1 $2” filename
Example:
$cat add
Echo “$1 $2”>>phonebook
$sh add ‘pizza’ 987-342-675
$cat phonebook
Explanation:
This will add a new text to another file by pasing argument from
a add file.
Output:
Pizza 987-342-675
5. This will take arguments from terminal and display using shift
Syntax:
Echo $#$*
Shift
Example:
#cat shift
echo$#$*
Shift
echo$#$*
Shift
echo$#$*
Shift
echo$#$*
Shift
echo$#$*
Shift
echo$#$*
$ sh shift a b c d e f
Explanation:
This will take arguments from terminal by using each shift it wi
ll remove one argument and display remaining until arguments is left.
Output:
6 a b c d e f
5 b c d e f
4 c d e f
3 d e f
2 e f
1 f
Check Prime

AIM :: Program to check whether a given number is prime or not

Program ::

cat chkprime
#Chech a given number is prime or not
echo "Enter a number"
read n
i=1
count=0
while [ $i -le $n ]
do
if [ $((n%i)) -eq 0 ]
then
count=$((count+1))
fi
i=$((i+1))
done
if [ $count -eq 2 ]
then
echo "$n is a Prime number"
else
echo "$n is not a prime number"
fi
OUTPUT ::
sh chkprime
Enter a number
45
45 is not a prime number

Factorial

AIM :: Program to find the factorial of a number

Program ::

cat factorial
#Print Factorial of a number
echo "Enter a number to find factorial value ::"
read n
a=$n
if [ $n -gt 1 ]
then
fact=1
while [ $n -gt 0 ]
do
fact=$((fact*n))
n=$((n-1))
done
echo "Factorial of $a = $fact"
fi

OUTPUT ::

sh factorial
Enter a number to find factorial value ::
6
Factorial of 6 = 720

FEBONICI SERIES
AIM :: Program to generate febonici series

Program ::

cat febonici
#Generate febonici series
echo "Enter the higher bound of the series ::"
read n
if [ $n -gt 1 ]
then
temp=0
temp1=1
i=0
echo "The series is :: "
while [ $i -lt $n ]
do
f=$((f+temp))
echo $f
temp=$temp1
temp1=$f
i=$((i+1))
done
fi
OUTPUT::
sh febonici
Enter the higher bound of the series ::
10
The series is ::
0
1
1
2
3
5
8
13
21
34
Greatest Among Three Numbers

AIM :: Program to find greatest among three numbers

Program ::

cat >greatest
#Program to find greatest among three numbers
echo "Enter Three numbers :: "
read a
read b
read c
if [ $a -gt $b -a $a -gt $c ]
then
echo "$a is the greatest among three"
elif [ $b -gt $c ]
then
echo "$b is greatest among three"
else
ech "$c is the greatest among three"
fi

OUTPUT ::

sh greatest
Enter Three numbers ::
45
67
89
89 is the greatest among three

Implement MOVE

AIM :: Program to implement move command.

Program ::

if [ "$#" -ne 2 ]
then
echo "usaes : copy file1 file2"
exit 1
fi
from="$1"
to="$2"
if [ -d "$to" ]
then
to="$to/$(basename $from)"
fi
if [ -e "$to" ]
then
echo "$to already exists;overwrite(y/n)? \c"
read answer
if [ "$answer"!=y ]
then
echo "copy not performed"
exit 0
fi
fi
cp $from $to
rm "$from"
echo “Moving Successfull”

OUTPUT ::
sh copy file1 file2
Move Successfull

Phonebook
AIM :: Program to Add,Remove and Search datas From Phonebook
Program ::
#Program to manipulate Phonebook
echo "
1. Add to Phonebook
2. Remove from Phonebook
3. Search from Phonebook
Enter Your choice :: "
read ch
case "$ch" in
1)echo "Enter the name ::"
read name
echo "Enter the Ph No :: "
read num
echo "$name $num" >>Phonebook;;
2)echo "Enter the name to Delete :: "
echo name
grep -v "$name" Phonebook >/tmp/Ph
mv /tmp/Ph Phonebook
echo "Deleted";;
3)echo "Enter the name to search"
read name
grep "$name" Phonebook;;
*)echo "Invalid Choice"
exit 1;;
esac

OUTPUT ::
sh phmp
Add to Phonebook
2. Remove from Phonebook
3. Search from Phonebook
Enter Your choice ::
1
Enter the name ::
Raj
Enter the Ph No ::
9042508265
INSTALLING THE LINUX OPERATING SYSTEM
AIM :: Installing The Linux Operating System
To start the installation process,boot off CD/DVD-ROM .This present us with a sp
lash screen introducing us to Linux RedHat.
Press any Key before timeout to proceed ………
After getting the Welcome Screen In PC, Follow the following Steps….
Steps ::
1. Select the language from the list in which language you want to perform
installation ……
• English(US)
Click On Next
2. Select the Keyboard Language (Layout) …..
• U.S. English Layout
Click On Next
3. Mouse Configuration….
2 button mouse
3 button mouse PS/2
………………………………
• 3 button mouse PS/2
Click On Next

4. Select Installation Type …..


Personal Desktop
Server
Workstation
Custom
• Custom
Generally we choose Custom because by this we can configure our OS in any type(
User Define Type)
Click On Next
5. Disk Partitioning Setup
We need to partition the disk to save System and our Own files
Comparison the partitions to Windows
I. / The root partition /volume identified by forwars slash(/).All other d
irectories are attached(mounted) to this parent directory. In windows c:\
II. /boot This partition/volume contains almost everything required for the
boot process. It stores data that is used before the kernel begins executing us
er programs. In windows System files.
III. /usr This is where all of the program files will reside. In windows c:
\Progr am Files
IV. /home This is the Home directory for all users. In Windows C:\Documents
and Settings
V. /var This is where system/event logs are generally stored. In Windows C
:\Windows/system32/config.
VI. /tmp This is where temporary files are stored. In Windows C:\Temp
VII. Swap This is where virtual memory file is stored. It is not user access
ible file system.
6. Disk Setup
I. Select manually partition disk option then click next.
II. The disk Setup Screen will appear.
III. Click New button. The Add partition dialog box appears; complete it wi
th the information that follows the corresponding field
Mount Point /boot
File System Type ext3
Allowable Drives hda
Size(MB) 200
Additional Size Option Fixed Size
Force to be a Primary Partition Leave unchecked
The completed dialog box should resemble.Click OK button When done.

IV. Now create the partitions /(root),/home,/tmp etc on an LVM partition. F


or this we need to create a parent physical volume.
Click New then Add partition dialog box appear
The Physical volume will be created with following informations ……
Mount point Leave this field blank
File system Type Physical volume(LVM)
Allowable Drive hda
Size(MB) 9216
Additional Size Option Fixed Size
Force to be a Primary partition Leave unchecked
Click OK button When done
V. Click again in the make LVM volume Group dialog box. Complete the fields
by following informations….

Mount Point Leave Blank


File System Type swap
Logical volume Name LogVol01
Size(MB) 512
Click Ok when done
VI. Click again in the make LVM volume Group dialog box. Complete the fields
by following informations….
Mount Point /home
File System Type ext3
Logical volume Name LogVol02
Size(MB) 3072
Click Ok when done
VII. Click again in the make LVM volume Group dialog box. Complete the fields
by following informations….
Mount Point /tmp
File System Type ext3
Logical volume Name LogVol03
Size(MB) 480
Click Ok when done
VIII. Click Next to Complete the Partitioning portion for installation.
Mount Point :: The location where the partition is mounted
Select File System Type – Ext3,Ext3,Swap or vfat.
Select the partition Size -- eg.Size (MB) – 400

Mount Point Size


/boot 200MB
/ 5GB
SWAP 512MB
/home 3GB
/tmp 512MB
FREE SPACE ~512MB
7. Boot loader Configuration
• DOS
Windows
RedHat
8. FireWall Configuration
• No FireWall
9. Additional Language Support
Select another Language from the list
Eg. Tamil (India)
10. Time Zone Selection
Asia Calcutta
11. Set Root Password then click Next
12. Authentication Configuration
Click Next
13. Package Group Selection
Desktop
Application
Server
Development
Systems
Miscellaneous
Click Next to begin Installation

14. Graphical Interface Configuration


Click Next
Reboot the system.
15. After getting the Welcome Screen
Accept the License and click Next
Set Date and Time
Click Next
16. Display Configuration
Set the resolution and Click Next to proceed.
17. Click continue to add user account – extra user.
18. Completion
Click Next to finish the Installation part
19. Exit
Configuring the GRUB
AIM :: Configuring the GRUB

The cofiguring file looks like as follows………….


1) # grub.conf generated by anaconda
2) # Note that you do not have to rerun grub after making changes to this
file
3) # NOTICE : you have a /boot partition. This means that
4) # all kernal and initrd paths are relative to /boot/
, eg.
5) # root (hd0,0)
6) # kernel /vmlinuz-version ro root=/dev/VolGroup0 0
/LogVol0 0
7) # initrd /initrd-version.img
8) #boot=/dev/had
9) default=0
10) timeout=5
11) splashimage=(hd0,0)/grub/splash.xpm.gz
12) Hiddenmenu
13) Title Fedora core (2.6.11-1.1369_FC4)
14) root( hd0,0)
15) kernel /vmlinuz-2.6.11-1.1369_FC4 ro root=/dev/VolGroup0 0/LogVol0 0
16) initrd initrd-2.6.11-1.1369_FC4.img

Lines 1-8 All lines that begin with the pound sign(#) are comments and are ign
ored.
Line 9 ,Default This directive tells GRUB which entry to automatically boot. T
he numbering starts from Zero.
Line 10, timeout This means that GRUB will automatically boot the default entr
y after five seconds. This can be interrupted by pressing any key in keyboard.
Line 11, splashimage This line specifies the name and location of an image fi
le to be displayed at the boot menu.
Line 12, hiddenmenu This entry hides the usual GRUB menu. It is an optional en
try.
Line 13, title This is used to display a short title or description for the fo
llowing entry it defines. The title field marks the beginning of a new boot entr
y in GRUB.
Line 14, root It is used to specify where the root partition mounted
Line 15, Kernel Used to specify path to a kernel image.
Line 16, Initrd This option allows us to load kernel modules from an image, no
t the modules from /lib/modules.

AIM :: Installing GRUB from the GRUB shell


1. Launch GRUB’s shell by issuing the grub command
# grub
GNU GRUB version 0.95 (640k lower / 3072 upper memory)
[ Minimal BASH-like line editing is supported. For the first word, TAB lists po
ssible command completions. Anywhere else TAB lists the possible completions of
a device / filename. ]
grub>
2. Display GRUB’s current root device. Type
grub> root
(fd0) : Filesystem type unknown, partition type 0x8e
The output shows that GRUB will be default use the first floppy disk drive (fd0)
as its root device unless you tell it otherwise.
3. Set GRUB’s root device to the partition that contains the boot directory o
n the local hard disk. Type
grub> root (hd0,0)
Filesystem type is ex2fs, partition type 0x83
4. Make sure that the stage1 image can be found on the root device. Type
grub> find /grub/stage1
(hd0,0)
This output means that the stage1 image was located on the (hd0,0) device.

5. Finally install the GRUB boot loader directly on the MBR of the hard dis
k. Type
grub> setup (hd0)
checking if “/boot/grub/stage1” exists. . . no
checking if “/grub/stage1” exists. . . yes
checking if “/grub/stage1” exists. . . yes
checking if “/grub/e2fs_stage1_5” exists. . . yes
Running “embed /grub/e2fs_stage1_5 (hd0,0)”. . . 16 sectors are embedded.
succeeded
Running “install /grub/stage1 (hd0) (hd0) 1+16 p (hd0,0) /grub/stage2/grub/g
rub.conf . . . succeeded
Done
6. Quit the GRUB shell. Type
grub> quit
PARTITION WITH FDISK
AIM :: Make partition with fdisk command
STEPS ::::::
1. Begin by running fdisk with the -l parameter to list the current par
tition table. Type
# fdisk -l
Disk /dev/hda : 10.7 GB, 10737418240 bytes
. . . (OUTPUT TRUNCATED) . . .
/dev/hda2 26 1200 9438187+ 8e Linux LVM
2. Next, we begin the actual repartitioning process using fdisk again. Typ
e
# fdisk /dev/hda
The number of cylinders for this disk is set to 1305
. . . (OUTPUT TRUNCATED) . . .
Booting and partitioning s/w from other Oss
( e.g. DOS FDISK, OS/2 FDISK )
Command ( m for help ) :
You will be presented with a sample fdisk prompt “Command(m for help):”
3. Print the partition table again while inside the fdisk program. Type p
at the fdisk prompt to print the partition table.
Command(m for help): p
Disk /dev/had : 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = Cylinders of 16065 * 512 = 8225280 bytes
Device boot start End Blocks Id
System
/dev/hda1 * 1 25 200781 83
Linux
/dev/hda2 26 1200 9438187+ 8e
Linux LVM

A few fact regarding the output are ::


1. The total disk size is approximately 10.7 GB
2. There are currently two partitions defined in the system.
3. From the partitioning scheme we choose during the OS installation.
4. The entire disk span 1305 cylinders.
5. The last partition hda2 ends at the 1200 cylinders.
4. Type n at the prompt to create a new partition.
Command(m for help): n
5. Type p to select primary partition type
e extended
p primary partition (1-4)
p
6. Select and type the partition number
Partition number (1-4) : 3
7. The next step is to specify the partition size. First we choose the lowe
r limit. Accept the default value for first cylinder. Type 1201
First cylinder (1201-1305, default 1201 ) : 1201
8. Specify the last cyinder
Last cylinder or +size or +sizeM or sizeK (1201-1305,default ) : 1305
9. Now change the partition type by using “ t ”
Command (m for help) : t
10. Enter the partition number whose type you want to change
Partition number (1-4) : 3

11. Enter the partition type for “Linux LVM“. Type 8e at the prompt
Hex code ( type L to list codes ) : 8e
12. View the changes made by you…….
Command (m for help) : p
Disk /dev/had : 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = Cylinders of 16065 * 512 = 8225280 bytes
Device boot start End Blocks Id
System
/dev/hda1 * 1 25 200781 8
3 Linux
/dev/hda2 26 1200 9438187+ 8e
Linux LVM
/dev/hda3 1201 1305 843412+ 8e
Linux LVM
13. Commit or write the changes to the partition table type
Command (m for help) : w
14. Quit the fdisk utility type
Command (m for help) : q
15. Now reboot the system by typing
# reboot

RedHat Package Manager ( RPM )


AIM :: To Demonstrate the functions of RedHat Package Manager ( RPM )
Explanation :: RPM allows the easy installation and removal of software packages
. An RPM file is a package that contains files needed for the software to functi
on correctly. These files can be configuration file, binaries and even pre- and
post-scripts to run while installing the software.
The primary functions of RPMs are-----------
a) Querying, installing and uninstalling software.
b) Maintaining a database that stores various items of information about th
e packages.
c) Packaging other software into an RPM form.

Frequently used RPM options are as follows ====>>>>>>>>


Querying With RPM

* Quering for All packages are currently installed in our System


# rpm --query -all
This will gives us long listing of software installed.
* Querying details of a specific package
General Form ::
rpm --query package_name
Example ::
rpm --query bash
OUTPUT :: bash- 3.0-17
* To see what the bash contains ::
rpm -qi bash
OUTPUT ::
Name : bash Relocatio
n: /usr
Version : 3.0 Vendor:
Red Hat , Inc.
Release : 17 Biuld D
ate: Tue 19 oct 2004 12:40:09 PM PDT
*******************************************************************
**
*******************************************************************
**
* To list all the files comes under the bash package
rpm -ql bash
* To list all configuration files comes under the bash package
rpm -qc bash
OUTPUT ::
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc
Many more…….
Installing with RPM ::
1. Lunch the virtual terminal.
2. Assuming your distribution install disk is mounted at /media/dvd mount p
oint,change to the directory that usually contains the RPM package on the DVD.
# cd /media/dvd/redhat/RPMS
Confirm the required package is in there or not by
# ls package_name
3. Now test to install the package using followint command
# rpm --install --verbose --hash --test package_name
Warning: package_name.rpm: V3 DSA signature: NOKEY, Key 4f56hjg67
Preparing . . . ###########################################
4. Go ahead and perform the installation
# rpm -ivh package_name.rpm
Warning: package_name.rpm: V3 DSA signature: NOKEY, Key 4f56hjg67
Preparing . . . #######################################[100%]
1:abc #######################################[100%]
5. Run a simple query to cofirm about the package installed or not
# rpm -q Package_name

Unistalling a package with RPM


# rpm -e Package_name
AIM :: Volume Mana
gement
This new approach to dealing with partitions is called Logical Volume Management
(LVM) in Linux. It lends itself to several benefits and removes the restrictions
, constraints, and limitations that the concept of partitions imposes.The benefi
ts are….
1. Greater flexibility for disk partitioning
2. Easy online resizing of volumes
3. Easy increases in storage space by simply adding new disks to the storag
e pool
4. Use of snapshots

There are following three volumes management terms available in Linux …


Physical Volume (PV) :: This typically refers to the physical hard disk(s) or ot
her physical storage entity,such as a h/w RAID array or s/w RAID devices.
Volume Group (VG) :: Volume groups are used to house one or more physical vol
umes and logical volumes into a single administrative unit. A VG is created out
of PV. VGs are simply a collection of PVs.
Logical Volume (LV) :: This perhaps is the trickiest LMV concept to grasp, becau
se losical volumes are the equivalent of disk partitions in a non LMV world. LVs
are created out of the space available in VGs.
Creating Physical Volume
1. Log in as administrator
2. First lets view the current physical volumes defined on the system. Type
# pvdisplay
--- Physical Volume ---
PV Name /dev/hda2
VG Name VolGroup0 0
PV Size 9.00 GB/not usable 0
. . . (OUTPUT TRUNCATED) . . .
3. Use the pvcreate command to initialize the partition we created erlier a
s a physical volume. Type
# pvcreate /dev/hda3
Physical volume “/dev/hda3” successfully created
4. Use the pvdisplay command to view your changes again. Type
# pvdislay
--- Physical Volume ---
PV Name /dev/hda2
VG Name VolGroup0 0
. . . (OUTPUT TRUNCATED) . . .
--- New Physical Volume ---
PV Name /dev/hda3
PV Size 823.46 MB
. . . (OUTPUT TRUNCATED) . . .
Assigning Physical Volume to Volume Group
1. First use the vgdisplay command to view the current volume groups that m
ight exists on the system. Type
# vgdisplay
--- Volume Group ---
VG Name VolGroup0 0
Format lmv2
. . . (OUTPUT TRUNCATED) . . .
VG Size 9.00 GB
PE Size 32.00 MB
Total PE 288
Alloc PE / Size 286 / 8.94 GB
Free PE / Size 2 / 64.00 MB
VG UUID JgPahd-1TBY-L5sT-tqho-KCk6-HxTy-rNCdz8
2. Assign the PV to the volume group using the vgextend command. The syntax
for the command is
Vgextend [option ] VolumeGroupName PhysicalDevice Path
# vgextend VolGroup0 0 /dev/hda3
Volume group “VolGroup0 0” successfully extended
3. To view changes type
# vgdisplay
--- Volume Group ---
VG Name VolGroup0 0
. . . (OUTPUT TRUNCATED) . . .
Act PV 2
VG Size 9.78 GB
PE Size 32.00 MB
Total PE 313
Alloc PE / Size 286 / 8.94 GB
Free PE / Size 2 / 864.00 MB

Creating a Logical Volume


1. First view the current LVs on the system. Type
# lvdisplay
--- Logical Volume ---
LV Name /dev/VolGroup0 0/LogVol0 0
VG Name VolGroup0 0
. . . (OUTPUT TRUNCATED) . . .
--- Logical Volume ---
LV Name /dev/ VolGroup0 0/LogVol0 1
VG Name VolGroup0 0
. . . (OUTPUT TRUNCATED) . . .
--- Logical Volume ---
LV Name /dev/ VolGroup0 0/LogVol0 2
VG Name VolGroup0 0
. . . (OUTPUT TRUNCATED) . . .
2. With the background information that we now have,we will create an LV us
ing the same naming convention that is currently used on the system.
# lvcreate -l 27 --name LofVol03 VolGroup0 0
. . . (OUTPUT TRUNCATED) . . .
Logical volume “LogVol3“ created
3. View the LV you created. Type
# lvdisplay /dev/VolGroup0 0/LogVol03

--- Logical Volume ---


LV Name /dev/ VolGroup0 0/LogVol0 3
VG Name VolGroup0 0
. . . (OUTPUT TRUNCATED) . . .
LV Size 864.00 MB
Current LE 27

You might also like