Operating Systems Lab Task -1

UNIX File and Directory Management Lab Task

Objective: Practice common UNIX commands for file and directory manipulation.

Instructions: Perform each task in your UNIX/Linux terminal. Verify each step's completion before moving to the next.


Task List:

  1. Environment Setup:

    • Create a new directory named unix_lab in your home directory.

    • Change your current directory to unix_lab.

    • Confirm your current working directory.

  2. File and Directory Creation:

    • Create three empty files: document1.txt, notes.md, and report.log.

    • Create two subdirectories within unix_lab: projects and backups.

    • List all files and directories (including detailed information) in unix_lab to verify their creation.

  3. File Content Management:

    • Add the line "This is the content for document one." to document1.txt.

    • Append the line "This is the second line." to document1.txt.

    • Add "# My Daily Notes", "* Remember to buy groceries", and "* Schedule meeting with John" (each on a new line) to notes.md.

    • Display the complete content of document1.txt.

    • Show only the first line of notes.md.

    • Display the last two lines of notes.md.

  4. File Manipulation (Copying, Moving, Renaming):

    • Copy document1.txt into the backups directory.

    • Verify document1.txt is present in backups.

    • Rename notes.md to daily_notes.md in the current directory.

    • Move report.log into the projects directory.

    • Verify report.log is now in projects.

  5. Searching:

    • From within unix_lab, find all files with the .txt extension.

    • Search for the word "content" within document1.txt.

    • Search for the word "meeting" within daily_notes.md.

  6. Archiving and Compression:

    • Navigate back to your home directory.

    • Create a tar archive of the entire unix_lab directory, naming it unix_lab_archive.tar.

    • Compress unix_lab_archive.tar using gzip.

    • Confirm that unix_lab_archive.tar.gz exists.

  7. Cleanup:

    • Create a new directory named extracted_lab.

    • Move unix_lab_archive.tar.gz into extracted_lab.

    • Change into the extracted_lab directory.

    • Decompress unix_lab_archive.tar.gz.

    • Extract the contents of unix_lab_archive.tar.

    • Navigate back to your home directory.

    • Delete the original unix_lab directory and all its contents. (Exercise caution!)

    • Delete the unix_lab_archive.tar.gz file.

    • Delete the extracted_lab directory and all its contents.

    • Verify that unix_lab, unix_lab_archive.tar.gz, and extracted_lab are no longer present in your home directory.

Comments

Popular posts from this blog

Shell Scripting Codes - Loops

shell script collection

OS Lab Record