More for you to like:
Closed Captioning Closed captioning available on our YouTube channel
You Might Like

How to use /dev/null: 2-Minute Linux Tips

Network World | Jun 14, 2019

In this Linux tip, learn how to use the /dev/null tool. You can send your outputs to /dev/null and it simply disappears. This is helpful when a command’s output isn’t interesting and you don't need to see it.

Copyright © 2019 IDG Communications, Inc.

Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at a special device called /dev/null – sometimes referred to as the “bit bucket” -- that acts something like a black hole on the Linux command line. Send output to /dev/null and it simply disappears.
OK, that was easy, but why would anyone want to do this? Well, there really are times when a command’s output isn’t interesting. Even if you need to run the command, you won’t always want to see its output.
For example, the find command – one that, by its very nature, is likely to generate some “permission denied” errors.
Using 2>, we see the output we’re looking for, but hide the errors. You can select which output you send to /dev/null using the 1> (normal standard out) and 2 (error) output.
And if you want to know if any errors were generated, you can find out like this:
The 1 is the return code from the command and anything greater than 0 indicates there were errors.
If, for some reason, you only want to see the errors, try this instead:
You can also use /dev/null to empty a file. If you want to remove the contents of a file without removing the file itself, you can do something like this:
You can, however, do the same thing more simply with a command like this:

That’s your Linux tip for today. If you have questions or would like to suggest a topic, please add a comment below. And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and

Featured videos from