0% found this document useful (0 votes)
1K views11 pages

Linux Lab Manual (cs-505)

Here are the steps to compare two files and display only matching lines: 1. Use comm command to compare the two sorted files containing student names 2. The comm command will output 3 columns - lines unique to file1, lines unique to file2, lines common to both 3. Use the -12 option to suppress the first two columns and display only the common lines 4. This will show the student names that are present in both files. The comm command is an efficient way to find matching lines between two files in Unix/Linux.

Uploaded by

Ketan Soni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views11 pages

Linux Lab Manual (cs-505)

Here are the steps to compare two files and display only matching lines: 1. Use comm command to compare the two sorted files containing student names 2. The comm command will output 3 columns - lines unique to file1, lines unique to file2, lines common to both 3. Use the -12 option to suppress the first two columns and display only the common lines 4. This will show the student names that are present in both files. The comm command is an efficient way to find matching lines between two files in Unix/Linux.

Uploaded by

Ketan Soni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

DEPARTMENT OF

COMPUTER SCIENCE AND ENGINEERING

Name of Student : …………………..

Name of Lab : Lab (Linux)

Subject Code : CS- 505

Branch : Computer Science and Engineering

Year/Sem : III/V

Affiliated to Rajiv Gandhi Prodyogiki Vishwavidyalaya, Bhopal (MP)


INDEX
S. No. Name of Experiment Date Sign Remark

1. Introduction to Unix/Linux operating system.

2. Installation, Configuration & Customizations of Unix/Linux.

3. To Study basic & User status Unix/Linux Commands.

4. Study & use of commands for performing arithmetic operations


with Unix/Linux.

5 Create a file called wlcc.txt with some lines and display how many
lines, words and characters are present in that file.

6 Append ten more simple lines to the wlcc.txt file created above and
split the appended file into 3 parts. What will be the names of these
split files? Display the contents of each of these files. How many lines
will be there on the last file?

7 Given two files each of which contains names of students. Create a


program to display only those names that are found on both the
files.

8 Create a program to find out the inode number of any desired file.

9 Study & use of the Command for changing file permissions.

10 Write a pipeline of commands, which displays on the monitor as


well as saves the information about the number of users using the
system.

11 Execute shell commands through vi editor.

12 Write a shell script that accepts any number of arguments and prints
them in the reverse order.

13 Write a shell script to find the smallest of three numbers that are
read from the keyboard.

14 Study & installation of Firewall & Proxy server.


List of Experiments
Lab(Linux)(CS- 505)
1. Introduction to Unix/Linux operating system..

2. Installation, Configuration & Customizations of Unix/Linux.

3. To Study basic & User status Unix/Linux Commands.

4. Study & use of commands for performing arithmetic operations with Unix/Linux.

5. Create a file called wlcc.txt with some lines and display how many lines, words and
characters are present in that file.

6. Append ten more simple lines to the wlcc.txt file created above and split the appended file
into 3 parts. What will be the names of these split files? Display the contents of each of
these files. How many lines will be there on the last file?

7. Given two files each of which contains names of students. Create a program to display
only those names that are found on both the files.

8. Create a program to find out the inode number of any desired file.

9. Study & use of the Command for changing file permissions.

10. Write a pipeline of commands, which displays on the monitor as well as saves the
information about the number of users using the system.

11. Execute shell commands through vi editor.

12. Write a shell script that accepts any number of arguments and prints them in the reverse
order

13. Write a shell script to find the smallest of three numbers that are read from the
keyboard.

​ 14.​ Study & installation of Firewall & Proxy server.


EXPERIMENT NO. 1
Unit/Topic: 1/ Introduction
PROBLEM DEFINITION:
Introduction to Unix/Linux operating system

OBJECTIVE:
To understand the basics of Unix/Linux.

THEORY INVOLVED:

EXPECTED VIVA QUESTIONS:

Q.1 What is Linux?


Q.2 Difference between Unix and Linux.
Q.3 Explain Linux Features.

NAME OF FACULTY:

SIGNATURE:

DATE:
EXPERIMENT NO. 2
Unit/Topic: 7/ Installation
PROBLEM DEFINITION:
Installation, Configuration & Customizations of Unix/Linux.

OBJECTIVE:
To understand the Installation, Configuration & Customizations of Unix/Linux.

THEORY INVOLVED:

EXPECTED VIVA QUESTIONS:

Q.1 How will you get the details about Ubuntu in computer?
Q.2 What do you Mean by Swap space partition and why swapping is required?
Q.3 What are the different types of OS ?

NAME OF FACULTY:

SIGNATURE:

DATE:
EXPERIMENT NO. 3
Unit/Topic: 2/ Basic commands
PROBLEM DEFINITION:
To Study basic & User status Unix/Linux Commands.

OBJECTIVE:
To understand the use of basic commands.

THEORY INVOLVED:
UNIX commands can often be grouped together to make even more powerful commands.
Unix General Purpose commands: ​date, who, who am I,cal,echo.

