Lab Task (1)
Lab Task (1)
Lab Task
Department of Computer Science
Q:01 [CLO-07]
1. Explain how the open (), read(), and write() system calls work in a Linux environment.
Illustrate with an example of reading from and writing to a file.
2. Discuss the file protection methods available in Linux. How do the commands chmod,
chown, and chgrp contribute to file security?
3. Describe the difference between single-level and tree-structured directories in Linux.
Which command would you use to navigate a tree-structured directory?
4. What is the purpose of mounting a file system in Linux? Describe the steps to mount
and unmount an external device using the mount and umount commands.
5. Compare and contrast contiguous allocation and linked allocation methods in Linux.
Provide scenarios where each method is advantageous.
6. How does indexed allocation improve file access efficiency? Describe how the inode
structure in Linux uses indexed allocation for file management.
7. How does indexed allocation improve file access efficiency? Describe how the inode
structure in Linux uses indexed allocation for file management.
8. Write a C program to create a file named example.txt, write the text "Hello, Linux File
Systems!" into it, close the file, and then read the contents back to display them on the
console.
9. Write a shell script to create a file named securefile.txt, change its permissions to 750,
and display the permissions using the ls -l command.
10. Write a series of Linux terminal commands to create the following directory structure:
/home/student
── projects
└── linux_fs
├── data
└── scripts
Navigate to the linux_fs directory and create an empty file named notes.txt inside the data
folder.
11. Assume you have a USB drive connected at /dev/sdb1. Write the commands to create a
mount point at /mnt/usbdrive, mount the USB drive, list its contents, and then unmount
it.
12. Write a shell script that displays the disk usage of the /home directory and lists the five
largest files or directories within it.