LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-11-2019, 08:53 PM   #1
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Rep: Reputation: Disabled
Permission denied using sudo dd command with pv


Trying to use dd command (my first effort with this command) to back up my system partition to a separate partition on the same hard disk.

sudo dd if=/dev/sda1 | pv | dd of=/dev/sda3
dd: failed to open '/dev/sda3': Permission denied
0 B 0:00:00 [ 0 B/s] [<=>

It runs ok without the pv option:
sudo dd if=/dev/sda1 of=/dev/sda3
 
Old 02-11-2019, 09:23 PM   #2
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,798

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
The sudo ends at the pipe.
Either have two sudos:
Code:
sudo dd if=/dev/sda1 | pv | sudo dd of=/dev/sda3
Or pass the piped commands to a root shell (then even the pv runs as root)
as an argument
Code:
sudo sh -c "dd if=/dev/sda1 | pv | dd of=/dev/sda3"
or from stdin
Code:
echo "dd if=/dev/sda1 | pv | dd of=/dev/sda3" | sudo sh
Bash also takes
Code:
sudo sh <<< "dd if=/dev/sda1 | pv | dd of=/dev/sda3"

Last edited by MadeInGermany; 02-11-2019 at 09:27 PM.
 
Old 02-11-2019, 11:01 PM   #3
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by MadeInGermany View Post
The sudo ends at the pipe.
Either have two sudos:
Code:
sudo dd if=/dev/sda1 | pv | sudo dd of=/dev/sda3
Or pass the piped commands to a root shell (then even the pv runs as root)
as an argument
Code:
sudo sh -c "dd if=/dev/sda1 | pv | dd of=/dev/sda3"
or from stdin
Code:
echo "dd if=/dev/sda1 | pv | dd of=/dev/sda3" | sudo sh
Bash also takes
Code:
sudo sh <<< "dd if=/dev/sda1 | pv | dd of=/dev/sda3"
Thanks! I used 2 sudos.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
sudo and >>: permission denied mcd Linux - Software 2 06-25-2008 03:30 PM
"sudo mount -a" works perfect but permission denied when mounting on startup, why? aaron4katie Linux - Software 10 01-11-2007 10:16 AM
sudo - permission denied! yogaboy Linux - Newbie 5 12-28-2006 11:58 PM
sudo permission denied Swift&Smart Slackware 5 07-13-2006 01:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration