I put an Ubuntu ISO on a USB drive, booted from that USB on my laptop, and then called

$ cat /dev/zero | pv > /dev/sda

to try to overwrite my laptop's hard drive (sda) with zeros.

I get the following error:

bash: /dev/sda: Permission denied

This error is raised regardless of whether I pre-pend my command with sudo. Why am I getting this? How do I circumvent this error?

(Could it have something to do with mounting/unmounting? Full disclosure: I have already partially erased sda, but the erasure was interrupted midway -- I'm rerunning the command to make sure it is fully erased.)


I was able to erase the hard drive using the disk utility GUI instead. But I'm still curious whether it would have been possible to do it via the command line using the method I attempted first.


Output redirection is done by shell, and non-root shell doesn't have access to /dev/sda. If you don't want to change to root shell, you can run the command with sudo and tee:

cat /dev/zero | pv | sudo tee /dev/sda
  • I was in the process of writing exactly this answer. +1 – Fox Aug 31 '17 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.