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.
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.
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
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).
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.
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.
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.
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)
I can’t say I’ve had problems remembering tar’s arguments, but
ln
gets me every time.You might find
cp -s
andcp -l
useful.The argument order for
ln
is the same as forcp
ormv
.That’s how I remember it. Write the arguments as if I’m making a copy of the file, but use
ln
instead ofcp
.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.My trick: consider, if you had to provide just one argument, which is essential. That comes first.
a bit crude but
ln <real> <fake>
seems to work for me.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”?
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>
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.Ah! Easy! The link goes from symlink A to file B, so the symlink name is the source and comes first right?
Fair point :P. I think source as the source file, the actual file. And destination as the symlink
ln: last -> new
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.After I had already memorised it, I heard someone refer to
-xzvf
as “extract ze various files”I was introduced to
xzvf
as xtract ze vucking files.I’ve learnt since that the
z
(gzip) andv
(verbose) aren’t really necessary, and you can probably get away withxf
.On GNU tar that is. Not necessarily the case on the BSDs, at least I don’t think it is on OpenBSD.
create/extract
Zipped
Verbose
(From/to) file
You don’t even need
z
when ex
tracting, since moderntar
s will autodetect the compression type.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
becomesls list human recursive
in the same way thattar xvzf
becomestar extract, verbose, comprezs this file
, and I’ve never had any trouble remembering the arguments for it. I always thought the arguments oftar
being difficult to remember was just a myth lolOne of my favourite footguns is
pkill -v
which does not verbosely tell you which processes it sent a signal to. Oh no, you must rememberpkill
is a sibling ofpgrep
, and like originalgrep
, v is short for inVert. It is a particularly spicy trap becausepkill
is the safer more portable alternative tokillall
, which on some systems kills matching processes, and on others kills everything indiscriminately (I blissfully forget which is which).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.
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.
To avoid the problem of tarball name or filename first, I often just
tar c files... | gzip > a.tar.gz
.[Comment removed by author]
tar
is such an improvement oncpio
that I haven’t even reconsidered the flags in decades, tbh. It’s useful also for copying directories and withrsh
stdio behaviour (inherited byssh
) a useful way to distribute files over the network. This latter use is largely obviated byrsync
of course.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.
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)
My problem is the order of the archive name Vs. The files you want to put in. I always mix these ones up.