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_labin 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:projectsandbackups.List all files and directories (including detailed information) in
unix_labto 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.txtinto thebackupsdirectory.Verify
document1.txtis present inbackups.Rename
notes.mdtodaily_notes.mdin the current directory.Move
report.loginto theprojectsdirectory.Verify
report.logis now inprojects.
Searching:
From within
unix_lab, find all files with the.txtextension.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_labdirectory, naming itunix_lab_archive.tar.Compress
unix_lab_archive.tarusinggzip.Confirm that
unix_lab_archive.tar.gzexists.
Cleanup:
Create a new directory named
extracted_lab.Move
unix_lab_archive.tar.gzintoextracted_lab.Change into the
extracted_labdirectory.Decompress
unix_lab_archive.tar.gz.Extract the contents of
unix_lab_archive.tar.Navigate back to your home directory.
Delete the original
unix_labdirectory and all its contents. (Exercise caution!)Delete the
unix_lab_archive.tar.gzfile.Delete the
extracted_labdirectory and all its contents.Verify that
unix_lab,unix_lab_archive.tar.gz, andextracted_labare no longer present in your home directory.
0 Comments