Error, even with sudo: "dd: failed to open ‘/dev/sda1’: Permission denied" (dd input piped from gzip)
Solution 1:
You are missing sudo
in the other side of the pipeline:
sudo gzip -dc sda1.image.gz | sudo dd of=/dev/sda1
In a <command> | <command> | [...]
command format, each command of the pipeline which requires sudo
should be run using sudo
, not only the first one.
In this case you might not need to use sudo
on gzip -dc sda1.image.gz
, unless you don't have read permission on the file:
gzip -dc sda1.image.gz | sudo dd of=/dev/sda1
In general, if all the commands to be run in a pipeline require sudo
, one way around having to write sudo
in each command is to run the whole command in a subshell invoked using sudo
:
sudo bash -c '<command> | <command> | [...]'