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

OS lab2

This document outlines a series of activities and solutions related to operating systems, specifically using the Linux command line interface. It includes tasks such as navigating directories, creating and managing files and directories, and performing I/O redirection. Each activity is accompanied by step-by-step commands to achieve the desired outcomes.

Uploaded by

Hajra Wajid
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)
3 views

OS lab2

This document outlines a series of activities and solutions related to operating systems, specifically using the Linux command line interface. It includes tasks such as navigating directories, creating and managing files and directories, and performing I/O redirection. Each activity is accompanied by step-by-step commands to achieve the desired outcomes.

Uploaded by

Hajra Wajid
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/ 8

university of

Engineering
And Technology Taxila

OPERATING SYSTEM (OS)

Name: Hajra Wajid


Reg no. : 23-cp-60
Submitted to: Engr. Sheheryar Khan
Report : 2nd

LAB 2
Activity 1:
1. Display your current directory.

2. Change to the /etc directory.

3. Go to the parent directory of the current directory.

4. Go to the root directory.

5. List the contents of the root directory.

6. List a long listing of the root directory.

7. Stay where you are, and list the contents of /etc.

8. Stay where you are, and list the contents of /bin and /sbin.

9. Stay where you are, and list the contents of ~.

10. List all the files (including hidden files) in your home directory.

11. List the files in /boot in a human readable format.

Solution:
1. pwd

2. cd /etc

3. cd ..

4. cd /

5. ls
6. ls -l

7. ls /etc

8. ls /bin /sbin
9. ls ~

10. ls -al ~

11. ls -lh /boot


Activity 2:
Perform the following tasks using Linux CLI

5. Create a directory “mydir1” in Desktop Directory. Inside mydir1 create another directory “mydir2”.

6. Change your current directory to “mydir2” using absolute path

7. Now, change you current directory to Documents using relative path

8. Create mydir3 directory in Documents directory and go into it

9. Now, change your current directory to mydir2 using relative path

Solution:
1. cd /home/Ubuntu/Desktop (suppose the user name is ubuntu)

mkdir mydir1

cd mydir1

mkdir mydir2
2. cd /home/ubuntu/Desktop/mydir1/mydir2

3. cd ../../../Desktop

4. mkdir mydir3

cd mydir3

5. cd ../../Desktop/mydir1/mydir2

Activity 3:
1. Go to mydir3 and create an empty file myfile using cat command

2. Add text the text “Hello World” to myfile

3. Append myfile with text “Hello World again” 24 Created by Sheharyar Khan ([email protected])

4. View the contents of myfile

Solution:
1. cd /home/Documents/mydir3 (suppose the user name is ubuntu)

cat >myfile
2. cat > myfile type: Hello World type: ctrl + d

3. cat >> myfile type: Hello World again type: ctrl + d

4. cat myfile

Activity 4:
Considering the above activities, perform the following tasks

1. move myfile to mydir1

2. copy myfile to mydir2

3. copy mydir2 on Desktop

4. delete mydir1 (get confirmation before deleting)

5. Rename myfile to mynewfile

Solution:
1. mv /home/ubuntu/Document/mydir3/myfile /home/ubuntu/Desktop/mydir1

2. cp /home/ubuntu/Desktop/mydir1/mydir3/myfile /home/ubuntu/Desktop/mydir1/mydir2

3. cp -r /home/ubuntu/Desktop/mydir1/mydir2 /home/ubuntu/Desktop

4. rm -ri /home/ubuntu/Desktop/mydir1
5. mv /home/ubuntu/Desktop/mydir2/myfile /hoem/ubuntu/Desktop/mydir2/mynewfile

Activity 5:
This activity is related to I/O redirection

1. Go to Desktop directory 25 Created by Sheharyar Khan ([email protected])

2. Write the long-listing of contents of Desktop on an empty file out-put-file

3. View contents of out-put-file

Solution:
1. cd /home/ubuntu/Desktop

2. ls -l > out-put-file

3. cat out-put-file

You might also like