Linux Command: ‘tee’ – Watch & Log Command Output

Video is ready, Click Here to View ×

The ‘tee’ command allows you to monitor a command’s output in your shell (or piping that output to another program) while *also* writing it to a logfile. Now you can have your Linux cake and eat it, too!

Full Linux Sysadmin Course:

Check out my project-based Linux System Administration course (free sample videos):…


  1. You might have wanted to mention the magic of "2>&1 " before piping because without this it only pipes the STDOUT but with this it pipes STDOUT and STDERR. Considering the most common use-cases, this is probably a must-know.

  2. Another tip on this command:
    Good to redirect the output to a process run as another user.

    Simple example when logged in as a normal user:
    This will not work: sudo echo "myawesomecomputername" > /etc/hostname
    This do work: echo "myawesomecomputername" | sudo tee /etc/hostname

    Sure there are many other ways to to this particular example. The point being is that one sometimes need to run something as a user, but need to process the output as another user. tee will help there.

  3. Hey, thanks for the cool tutorial… but can you also explain what are those green/red arrows on the left side of your prompt?!
    What terminal are you using? Isn't it GNOME's "terminator" by any chance?

  4. cool, this would be great for something like sudo watch tail -f /var/log/syslog | tee -a bla.txt if you wanted to capture just the output of a specific configuration change or problem for reviewing later. Thanks for the great tip!

  5. Another nice use case is when you want to log an interactive command, so something where you get asked stuff once in a while (username or password for example). Even though the script command might be more useful in that scenario.

  6. Another benefit of tee, is that it allows you to use sudo if you need to. For example running something like "sudo date >> mylog.log" is not going to work, running though "date | sudo tee -a mylog.log" will do the trick.

  7. This was very useful! thank you for the video!
    tee is one of those commands that I had seen before but I never really knew what it was for or how to use and your explanation was so good I was even able to use it right away on a script I was writing in PowerShell.

  8. Thanks for a video, though it looks more like one of the "Hello world" one…
    Would love to see the use of this command along with some python/bash script, to actually show it's usefulness and convince me to use it. We need more high level stuff! ๐Ÿ™‚ Still thanks ๐Ÿ˜‰

Leave a Reply

Your email address will not be published.