0
0
Linux CLIscripting~5 mins

tar (create and extract archives) in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the tar command do in Linux?
The tar command bundles multiple files and directories into a single archive file. It can also extract files from such archives.
Click to reveal answer
beginner
How do you create a compressed archive named backup.tar.gz of a directory called myfolder?
Use the command: tar -czf backup.tar.gz myfolder. <br>Here, -c creates an archive, -z compresses with gzip, and -f specifies the archive file name.
Click to reveal answer
beginner
How do you extract files from an archive named archive.tar.gz?
Use the command: tar -xzf archive.tar.gz. <br>-x extracts files, -z decompresses gzip, and -f specifies the archive file.
Click to reveal answer
beginner
What option shows the list of files inside a tar archive without extracting?
Use tar -tf archive.tar. <br>-t lists the contents, -f specifies the archive file.
Click to reveal answer
intermediate
Explain the difference between tar -cf and tar -czf.
tar -cf creates an uncompressed archive file. <br>tar -czf creates a gzip compressed archive, making the file smaller.
Click to reveal answer
Which tar option is used to extract files from an archive?
A-z
B-c
C-t
D-x
What does the -f option do in the tar command?
AForces overwrite of files
BFilters files by name
CSpecifies the archive file name
DFormats the archive
How do you create a tar archive without compression?
Atar -cf archive.tar folder
Btar -czf archive.tar.gz folder
Ctar -xzf archive.tar.gz
Dtar -tf archive.tar
Which command lists the contents of files.tar without extracting?
Atar -xf files.tar
Btar -tf files.tar
Ctar -cf files.tar
Dtar -czf files.tar
What compression does tar -czf use by default?
Agzip
Bxz
Cbzip2
Dzip
Describe how to create a compressed tar archive of a folder and then extract it.
Think about the options for create, extract, compression, and file name.
You got /4 concepts.
    Explain how to check what files are inside a tar archive without extracting them.
    Listing contents is different from extracting.
    You got /3 concepts.