• @[email protected]
    link
    fedilink
    65 months ago

    Since the reply (as of writing) has more upvotes than the joke itself, I thought I’d give a thorough over-explanation of the joke, because that always makes jokes better (/s):

    The basis of the joke is a UNIX-style command line, or shell, showing the invocation of a single command. It could be Bash on Linux, or zsh on MacOS, or any other shell with a compatible syntax. This is not strictly a joke for programmers, but likely for anyone with experience in IT. Using the shell is oftentimes necessary to configure or modify the operating system, or in this case, to interact with software that does not have a graphical user interface (GUI) component. Some people consider using the shell more convenient than the GUI even if there is one. Personally, I’m not a snob and I’ll use whatever is handy to get the job done.

    The command shows the invocation of gzip, a file compression utility like WinRAR or WinZip or 7Zip but free and open source, that is installed by default on most Linux distributions and MacOS. gzip is also the name of the compressed file format that this utility outputs, which is similar to .zip or .rar but differs in some key details.

    -9 is a flag to the gzip command that tells it to target maximum compression of the input file. gzip implements the DEFLATE compression algorithm, which is actually a combination of two other algorithms: LZ77, which searches the input for duplicate runs of bytes and replaces them with references that point back to earlier occurrences, and Huffman coding, which replaces sequences of bytes with “symbols”, the length of which is inversely proportional to its frequency (more frequent symbols are given shorter encodings and less frequent symbols are given longer encodings, which saves space on average). The compression setting only affects the LZ77 portion, as it controls how long the algorithm will search for duplicate substrings. ZIP files also use the DEFLATE algorithm, but the file format is different so they are not strictly compatible.

    KaiWinn is the input file to be compressed. As a convention on UNIX-based systems like Linux and MacOS, files without any extension (e.g. .gz, .zip, .txt, etc.) are usually executable files (i.e. programs, the equivalent to .exes on Windows), though sometimes they are text files (but this is usually obvious from context, like a file named README). This could be a folder instead, but unlike WinRAR or WinZip or 7Zip, gzip does not support compressing multiple files (like a whole folder structure) into a single archive. Compressing a folder would require either a different utility, or more typically for UNIX-based systems, filtering through the tar (Tape ARchive) utility to encode the contents of the folder into a single file before compressing. The tar utility comes with support for compressing with gzip built-in, so compressing KaiWinn as a folder would look something like tar -czf KaiWinn Alixus.tar.gz.

    > is a redirection operator which writes the output of the command to a file (Alixus.gz in this case). By default, a lot of command line utilities on UNIX-based systems (e.g. Linux and MacOS) write their output to stdout, which normally outputs to the console but may be piped into other commands. A lot of utilities have command-line options to write their output to a file (like the -f flag for tar shown above), but gzip does not.

    In fact, gzip’s behavior is potentially quite surprising, because it does not normally write its output to stdout. By default, it actually replaces the input file with a compressed version of it with the .gz extension appended, and redirecting the output does nothing. This means it won’t actually behave as intended for the joke. We can see this by running the following commands ($ is a prompt for a command, # denotes a comment which will not be interpreted by the shell):

    $ # make a directory to work in
    $ mkdir s2e15
    $ # enter that directory
    $ cd s2e15/
    $ # create an empty file
    $ touch KaiWinn
    $ # list directory with details (file permissions, number of hard links, user/group ownership, size, creation timestamp)
    $ ls -l
    total 0
    -rw-r--r-- 1 root root 0 Apr 22 00:11 KaiWinn
    $ # Compress our file
    $ gzip -9 KaiWinn > Alixus.gz
    $ # List the directory again
    $ ls -l
    total 4
    -rw-r--r-- 1 root root  0 Apr 22 00:20 Alixus.gz
    -rw-r--r-- 1 root root 28 Apr 22 00:11 KaiWinn.gz
    

    Notice how KaiWinn is gone and we now have two new files, Alixus.gz and KaiWinn.gz. Pay special attention to the sizes: 0 bytes for the former, 28 bytes for the latter. The gzip format has a header which always contains some data, including the original filename, so a properly formatted gzip file will never be zero-sized even if its input was. So why is Alixus.gz zero-sized? Because it’s not actually a valid gzip file. The gzip utility doesn’t output anything to stdout by default, so we ended up just writing an empty file alongside our compressed one.

    To tell gzip to output to stdout so we can redirect it to a file of our choosing (and coincidentally leave its input file alone), we can pass the -c flag:

    $ gzip -9 -c KaiWinn > Alixus.gz
    $ ls -l
    total 4
    -rw-r--r-- 1 root root 28 Apr 22 00:31 Alixus.gz
    -rw-r--r-- 1 root root  0 Apr 22 00:31 KaiWinn
    

    And now we have our Alixus.gz.

    • @ummthatguyOP
      link
      English
      7
      edit-2
      5 months ago

      But, also, actual thanks. That level of technical dedication will be the basis of what I can only hope to become our own Federation.