Operating Systems Lab Manual # 2: File Systems and Shell Commands Objective: The primary objective of Lab 2 is to deepen your understanding of file systems in a Unix-like environment and enhance your proficiency in using essential shell commands. Additionally, you'll delve into basic shell scripting to automate tasks and explore advanced file system operations. Pre-requisites: • Basic understanding of Linux/Unix commands. • Completion of Lab 1. Lab Setup: 1. 2. Virtual Machine Setup: • Ensure that your virtual machine (VM) is running Ubuntu 23.08 LTS. • Confirm the installation of VMware/VirtualBox tools. Terminal Basics: • Open a terminal in Ubuntu to execute commands. • Familiarize yourself with basic commands: Tasks: 1. File System Exploration: Use the commands ls, cd, and pwd to navigate through the file system. Create a new directory and move into it. Create a few text files and directories inside the newly created directory. 2. Basic Shell Scripting: Create a shell script file (e.g., myscript.sh ) using a text editor. Write a script that prints a welcome message and the current date and time. Save the file, give execute permissions ( chmod +x myscript.sh), and run it. 3. File Operations: Copy a file from one directory to another. Move a file to a different location and rename it. Delete a directory and its contents. 4. Search and Display: Use the find command to search for a specific file. Display the manual page for a command of your choice. 5. Advanced Commands: Use head and tail commands to view the first and last few lines of a file, respectively. Experiment with other advanced commands (e.g., grep, chmod, chown). Examples: 1. File System Exploration: # Navigate to the home directory cd ~ # Display the current directory pwd # List files and directories ls # Change directory cd Documents # Create a new directory mkdir Lab2 # Move into the new directory cd Lab2 # Create text files and directories touch file1.txt file2.txt mkdir dir1 dir2 2. Basic Shell Scripting: Create a file named myscript.sh and add the following content: # Open a text editor to create the script file nano myscript.sh #!/bin/bash # Print a welcome message echo "Welcome to my script!" # Print the current date and time date Save the file, give execute permissions, and run it: # Save the file (in nano, press Ctrl + X, then Y, then Enter) # Give execute permissions chmod +x myscript.sh # Run the script ./myscript.sh 3. File Operations: # Copy a file from one directory to another cp file1.txt /path/to/destination/ # Move a file to a different location and rename it mv file1.txt ../Lab2/newfile.txt # Delete a directory and its contents rm -r ../Lab2 4. Search and Display: # Use find to search for a specific file find / -name myfile.txt # Display the manual page for the ls command man ls 5. Advanced Commands: # View the first few lines of a file head file1.txt # View the last few lines of a file tail file1.txt # Experiment with other commands (e.g., grep, chmod, chown) grep "pattern" file.txt chmod 755 script.sh chown user:group file.txt 6. Reflection: Document your experience and observations during the lab. For example: Did you encounter any challenges in navigating the file system or using certain commands? How did you overcome any challenges? What new things did you learn during the lab? Feel free to adapt these examples based on your VM setup and specific tasks in the lab.