You are on page 1of 6

National University of Technology

Department of Computer Science


CS4012 Database Systems Lab

Instructor Name: Madam Tabinda Grade:


Batch: 2018 Session: Spring 2021
Assessment Type: Inlab+Postlab Assessment No. 04
Student Name: Ansar Iqbal Registration No. F18605005

Q. INLAB

Task 1
This activity is related to file permission. Perform the following tasks

0. Create a file “testfile.txt” in /test directory


1. View and read the file using Less command
2. Use wc command to print lines, words and bytes
3. Find any text pattern in the file using grep
4. Print the first 3 lines of the file using head
5. Print the last 3 lines of the file using tail

SOLUTION
0. Create a file “testfile.txt” in /test directory
Firstly I have created the test directory by using mkdir /test command.

Page |1
1. View and read the file using Less command

I have entered the data first before running the less command and entered the data using
CAT > command into TESTFILE.TXT as shown below.

2. Use wc command to print lines, words and bytes


In this part, I have used the wc command that is stand for word count. So have counted the
lines, words and bytes of my testfile.txt that is located on the Desktop. So in my testfile,
there are 8 lines, 63 words and 383 bytes data.

3. Find any text pattern in the file using grep


Using grep command, I have searchet the text “textual” in contents of tesfile.txt.
Wherever word TEXTUAL is present in the text, Grep command will highlight it as shown
below in screen shot.

4. Print the first 3 lines of the file using head


As task is to print first 3 lines of textual data stored in testfile.txt. So I have used the
command head –n 3, so it has printed the first 3 lines of the text as shown below.

Page |2
5. Print the last 3 lines of the file using tail
As task is to print last 3 lines of textual data stored in testfile.txt. So I have used the
command tail –n 3, so it has printed the last 3 lines of the text as shown below.

TASK NO. 02
1. Find all the files with extension txt in the /test directory

2. Find the first line of the list of files in the /test directory

I have used the command ls /test |head –n 1 to print the first line of the list of files in /test
directory.
3. Find the last line of the list of files in the /test directory
I have used the command ls /test |head –n 1 to print the first line of the list of files in /test
directory.

Page |3
4. Produce and view a single sorted list of files by combining two directories: /Desktop and
/bin
I have used the command for above operation
and then following operations shown.

TASK No. 3
Perform the following tasks

1. Examine the network using Ping command and view the performance statistics
I have checked the networks using “PING LOCALHOST” command and the statics data is
show below from localhost….. This information is continuing processing and after few
steps I have Enter CTRL + C to stop this command for being running.

Page |4
2. displays a listing of all the “hops” network traffic takes to get from the local system to
yahoo.com

I was running tracerout yahoo.com command, but was successful due traceroute funcatinonaliy
was not install. So first I intalled it as show above and below.

I found this result utp 30th number.

Page |5
3. examine various network settings and statistics through netstat

I have used the command “NETSTAT -R” and then I came to known about the above
network settings and its statics. Netstat command can also be used to diagnose network
issues and service problems.

<***************************END**************************>

Page |6

You might also like