1. 11
    1. 17

      I can’t say I’ve had problems remembering tar’s arguments, but ln gets me every time.

      1. 9

        You might find cp -s and cp -l useful.

      2. 7

        The argument order for ln is the same as for cp or mv.

        1. 1

          That’s how I remember it. Write the arguments as if I’m making a copy of the file, but use ln instead of cp.

          The problem: I don’t use ln very often, so even though the argument order is consistent, I second-guess myself and pull out the manual anyway.

      3. 3

        My trick: consider, if you had to provide just one argument, which is essential. That comes first.

      4. 1

        a bit crude but ln <real> <fake> seems to work for me.

        1. 1

          Maybe I’m looking for something that isn’t there, but I don’t get it — is this a mnemonic based off the word “crude”?

          1. 1

            no not really, crude because real / fake can be (mis)interpreted in varying contexts (you can use your imagination) .

            for, me, i prefer real to fake and hence, ln <real> <fake>

      5. 1

        I also get tripped up but at the same time I try to remember source, then destination. And since I’m almost always doing soft links -s reminds me that source is first.

        1. 2

          up but at the same time I try to remember source, then destination

          Ah! Easy! The link goes from symlink A to file B, so the symlink name is the source and comes first right?

          1. 1

            Fair point :P. I think source as the source file, the actual file. And destination as the symlink

      6. 1

        ln: last -> new

    2. 6

      I just memorized -czvf and -xzvf, create and extract. If I want to do something else to a file, unless I’m desperate I just extract it and do that stuff.

      1. 10

        After I had already memorised it, I heard someone refer to -xzvf as “extract ze various files”

        1. 4

          I was introduced to xzvf as xtract ze vucking files.

          I’ve learnt since that the z (gzip) and v (verbose) aren’t really necessary, and you can probably get away with xf.

          1. 1

            On GNU tar that is. Not necessarily the case on the BSDs, at least I don’t think it is on OpenBSD.

        2. 2

          create/extract

          Zipped

          Verbose

          (From/to) file

      2. 8

        You don’t even need z when extracting, since modern tars will autodetect the compression type.

    3. 3

      I mean, -v for verbose is supported in pretty much every command that Does Something, -f for a file, -c for create and -x for extract are all pretty easy to remember because they’re named after what they do. The only thing that’s perhaps difficult to remember is z/J/j for the archive formats, but as you have mentioned it does it automagically.

      I use the same system to remember the arguments as I do when I’m using LS or whatever. ls -lhR becomes ls list human recursive in the same way that tar xvzf becomes tar extract, verbose, comprezs this file, and I’ve never had any trouble remembering the arguments for it. I always thought the arguments of tar being difficult to remember was just a myth lol

      1. 4

        One of my favourite footguns is pkill -v which does not verbosely tell you which processes it sent a signal to. Oh no, you must remember pkill is a sibling of pgrep, and like original grep, v is short for inVert. It is a particularly spicy trap because pkill is the safer more portable alternative to killall, which on some systems kills matching processes, and on others kills everything indiscriminately (I blissfully forget which is which).

    4. 3

      I recommend the atool scripts (available on many distros) for a uniform interface for interacting with many archive formats.

      They also automatically extract into a new directory when that makes sense, which I’m thankful for because it is always an annoying waste of time when tar spills files somewhere I wasn’t expecting.

    5. 2

      That’s not really ‘your’ mnemonic. Those are the mnemonics as they were chosen from the beginning.

      The tricky part is remembering the order of the argument. What comes first? The options, the target tararball or the files to include/locations.

      I think mostly everyone remembers X for extract, c for create/compress, z for zip compression, v for verbose.

    6. 1

      To avoid the problem of tarball name or filename first, I often just tar c files... | gzip > a.tar.gz.

    7. [Comment removed by author]

    8. 1

      tar is such an improvement on cpio that I haven’t even reconsidered the flags in decades, tbh. It’s useful also for copying directories and with rsh stdio behaviour (inherited by ssh) a useful way to distribute files over the network. This latter use is largely obviated by rsync of course.

    9. 1

      For creating tars, I always mixed up the order of arguments for the tarball I’m creating and the files to tar, so I always tell myself: “create file.tar.gz from files”. I think I came up with that after seeing the same xkcd comic.

    10. 1

      I use -caf (Create A File) and -xaf (eXtract A File).

      -a is the explicit “auto-detect the compression format” flag, which is supported by every tar I’ve used in the last few years (which is mostly libarchive’s bsdtar). It makes for a handy addition to the mnemonic, as well as not having to remember what flag is for what compression format when creating an archive :D

      (edit: should have scrolled down further in the article, lmao)

    11. 1

      My problem is the order of the archive name Vs. The files you want to put in. I always mix these ones up.