Humor - wrong use of the DD command

Warning: this is meant to be humorous, but possibly instructive and fun as it was for me when I first learned about it…

Ever use the DD command? Sure you have.

Did you know that you are using the syntax from the IBM/360 mainframe era from the 1960’s to do so with it’s JCL or job-control-language?

Most notably, the IF= and OF= pair are a blast from the past when bell-bottom pants were all the rage.

Consider our own instruction to dd the NomadBSD image:

# dd if=nomadbsd-x.y.z.img of=/dev/daX bs=1m conv=sync

Looks pretty much like everything we’ve ever seen since time began.

But that’s NOT the unix-way! But I can’t complain, since looking back in history I saw that the instructions for installing ATT Research V6 unix looked much the same!

I caught this hint from Doug McIlroy (look him up if you don’t know) that in reality, unix redirection should replace the old IF= and OF= syntax as being the right use and self-explanatory. Let’s change it to modern unix standards:

# dd < nomadbsd-x.y.z.img > /dev/daX bs=1m conv=sync

If the dual-redirection freaks you out like it did to me at first, just use some more whitespace between the input < redirection and the output > redirection and then it becomes a bit more obvious.

So yeah, at first the IF= and OF= syntax looks like a way to help make sure that one doesn’t get their input and output mixed up. But once I tried what Doug casually mentioned to do, I can no longer use the JCL syntax as it seems plainly obvious.

Someone needs to pass this up to Core. It’s time to do it the Unix way as nature intended. :slight_smile:


"Everything is a file"

Yeah, yeah, old history. The humor of the DD command using jcl syntax brought this to mind too:

We all know that the PIPE was a game changer for *nix right? Passer-by’s would gasp!

Long forgotten was another mind-blower to passer-by’s with something as simple as this copy function we take for granted:

cp myresume.txt /dev/daXs1/work/myresume.txt

Previously on other systems, your resume.txt file was in memory. But how do you save it to an actual medium?

JCL, where YOU are the device driver! See the difference in complexity between unix and jcl, which would have been the norm forcing you to be the jcl hacker just to perform a simple job! Better hope you get it right, or kiss your resume goodbye.

So put that into your pipe and smoke it. Is it any wonder that people within ATT started to take this stuff from that merry band of research-hackers seriously?

Additional fun trivia:
Ever use basic and do

load gorilla.bas

Or any other filesystem stuff. Nearly all basic’s operated with these simplistic file save/load/delete commands, not requiring the user to drop into some arcane job control.

But that wasn’t part of Basic! All that stuff was from the DTSS timesharing system, where Dartmouth Basic was born in the early/mid 60’s. You could load algol or whatever in much the same way.

Enough history - but maybe if you load up the bwbasic package (now at v 3.20!) and try saving and loading files, you can thank a Dartmouth undergrad for that vision of simplicity for the non-skilled user.

Here is a REALLY “fast” (disastrous) way to obliterate your entire system.
I’m more familiar with Linux device specs, so I’ll use theirs; you can substitute your actual device:

sudo dd if=/dev/null of=/dev/sda ; sudo sync # Not likely you’ll ever REACH ‘sync’!

An equivalent way to do something like this that I’ve actually DONE on a UNIX workstation is:

sudo rm -rf / # Probably one of the shortest syntaxes; it should self-destruct any UNIX, BSD, or Linux system in short order!

I was “repurposing” the UNIX workstation, so erasing the entire contents was fine. I was a member of the UNIX development team, so we had nightly builds, Alpha, Beta, and Release (stable) builds readily available.

Any time you want to erase the entire disk (or at least disk partition) these commands will effectively do the job. The only exception is if you have a multi-boot configuration, then you have to perform a command that uses a slightly different device spec to wipe a single partition as opposed to an entire device.

Yeah, definitey do NOT do that!

The funny thing is that for decades I had always wondered why the IF= and OF= syntax which I saw everywhere with DD seemed to be specific to just this one command in Unix. Why didn’t other commands use IF/OF pairs - even as an alternate?

Then a few years ago I saw that Doug McIlroy - basically the boss of the original research Unix team, mentioned that this was a totally old-school 1960’s relic where if one wanted to do it the unix-way, simple redirection was the right way to do it.

Since I had never seen the use of DD without the JCL syntax of using IF= and OF= pairs, I tried to go back as far as I could to see if it was ever done the “unix way”.

As far back as 1975, the jcl way was in use!
(use a ctrl-f in a browser or whatever to quickly go to the first appearance of IF=)

I mean, c’mon - right there as of 1975 they were promoting the use of the non-unix way.

My only thought was that maybe getting redirection wrong (albeit self explanatory to me) was a danger to “old timers” that were actually used to mainframe jcl way of doing things and not blowing their first install of this new-fangled system.

It’s a question that I’ve always wanted to ask Doug - although I have no contact with him - is “How could you let this faux-pas be in the V6 1975 installation manual?!?” :slight_smile:

Tinfoil hat time:
Could it be that by allowing the use of an archaic form of JCL syntax be related to the problems some had with their “home computers” using CP/M where the PIP command using (destination=source) was frequently gotten wrong and wiped out disks? Heh, I seriously doubt that anyone was toying with CP/M, but then again, it’s hard to take your PDP-11/45 home. :slight_smile:

Mystery Solved!

I can finally take this quandery off my bucket list. It’s my best answer in regards to the legacy use of IF / OF pairing of the dd command ala jcl syntax:

An offshoot of pure ATT Research Unix was “PWB” or programmer’s work-bench. It brought us such niceities as a source code control system - SCCS - amongst other goodies.

This was where people with “real-work”, rather than pure os research needed to get things done. Most notably, acting as a front-end processor to: MAINFRAMES using JCL so that they could more easily interact with the big-iron.

So who’s most likely to install it? The mainframe guys who would be more than familiar with IF / OF pairs as seen in the installation manual - even though it is not truly the “unix way”.

Here’s a video showing people probably very familiar with DD, any one of which would be more than happy (actually probably NOT being so disruptive tech) to install V6 for you:

I can sleep soundly tonight…

Using dd, which is definitely a throwback to the IBM dd card in the Job Control Language {JCL), seems to me to be TWO things:

  1. a utility that was originally used primarily for communication with IBM mainframe computer systems but is able to exchange data with any device, and

  2. Yet another UNIX "play on words, just to add to the collection of puns.

I also question whether it was written by mainframe programmers and ported to C, either by those same programmers or by UNIX programmers who needed it quickly and wrote it to emulate the dd card for compatibility.