-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I've been volunteered to try to build a boot image for a Nitrogen 6x Freescale SOM board using whatever OS I can make work. I chose Fedora's ARM image since I'm more comfortable with using Fedora. In the process of trying to using xzcat to dump the image to the microSD card I noticed something strange. When I tried:
sudo xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb
I would get a 'Permission denied' error.
But when I ran the same command as root directly, it worked just fine. I'm not sure I've ever encountered a situation where sudo wouldn't work like this before. Is there a particular reason for this? Or is this a bug? For the record, I changed nothing on the device between attempts to xzcat the image.
- -- Mark Haney Network/Systems Administrator Practichem W: (919) 714-8428 Fedora release 20 (Heisenbug) 3.13.6-200.fc20.x86_64
Once upon a time, Mark Haney mhaney@practichem.com said:
sudo xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb
I would get a 'Permission denied' error.
That's because the "> /dev/sdb" was parsed and handled by your user shell (redirection is handled by the shell before running the command). sudo only got "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz" as arguments. You should be able to quote what you want actually passed to sudo:
sudo "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb"
01.04.2014 17:33, Chris Adams:
Once upon a time, Mark Haney mhaney@practichem.com said:
sudo xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb
I would get a 'Permission denied' error.
That's because the "> /dev/sdb" was parsed and handled by your user shell (redirection is handled by the shell before running the command). sudo only got "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz" as arguments. You should be able to quote what you want actually passed to sudo:
sudo "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb"
... which would give a "command not found" error.
Something like sudo bash -c "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb" should work though, since the shell which is started with elevated rights is doing the output redirection now.
On 1 April 2014 16:45, Markus Schönhaber fedora-users@list-post.mks-mail.de wrote:
01.04.2014 17:33, Chris Adams:
Once upon a time, Mark Haney mhaney@practichem.com said:
sudo xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb
I would get a 'Permission denied' error.
That's because the "> /dev/sdb" was parsed and handled by your user shell (redirection is handled by the shell before running the command). sudo only got "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz" as arguments. You should be able to quote what you want actually passed to sudo:
sudo "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb"
... which would give a "command not found" error.
Something like sudo bash -c "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb" should work though, since the shell which is started with elevated rights is doing the output redirection now.
xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz | sudo dd of=/dev/sdb Will also work, using sudo to grant write permissions, but not read permissions.
Less flexible than specifying a command to a sudoed shell command, but also more granular control (if you can call dd as root granular).
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 04/01/14 11:33, Chris Adams wrote:
Once upon a time, Mark Haney mhaney@practichem.com said:
sudo xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb
I would get a 'Permission denied' error.
That's because the "> /dev/sdb" was parsed and handled by your user shell (redirection is handled by the shell before running the command). sudo only got "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz" as arguments. You should be able to quote what you want actually passed to sudo:
sudo "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb"
Well, someone on the Fedora team needs to fix the documentation then. But now it makes sense. I didn't stop to think about the redirect, since my boss isn't giving me time to think. Apologies for spamming the list.
- -- Mark Haney Network/Systems Administrator Practichem W: (919) 714-8428 Fedora release 20 (Heisenbug) 3.13.6-200.fc20.x86_64
On 04/01/2014 08:47 AM, Mark Haney issued this missive:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 04/01/14 11:33, Chris Adams wrote:
Once upon a time, Mark Haney mhaney@practichem.com said:
sudo xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb
I would get a 'Permission denied' error.
That's because the "> /dev/sdb" was parsed and handled by your user shell (redirection is handled by the shell before running the command). sudo only got "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz" as arguments. You should be able to quote what you want actually passed to sudo:
sudo "xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb"
Well, someone on the Fedora team needs to fix the documentation then. But now it makes sense. I didn't stop to think about the redirect, since my boss isn't giving me time to think. Apologies for spamming the list.
In general, if you're asking a command (in this case sudo) to run another command (xzcat) and the argument list to that second command contains spaces, then the entire command should be enclosed by quotes to keep the shell from processing the arguments and command. Again, this is standard operation.
This is not Fedora-specific. You'd hit the exact same thing on any Linux system using the bash shell (I think the other shells would also do this). Even BSD-derived systems (FreeBSD, Mac OSX) would do this. ---------------------------------------------------------------------- - Rick Stevens, Systems Engineer, AllDigital ricks@alldigital.com - - AIM/Skype: therps2 ICQ: 22643734 Yahoo: origrps2 - - - - Beware of programmers who carry screwdrivers - ----------------------------------------------------------------------
On 04/01/2014 08:47 AM, Mark Haney wrote:
Well, someone on the Fedora team needs to fix the documentation then. But now it makes sense. I didn't stop to think about the redirect, since my boss isn't giving me time to think. Apologies for spamming the list.
No apologies needed, as you were simply asking a simple question.
On Apr 1, 2014 9:47 AM, "Mark Haney" mhaney@practichem.com wrote: ...
Well, someone on the Fedora team needs to fix the documentation then. But now it makes sense. I didn't stop to think about the redirect, since my boss isn't giving me time to think. Apologies for spamming the list.
Mark Haney ...
You're referring to a wiki page, right? If so, you're part of the team! IIRC, wiki access requires only a FAS account and the Contributor Agreement ( basically you're saying yes, you can edit my wiki edits, in this case .)
Seemingly minor contributions like this add up. Communicate for big changes, of course, but if you find something like this where the issue is clear, we all benefit.
--Pete
01.04.2014 17:27, Mark Haney:
I've been volunteered to try to build a boot image for a Nitrogen 6x Freescale SOM board using whatever OS I can make work. I chose Fedora's ARM image since I'm more comfortable with using Fedora. In the process of trying to using xzcat to dump the image to the microSD card I noticed something strange. When I tried:
sudo xzcat Fedora-Minimal-armhfp-20-1-sda.raw.xz > /dev/sdb
I would get a 'Permission denied' error.
But when I ran the same command as root directly, it worked just fine. I'm not sure I've ever encountered a situation where sudo wouldn't work like this before. Is there a particular reason for this? Or is this a bug? For the record, I changed nothing on the device between attempts to xzcat the image.
There's nothing strange or weird with that. While xzcat is run via sudo with elevated rights, the output redirection is done by the user's shell (i. e. *not* with elevated rights). Do, for example, something like sudo date > output.file and look who's output.file's owner.