Tar Flashcards
What does tar stand for?
tape archive
tar can quickly join together multiple files into one larger file, while still preserving ______.
meta-data such as Unix permissions
By default, tar does not compress files, but it does have a flag that will compress the archive using ____.
gzip
A very simple archive built using tar is called a _____.
tarball
How would we create a tarball of all of the files in the tools directory?
tar -c tools/
What is the “gibberish” preceding each of the files that make up a tarball?
Unix meta-data of that file; including such things as the permissions, file’s owner, group, etc.
If you don’t use the -f flag when using tar, where does the archive go?
It’s printed to stdout, which is useful when you want to pipe the output of the archive into another command.
How would you create a tarball and save it to a file?
tar -cf foo.tar tools/
[command] [flags] [file to be created] [directory]
What flag can we use to see which files are being added to the archive?
-v
verbose mode
How can we pass multiple directories to the tar command?
just tack them on at the end
How can we create a tarball from a list of files generated by a find command?
find . -name *.gemspec | tar -cvf gemspecs.tar -T -
- T flag reads in a list of file names from another file
- tells tars that it should read in the list of files from the find query
What does the -T flag do?
Reads in a list of file names from another file.
How can you list the files in an existing archive?
using the -t flag
tar -tf foo.tar
How can we append additional files to a non-compressed archive?
with the -r flag
tar -rvf foo.tar Gemfile README.md
How can we update a specific file within an uncompressed archive?
with the -u flag
tar -uvf foo.tar version.rb
What flag do we use to extract all of the files into the current directory?
-x
tar -xvf foo.tar
How can we extract a single file from the archive?
tar -xvf foo.tar rails.gemspec
list the file name(s) after the command and arguments
How can we extract files to a different directory?
using the -C flag
tar -xvf foo.tar -C ./myfolder
Which three compression algorithms does tar provide?
gzip (-z)
bzip2 (-j)
unix compress (-Z)
What is the convention for showing that a file has been compressed?
appending .gz to the end of the archive’s name
How would we create a compressed archive from “ar.tar”
tar -zf ar.tar.gz
tar flags name.gz
How can we extract files from a compressed archive?
add the -z flag to the extract command so that it first uncompresses the archive and then extracts the files:
tar -xvzf ar.tar.gz