We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
Linux Practices: Using tar and gzip
Using tar
Practice 1: Creating a Tar Archive
Objective: Use tar to create an archive of multiple files. Instructions: 1. Create a directory named Avengers with the following files: IronMan.txt, Thor.txt, Hulk.txt. touch Avengers/{IronMan.txt,Thor.txt,Hulk.txt} 2. Create a tar archive named Avengers.tar: tar -cvf Avengers.tar Avengers/ 3. Verify the archive by listing its contents: tar -tvf Avengers.tar
Practice 2: Extracting a Tar Archive
Objective: Use tar to extract files from an archive. Instructions: 1. Extract the contents of Avengers.tar into a new directory: mkdir ExtractedAvengers tar -xvf Avengers.tar -C ExtractedAvengers/ 2. Verify that the files were extracted successfully by listing the ExtractedAvengers directory.
Practice 3: Compressing a Tar Archive
Objective: Use tar to create a compressed archive. Instructions: 1. Compress the Avengers directory into a gzip-compressed archive: tar -czvf Avengers.tar.gz Avengers/ 2. Verify the archive by listing its contents: tar -tzvf Avengers.tar.gz
Practice 4: Extracting a Compressed Archive
Objective: Use tar to extract files from a compressed archive. Instructions: 1. Extract the contents of Avengers.tar.gz into a new directory: mkdir ExtractedCompressedAvengers tar -xzvf Avengers.tar.gz -C ExtractedCompressedAvengers/ 2. Verify that the files were extracted successfully by listing the ExtractedCompressedAvengers directory.
Practice 5: Archiving Specific Files
Objective: Use tar to create an archive of selected files. Instructions: 1. Create files Thor.txt and Hulk.txt in the Avengers directory. 2. Archive only these two files into SelectedHeroes.tar: tar -cvf SelectedHeroes.tar Avengers/Thor.txt Avengers/Hulk.txt 3. Verify the contents of the archive: tar -tvf SelectedHeroes.tar
Using gzip
Practice 6: Compressing a File with gzip
Objective: Use gzip to compress a single file. Instructions: 1. Create a file named MissionLog.txt with some content: seq 1 100 > MissionLog.txt 2. Compress the file using gzip: gzip MissionLog.txt 3. Verify that the file has been compressed by listing it: ls -lh MissionLog.txt.gz
Practice 7: Decompressing a File with gzip
Objective: Use gzip to decompress a file. Instructions: 1. Decompress the MissionLog.txt.gz file: gzip -d MissionLog.txt.gz 2. Verify that the original file is restored: ls -lh MissionLog.txt
Practice 8: Viewing the Contents of a Compressed File
Objective: Use gzip with zcat to view a compressed file without extracting it. Instructions: 1. Compress MissionLog.txt again: gzip MissionLog.txt 2. View its contents without decompressing: zcat MissionLog.txt.gz
Practice 9: Compressing Multiple Files
Objective: Use gzip to compress multiple files simultaneously. Instructions: 1. Create files Hero1.txt, Hero2.txt, and Hero3.txt: touch Hero1.txt Hero2.txt Hero3.txt 2. Compress all the files at once: gzip Hero*.txt 3. Verify that all files have been compressed by listing them: ls -lh
Practice 10: Combining tar and gzip
Objective: Use tar and gzip together to create and compress an archive. Instructions: 1. Create a tar archive of the Avengers directory: tar -cvf Avengers.tar Avengers/ 2. Compress the tar archive using gzip: gzip Avengers.tar 3. Verify the compressed archive: ls -lh Avengers.tar.gz
TAN, MEA S. Unlocking Writing Potential The Impact of Multisensory Activities On The Writing Skills of Struggling Kindergarten Learners of Leon Consumo Memorial Elementary School