19

In the section "Installing Portage", the Gentoo installation docs say:

# tar xvjf /mnt/gentoo/portage-latest.tar.bz2 -C /mnt/gentoo/usr

What does this command do?

VL-80
  • 4,475
  • 2
  • 28
  • 38
guilin 桂林
  • 381
  • 2
  • 3
  • 7

3 Answers3

31

Tar is used to handle archives (historically saved on tapes).

  • The x tells it to extract files from the archive
  • v stands for verbose
  • j for bzip2 archive
  • f indicates the file name
  • finally: C tells it to change directory (so the package content will be unpacked there)

See also man tar.

rubo77
  • 4,680
  • 11
  • 45
  • 79
choroba
  • 18,638
  • 4
  • 48
  • 52
  • I've also seen -C used while creating an archive. What does it mean in that context? – Frak Jan 23 '20 at 21:51
  • 1
    @frakman1: Do I really have to copy the contents of `man tar` here? – choroba Jan 23 '20 at 22:11
  • 3
    The man page just says `change to directory DIR` which is not very helpful. Saying "(so the package content will be unpacked there)" on the other hand, is. – Frak Jan 23 '20 at 22:19
  • 1
    OK. When -C is used while creating an archive, it specifies where to search for the files to archive. – choroba Jan 24 '20 at 09:58
12

If you ever need to know what a parameter does again, try to read the man first. The command man tar, and then doing /-C will get you to the section describing what -C stands for, which in this example represents 'change directory' (i.e. sends the results of the unpacking to /mnt/gentoo/usr).

Simon Sheehan
  • 9,114
  • 12
  • 52
  • 71
timss
  • 388
  • 1
  • 12
4

It unpacks /mnt/gentoo/portage-latest.tar.bz2 in /mnt/gentoo/usr/

Tamara Wijsman
  • 57,083
  • 27
  • 185
  • 256
Tog
  • 4,975
  • 14
  • 37
  • 42