Hacker News new | past | comments | ask | show | jobs | submit login

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 DESTROY YOUR SHIT if you say so?



> 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 DESTROY YOUR SHIT if you say so?

That's the beauty of Unix.

Everything is a file. Thus every program that can work with files, can in fact work with everything.

It's actually very liberating.


> I'll also DESTROY YOUR SHIT if you say so

That's the Unix way: The customer, eh, user is always right.

I once wanted to clean up backup files created by emacs (they end in the tilde character) by typing "rm <asterisk>~" - except what I did type was "rm <asterisk> ~".

(On the upside, I learned a valuable lesson that day.)


It isn't the same though, because not all files are non-seekable streams of bytes. In fact, most are seekable and possibly sparse.

What happens when you did a sparse file? And cp?

https://wiki.archlinux.org/index.php/sparse_file

C.f. fallocate(1,2)


I'll also DESTROY YOUR SHIT if you say so?

It better :-)

But it all comes from the unix idea of everything is a file.


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




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: