Someone mentioned

echo "" > /dev/null 

as a command to me that I should run. I am too nervous to try, however, because someone else on the internet mentioned that it seemed "relatively harmless..."

What will this command to? I am considering running it in a VM, but I don't have one set up and I don't want to waste my time if it does nothing. I also don't want to run it on my system, either, in case it is dangerous.

What does it do?


It's not dangerous.

  • The echo command is used to send output to stdout. This is usually your terminal but can be redirected to other things.
  • The > redirection operator will redirect output from stdout to a file of your choosing.
  • Files in /dev are usually a special type of file that send output to a device driver instead of storage.

Under modern Unix systems, these "special" files are made and dynamically maintained by a hardware detection process - udev or systemd under Linux, for example. But it is possible to have a completely static system where these are manually made (via mknod is one way) if the hardware in the system does not change - before the prevalence of Plug-and-Play interfaces (e.g. various Unices in the 70's, 80's and early 90's), this was common.

/dev/null is a standard Unix device driver that simply throws away what it receives. It's often used to throw away unwanted output or for testing.

If you are running this under Windows' Linux Subsystem for Windows, I'm not sure how it makes these files, but the LXSS is probably presenting a virtual version of them to programs that run under the subsystem for compatibility. (Windows has a "Null" device driver if you look in devmgmt.msc under "Non Plug-and-Play Devices" - the LXSS is probably doing things behind the scenes to make /dev/null really use that Windows driver.) Cygwin, another software that presents a Linux subsystem, does this too.

"" is a null string, meaning nothing, but echo adds a newline unless the -n switch is specified, so echo "" outputs a newline to stdout (redirected to /dev/null in the example).

| improve this answer | |
  • 3
    As a footnote, while the questioner's command could be used as a "do-nothing" command, it is much more efficient to use : for this purpose instead. – AFH Feb 6 '17 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.