Live data from Hacker News

The Cult of DD

eklitzke.org

141–150 of 178 posts

Re: The Cult of DD

#141
post #34

Earlier quoted context omitted.

This probably has more truth than most unix admins would like to admin. "Why do we do it like that? I dunno, that's how I learned how, how do you do it?"

Definitely this. I have found many times that I'm an offender of these "bad practices", and usually that's because a certain pattern I learned way back in the beginnings of my Linux days still hangs around. Embarrassingly, it took me a long time before I started reaching for man pages instead of Google. That has probably has had the biggest effect on tightening up my command line fu. find is another tool that seems t…

I learned Linux this way a decade and a half ago when it was far (and still is imho!) more convenient to quickly search a man page than google something. (with slow internet start times, browser startup times, etc)

Now, sometimes when people watch me work in a shared session they comment on my "peculiar" (to them) usage of flipping between -h --help and man $command, because there's a whole lot of switches I have memorized over time, but even more that I just have good reference points for.

But, bar none, what I've noticed among my peers is that the people that have always bowed to quick google solutions never really have taken the time to learn what they're doing. They almost always seems to be the 'quick fix', 'get it working now, sort it out later' types.

Re: The Cult of DD

#142

I think dd is primarily so popular because it is used in mostly dangerous operations. Sure, using cat makes logicial sense, but if we are talking about writing directly to disk devices here I'll trust the command I read from the manual and not explore commands I think would work. dd's "highly nonstandard syntax" comes from the JCL programming language, but it's really just another tool to read and write files. At the…

There is some truth to the fact that (if you basically already know dd like I do) then reserving it for dangerous operations is a good way to "signal" to yourself "slow down here and pay attention"

Re: The Cult of DD

#143
post #104
post #61

Earlier quoted context omitted.

Would that seriously work?

Yes. Yes it does. Reminds me of a Sunday evening in the late 90ies when I stopped working as root all the time: cp backup.tar.bz /dev/sda Nowadays I would know enough to at least get the contents of the backup.tar.bz back. Back then, this was the end of both my / partition (or any other partition) and the backup of my music collection. Still, that didn't end my love affair with Unix. It did make me a whole lot more c…

> cp backup.tar.bz /dev/sda

Ouch. That just hurts seeing that line.

Re: The Cult of DD

#144
post #128
post #116

Earlier quoted context omitted.

Or, before that, just send the dd process SIGINFO to get the same output printed once. `while :; do kill -INFO %1; sleep 1; done` if you want a "progress bar" of sorts. As an aside: On BSDs (incl. macOS), SIGINFO is also able to be sent interactively by the line driver when you type ^T (like ^C sends SIGINT.) Kind of lame that Linux doesn't follow suit [or even have SIGINFO], or we'd see a lot more programs that buil…

Erm... It's the first time I see SIGINFO signal. I think you meant SIGUSR1.

On Unix, there's SIGINFO, which doesn't exist on Linux systems. That's why coreutils' dd uses SIGUSR1 instead.

Re: The Cult of DD

#145
post #43

Earlier quoted context omitted.

$50k is a massive sum for a lot of people...

Well yeah, he's in med school. Maybe one day it won't be a massive sum, but, for now, he's broke.

And I state again: if you're a future doctor and your biggest regret is that you could be $50k richer right now, I'm not inclined to do much weeping. Basically everyone has been a broke student.

Re: The Cult of DD

#146
post #128
post #116

Earlier quoted context omitted.

Or, before that, just send the dd process SIGINFO to get the same output printed once. `while :; do kill -INFO %1; sleep 1; done` if you want a "progress bar" of sorts. As an aside: On BSDs (incl. macOS), SIGINFO is also able to be sent interactively by the line driver when you type ^T (like ^C sends SIGINT.) Kind of lame that Linux doesn't follow suit [or even have SIGINFO], or we'd see a lot more programs that buil…

Erm... It's the first time I see SIGINFO signal. I think you meant SIGUSR1.

No, I think GP means SIGINFO, which the BSD family uses. On GNU/Linux SIGUSR1 is a passable substitute. See http://www.unix.com/man-page/FreeBSD/3/siginfo/ and https://unix.stackexchange.com/questions/179481/siginfo-on-g... for more about it.

Re: The Cult of DD

#147

Earlier quoted context omitted.

>pv /dev/sdb Huh? pv can cat stuff on it's own, and it will be able to make a progress bar based on the filesize pv image.img > /dev/sdb

So I suppose that the command pv /dev/sdb would actually need to buffer the complete file, before commencing to write to the device (and showing the progress), which would defeat the whole idea of showing progress.

It wouldn't. It just won't be able to predict a file size.

Re: The Cult of DD

#148

This article is full of Useless Uses of Cat[1] that could just use redirection operators. For instance, cat image.iso | pv >/dev/sdb could be rewritten as pv /dev/sdb A related mistake is the Useless Use of Echo, since any command of the form echo "foo" | bar can be written using here strings as bar or even bar [1] http://porkmail.org/era/unix/award.html

They could! They could be super annoying to read, too. Pipelines make more sense to humans when they always read in the same direction. In the rare case where the volume of data is large enough to make the efficiency hit noticeable on large machines, rewriting a pipeline to eliminate a leading cat makes sense. In all other cases, it is a premature and unnecessary optimization.

Yeah, in BASH at least it's nicer to use

         /dev/sdb

Re: The Cult of DD

#149
post #131

This article is full of Useless Uses of Cat[1] that could just use redirection operators. For instance, cat image.iso | pv >/dev/sdb could be rewritten as pv /dev/sdb A related mistake is the Useless Use of Echo, since any command of the form echo "foo" | bar can be written using here strings as bar or even bar [1] http://porkmail.org/era/unix/award.html

Useless or not, I personally prefer left to right flow.

Which has the added benefit of not overwriting the source if you mistype the operator...

Re: The Cult of DD

#150
post #74

I think dd is primarily so popular because it is used in mostly dangerous operations. Sure, using cat makes logicial sense, but if we are talking about writing directly to disk devices here I'll trust the command I read from the manual and not explore commands I think would work. dd's "highly nonstandard syntax" comes from the JCL programming language, but it's really just another tool to read and write files. At the…

I always thought dd stood for disk destroyer, only ever used it for making low level copies of whole disks or shredding them with if=/dev/random. This thread has been informative and terrifying as I learn cat and cp are every bit as dangerous as dd! I never would expect something like cp xxx /dev/sda to actually work. Thinking about it, why should cp even support something like that? I'll copy files but I'll also DES…

1. Everything is a file; why would cp care that one file happens to be your hard drive?

2. "UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things."

- Doug Gwyn

Post reply on HN