LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 09:53 PM   #1
Tem2
Member
 
Registered: Dec 2011
Posts: 68

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, 10:23 PM   #2
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 1,006

Rep: Reputation: 439Reputation: 439Reputation: 439Reputation: 439Reputation: 439
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 10:27 PM.
 
Old 02-12-2019, 12:01 AM   #3
Tem2
Member
 
Registered: Dec 2011
Posts: 68

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:36 AM
sudo and >>: permission denied mcd Linux - Software 2 06-25-2008 04:30 PM
"sudo mount -a" works perfect but permission denied when mounting on startup, why? aaron4katie Linux - Software 10 01-11-2007 11:16 AM
sudo - permission denied! yogaboy Linux - Newbie 5 12-29-2006 12:58 AM
sudo permission denied Swift&Smart Slackware 5 07-13-2006 02:05 AM

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

All times are GMT -5. The time now is 09:45 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration