Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using | sudo tee FILENAME to be able to write or append to a file for which superuser permissions are required quite often.

Although I understand why it is helpful in some situation, that tee also sends its input to STDOUT again, I never ever actually used that part of tee for anything useful. In most situations, this feature only causes my screen to be filled with unwanted jitter, if I don't go the extra step and manually silence it with tee 1> /dev/null.

My question: Is there is a command arround, which does exactly the same thing as tee, but does by default not output anything to STDOUT?

share|improve this question
If you replace the tee with cat >filename, do you get the results that you want? – sawdust Nov 11 '12 at 23:12
cat does not write to files by itself. And the > operator doesn't work as the files are not writable by my current user. So no, that doesn't help a bit. And please stop to completely alter your comment's meaning every 2 seconds. Make a new one instead. – aef Nov 11 '12 at 23:14
If you replace the | sudo tee FILENAME with | sudo cat >filename, do you get the results that you want? – sawdust Nov 11 '12 at 23:20
No, the > operator uses the current shell user to write to the file. This user hasn't got the neccessary permissions. cat is completely useless for that. – aef Nov 11 '12 at 23:23
Also see… – Joachim Breitner Apr 26 '13 at 8:10
up vote 7 down vote accepted

Another option that avoids piping the stuff back and then to /dev/zero is

sudo command | sudo dd of=FILENAME
share|improve this answer
Exactly what I was looking for. Great thanks. – aef Sep 7 '13 at 14:36 describes the additional oflag=append conv=notrunc options to use dd for appending. – aef Jan 22 at 9:32

You could use a script. I.e. put something like this in i.e. $HOME/bin/stee, 0tee or similar:


while [[ "$1" =~ ^- ]]; do
    argv+=" $1"

sudo tee $argv "$1" > /dev/null


sudo tee "$@" > /dev/null

Make it executeable:

$ chmod 755 stee

Now do i.e.:

$ ls -la | stee -a /root/foo

share|improve this answer
Writing a script and deploying it to all the systems I work on is not exactly what I wanted, but until someone names an already existing tool, I think I'll go with your solution. – aef Nov 12 '12 at 0:07
Indeed. Would like to see it myself. I wrote a program in C a long time back that did what you ask, but it is a long time gone and forgotten. There was close to no interest for it back when. But then again I did not actually advertise it much. – Luca Stein Nov 12 '12 at 17:59

The dd solution still prints junk to stdout:

$ ls | sudo dd of=FILENAME
0+1 records in
0+1 records out
459 bytes (459 B) copied, 8.2492e-05 s, 5.6 MB/s

That can be avoided using the status option:

command | sudo dd status=none of=FILENAME

Another interesting possibility (for Linux anyway):

command | sudo cp /dev/stdin FILENAME

To copy TTY input into a file, I often do this:

sudo cp /dev/tty FILENAME

It's too bad tee doesn't have an option to suppress stdout.

share|improve this answer

There is not directly a program to do that (this is pretty much the only time that it would be useful), but you could easily write your own. If you do not want to program, you could also write a simple shell script that does the same thing: cat > $1. This is different from putting it inline (as sawdust suggested) because the sudo will apply to the entire script, including the redirection.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .