3.1 Command Line - Archiving Files on the Command Line Flashcards

1
Q

What command would you use to create a new archive of /tmp/Archive (named archive.tar.bz2) with bz2 compression?

A) tar cbvf archive.tar.bz2 /tmp/Archive
B) tar cjf archive.tar.bz2 /tmp/Archive
C) tar cvzf archive.tar.bz2 /tmp/Archive
D) bzip2 archive.tar.bz2 /tmp/Archive

A

tar cjf archive.tar.bz2 /tmp/Archive

j is the command for creating bzip2 or bz2 compression

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

What command would you use to unpack the gzip-compressed archive archive.tgz?

A) tar xvf archive.tgz
B) gunzip archive.tgz
C) tar xjf archive.tgz
D) tar xzf archive.tgz

A

tar xzf archive.tgz

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

Does zip support different compression levels?

A

Yes. You would use -#, replacing # with a number from 0-9.

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

When extracting files, does tar support globs in the file list?

A

Yes, you would use the –wildcards option. –wildcards must be placed right after the tar file
when using the no dash style of options.

For example:
$ tar xf tarfile.tar –wildcards dir/file
$ tar –wildcards -xf tarfile.tar dir/file*

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

To extract the file file.txt from the tar archive ./archive.tar, you would use the following command:

A) tar -af file.txt ./archive.tar

B) tar -rf ./archive.tar file.txt

C) tar -xf file.txt ./archive.tar

D) ** tar -xf ./archive.tar file.txt**

A

tar -xf ./archive.tar file.txt

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

What command will list the contents of an archive?

A

tar -t

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

What command will append to an archive?

A

tar -r

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