The Arrow Law

When I first started out with Linux, I was having trouble understanding the basic commands such as ln, andrewmv, scp, rsync, etc. What got me with those commands was the SOURCE and DEST options until I figured out the arrow law.

A typical rsync command looks like this:

rsync -av /home/andrew/file1.txt /opt/andrew/file2.txt

Where as a basic tar command looks like this:

tar -cJf tarfile.xz /home/andrew/file1.txt

In the rsync example, the SOURCE came first. In the tar example, the DEST came first. Did I really have to learn every command to know which order my commands were supposed to be in?

There are a few quirks, but most commands follow the arrow law: -> . SOURCE should come first – then DEST.

To place the tar command in the arrow law way, we would write the command like the example below. Tar allows the use of multiple source locations in the form of files or folders. Each source is then compress and place in the file.

tar -cJ /home/andrew/file1.txt /opt /folder -f files.xz

At a glance, one should easily recognize that the -f indicates the DEST/SOURCE file to be worked on by the tar command. Thus by typing the extraction command as the below is following the arrow law.

tar -xvJf files.xz

The command that really confused me the most was the ln. By using the arrow law, it was easy to figure this one out. (note: in the below example -s is the option for making a symbolic link – not to indicate the source.)

ln -s /opt /home/andrew/opt

In human readable terms, the above command means the following: take /opt and make it accessible by going to /home/andrew/opt.