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:
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.
File and Directory Creation:
Create three empty files:
document1.txt
,notes.md
, andreport.log
.Create two subdirectories within
unix_lab
:projects
andbackups
.List all files and directories (including detailed information) in
unix_lab
to verify their creation.
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
.
File Manipulation (Copying, Moving, Renaming):
Copy
document1.txt
into thebackups
directory.Verify
document1.txt
is present inbackups
.Rename
notes.md
todaily_notes.md
in the current directory.Move
report.log
into theprojects
directory.Verify
report.log
is now inprojects
.
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
.
Archiving and Compression:
Navigate back to your home directory.
Create a tar archive of the entire
unix_lab
directory, naming itunix_lab_archive.tar
.Compress
unix_lab_archive.tar
usinggzip
.Confirm that
unix_lab_archive.tar.gz
exists.
Cleanup:
Create a new directory named
extracted_lab
.Move
unix_lab_archive.tar.gz
intoextracted_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
, andextracted_lab
are no longer present in your home directory.
Comments
Post a Comment