How to do that with a regular sudoers user:
wget -q https://example.com/binary.tar.gz -O - | tar -xzO binary > /usr/local/bin/binary # Doesn't work because I can't write in /usr/local/bin as regular user
I can't use sudo with the redirect >
. So what is the appropriate way to do it?
Subsidiary question: I know I can use tee for the following case:
echo "foo" > /etc/myapp.conf # Doesn't work
echo "foo" | sudo tee -a /etc/myapp.conf # Solution
But I know this is not the goal of tee. So the question is the same for this case: what's the best solution?
EDIT:
- I don't want to use a subshell with something like
sudo sh -c 'my-command'
. One reason is to limit as much as possible the number of commands launched as root. - This is a question to find a solution in the "linux standard", not some kind of hacking.
- I think the goal of tee is to write output to some files AND in the stdout. I don't want to use something which can do that, but something which exists to do that.