0% found this document useful (0 votes)
223 views12 pages

Practical No 1 (Linux OS)

The document discusses installing and configuring Linux using VirtualBox. It provides steps to download VirtualBox, allocate RAM, install Linux by selecting drive options and username/password. It also discusses using pipes to concatenate Linux commands like sort, grep, head, tail and wc. Finally, it covers using grep family commands like grep, egrep for pattern searching with options like -i, -c, -l, -n, -w and -o.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
223 views12 pages

Practical No 1 (Linux OS)

The document discusses installing and configuring Linux using VirtualBox. It provides steps to download VirtualBox, allocate RAM, install Linux by selecting drive options and username/password. It also discusses using pipes to concatenate Linux commands like sort, grep, head, tail and wc. Finally, it covers using grep family commands like grep, egrep for pattern searching with options like -i, -c, -l, -n, -w and -o.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Practical No.

1
Aim : Install and configure Linux Operating system environment

Install Linux Using Virtual Box


Steps:
1. Download the VIRTUAL BOX from original ORACLE VIRTUAL BOX site. You can
refer below link

https://www.virtualbox.org/

2. Install Linux Using Virtual Box

Use the .iso file or ISO file that can be downloaded from the internet and start the virtual box.

Here we need to allocate RAM to virtual OS. It should be 2 GB as per minimum requirement.

 Choose an option under Create a virtual disk.


 Choose a type of storage on physical hard disk. And choose the disk size(min 12 GB as
per requirement)
 Click on create option and then click on the START button to start the virtual box and
browse to the location of the .iso file of the OS.

 Now Linux OS will start, Click on install option.


 Select the drive for completing the OS installation. Select “Erase Disk and install
Ubuntu” in case you want to replace the existing OS otherwise select “Something else”
option and click INSTALL NOW.
 Click on Continue.
 Choose a username and password.
You are almost done. It should take 10-15 minutes to complete the installation. Once the
installation finishes, restart the system.

Conclusion :
Thus we successfully installed and configure Linux Operating System using Virtual Box.
Practical No. 2
Aim : Use pipe to concatenate the general purpose linux command.
Theory:
Pipes help combine two or more commands and are used as input/output concepts in a command.
In the Linux operating system, we use more than one pipe in command so that the output of one
command before a pipe acts as input for the other command after the pipe.
Syntax:
Command 1 | command 2 | command 3 | ……

Examples:
sort :The data present in the file is unordered. So, This will sort the given file.
Command : cat Branch.txt | sort
Output:

Grep:
The grep filter
searches a file for
a particular
pattern of
characters, and displays all lines that contain that pattern.
Command: $ cat Branch.txt | grep Computer
Output :

head :
Command: $ cat Branch.txt | head -4
Output :

tail :
Command : $ cat Branch.txt |tail -4
Output :

wc :
Command :$ cat Branch.txt | wc
Output :

Conclusion:
As a result, we have performed Shell script by using pipe to concatenate general purpose linux
command.
Practical No.3
Aim : Use pattern searching using grep family commands.
Grep command is used to search for a particular character string in a file.The basic syntax of
the grep command is:

The grep filter searches a file for a particular pattern of characters, and displays all lines that
contain that pattern. The pattern that is searched in the file is referred to as the regular
expression (grep stands for global search for regular expression and print out). 

Syntax: 
 
grep [options] pattern filename
 
Options Description
-c : This prints only a count of the lines that match a pattern
-h : Display the matched lines, but do not display the filenames.
-i : Ignores, case for matching
-l : Displays list of a filenames only.
-n : Display the matched lines and their line numbers.
-v : This prints out all the lines that do not matches the pattern
-e exp : Specifies expression with this option. Can use multiple times.
-f file : Takes patterns from file, one per line.
-E : Treats pattern as an extended regular expression (ERE)
-w : Match whole word
-o : Print only the matched parts of a matching line,
with each such part on a separate output line.

1. Case insensitive search : The -i option enables to search for a string case insensitively in the
given file. It matches the words like “UNIX”, “Unix”, “unix”. 
Command :$ grep -i file.txt
Output:

2. Displaying the count of number of matches : We can find the number of lines that matches
the given string/pattern 
 
Command: $grep -c "Linux” file.txt
Output:
3. Display the file names that matches the pattern : We can just display the files that contains
the given string/pattern. 
 Command: $ grep
Output:

4. Checking for the whole words in a file : By default, grep matches the given string/pattern
even if it is found as a substring in a file. The -w option to grep makes it match only the whole
words. 
 Command : $ grep -w "system" file.txt
Output:

5. Displaying only the matched pattern : By default, grep displays the entire line which has
the matched string. We can make the grep to display only the matched string by using the -o
option. 
 Command: $ grep -o "Linux" file.txt
Output:
Conclusion:
Thus we have successfully,performed shell scripting using grep command family for searching
pattern.

You might also like