File Handling utilities​:


Directory related commands : pwd,mkdir,cd,rmdir,ls
File related commands: cat, cp, mv, rm, chmod, chown, chgrp, file, find,touch
Filters: cat, head, tail, cut, paste, cmp, comm, sort, more, less, etc.
Network Related commands​: telnet, ftp, rlogin, arp

Disk and backup utilities : ​df, du and cpio ,tar

Advanced filters : ​grep

INPUT SET:

OUTPUT SET:

EXPECTED VIVA QUESTIONS:


Q.1 Difference between who and who am i command.
Q.2 How to use filter commands?
Q.3 Explain about various file handling commands.
NAME OF FACULTY:
SIGNATURE:
DATE:
EXPERIMENT NO. 4
Unit/Topic: 2/ Arithmetic Operation
PROBLEM DEFINITION:
Study & use of commands for performing arithmetic operations with Unix/Linux.

OBJECTIVE:
Implementation of arithmetic commands.

THEORY INVOLVED:
1. Log in to the system
2. Open Ubuntu terminal
3. Type bc

The most basic element in bc is the number. BC stands for “Basic calculator” Numbers are arbitrary
precision numbers. This precision is both in the integer part and the fractional part. All numbers are
represented
internally in decimal and all computation is done in decimal.

INPUT SET:

OUTPUT SET:

EXPECTED VIVA QUESTIONS:


Q.1 What is bc commands?
Q.2 How to get floating point result by using bc commands?
Q.3 How to perform different operations using bc commands?

NAME OF FACULTY:
SIGNATURE:
DATE:
EXPERIMENT NO. 5
Unit/Topic: 3/ File commands
PROBLEM DEFINITION:
Create a file called wlcc.txt with some lines and display how many lines, words and characters are
present in that file.

OBJECTIVE:
To implement commands of file system.

THEORY INVOLVED:
wc (Stands for word count) is a command in Unix-like operating systems.

The program reads either standard input or a list of files and generates one or more of the following
statistics: newline count, word count, and byte count.

Syntax:

wc <filename>

Options:

wc -l <filename> print the line count

wc -c <filename> print the byte count

wc -m <filename> print the character count

wc -L <filename> print the length of longest line

wc -w <filename> print the word count


Steps:

1. Log in to the system

2. Use Ubuntu terminal to create a file called wlcc.txt by using cat

command which contain some text.

3. Correct typing errors during creation

4. Save the file

5. Type wc command to display lines, word, character

6. Logout of the file

INPUT SET:

OUTPUT SET:

EXPECTED VIVA QUESTIONS:

Q.1 What is use of wc command?


Q.2 Difference file and directory.
Q.3 How to find number of characters in a file?

NAME OF FACULTY:

SIGNATURE:

DATE:
EXPERIMENT NO. 6
Unit/Topic: 3/File commands
PROBLEM DEFINITION:
Append ten more simple lines to the wlcc.txt file created above and split the appended file into 3 parts.
What will be the names of these split files? Display the contents of each of these files. How many lines
will be there on the last file?
.
OBJECTIVE:
To understand the concept to splitting file.

THEORY INVOLVED:
Split is a UNIX utility most commonly used to split a file into two or more smaller files.
The command-syntax is: split [option] [Input] [Prefix]
The default behavior of split is to generate output files of a fixed size, default 1000 lines. The files are
named by appending aa, ab, ac, etc. to output filename. If the output filename is not given, the default
filename of x is used, for example, xaa, xab, etc. When a hyphen (-) is used instead of input filename,
data is derived from standard input .

INPUT SET:

OUTPUT SET:

EXPECTED VIVA QUESTIONS:

Q.1 What is split command?


Q.2 Difference between append and split.
Q.3 What are the names of splitted files?

NAME OF FACULTY:
SIGNATURE:
DATE:
EXPERIMENT NO. 7
Unit/Topic: 3/ Comparing file
PROBLEM DEFINITION:
Given two files each of which contains names of students.Create a program to display only those names
that are found on both the files..

OBJECTIVE:
To understand the concept of comparing files.

THEORY INVOLVED:
Comm : Compare two sorted files line-by-line.
Syntax :​Comm [option] ... File 1 file 2
Compare sorted files FILE1 and FILE2 line-by-line. With no options, comm produces three-column
output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and
column three contains lines common to both files. Each of these columns can be suppressed
individually with options.
Options
-1 suppress column 1 (lines unique to FILE1)
-2 suppress column 2 (lines unique to FILE2)
-3 suppress column 3 (lines that appear in both files)

INPUT SET:

OUTPUT SET:

EXPECTED VIVA QUESTIONS:


Q.1 What is the use of comm command?
Q.2 Difference between cmp and comm command.
Q.3 How to display unique content of file?

NAME OF FACULTY:
SIGNATURE:
DATE:

You might also like