Tar Flashcards

1
Q

What does tar stand for?

A

tape archive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

tar can quickly join together multiple files into one larger file, while still preserving ______.

A

meta-data such as Unix permissions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

By default, tar does not compress files, but it does have a flag that will compress the archive using ____.

A

gzip

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A very simple archive built using tar is called a _____.

A

tarball

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How would we create a tarball of all of the files in the tools directory?

A

tar -c tools/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the “gibberish” preceding each of the files that make up a tarball?

A

Unix meta-data of that file; including such things as the permissions, file’s owner, group, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

If you don’t use the -f flag when using tar, where does the archive go?

A

It’s printed to stdout, which is useful when you want to pipe the output of the archive into another command.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How would you create a tarball and save it to a file?

A

tar -cf foo.tar tools/

[command] [flags] [file to be created] [directory]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What flag can we use to see which files are being added to the archive?

A

-v

verbose mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can we pass multiple directories to the tar command?

A

just tack them on at the end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can we create a tarball from a list of files generated by a find command?

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does the -T flag do?

A

Reads in a list of file names from another file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you list the files in an existing archive?

A

using the -t flag

tar -tf foo.tar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can we append additional files to a non-compressed archive?

A

with the -r flag

tar -rvf foo.tar Gemfile README.md

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How can we update a specific file within an uncompressed archive?

A

with the -u flag

tar -uvf foo.tar version.rb

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What flag do we use to extract all of the files into the current directory?

A

-x

tar -xvf foo.tar

17
Q

How can we extract a single file from the archive?

A

tar -xvf foo.tar rails.gemspec

list the file name(s) after the command and arguments

18
Q

How can we extract files to a different directory?

A

using the -C flag

tar -xvf foo.tar -C ./myfolder

19
Q

Which three compression algorithms does tar provide?

A

gzip (-z)
bzip2 (-j)
unix compress (-Z)

20
Q

What is the convention for showing that a file has been compressed?

A

appending .gz to the end of the archive’s name

21
Q

How would we create a compressed archive from “ar.tar”

A

tar -zf ar.tar.gz

tar flags name.gz

22
Q

How can we extract files from a compressed archive?

A

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