OS lab2
OS lab2
Engineering
And Technology Taxila
LAB 2
Activity 1:
1. Display your current directory.
8. Stay where you are, and list the contents of /bin and /sbin.
10. List all the files (including hidden files) in your home directory.
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 ~
5. Create a directory “mydir1” in Desktop Directory. Inside mydir1 create another directory “mydir2”.
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
3. Append myfile with text “Hello World again” 24 Created by Sheharyar Khan ([email protected])
Solution:
1. cd /home/Documents/mydir3 (suppose the user name is ubuntu)
cat >myfile
2. cat > myfile type: Hello World type: ctrl + d
4. cat myfile
Activity 4:
Considering the above activities, perform the following tasks
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
Solution:
1. cd /home/ubuntu/Desktop
2. ls -l > out-put-file
3. cat out-put-file