Is there a directory equivalent of /dev/null in Linux?

The FHS provides no “standard” empty directory.

It is common for Linux systems to provide a directory /var/empty, but this directory is not defined in FHS and may not actually be empty. Instead, certain daemons will create their own empty directories in here. For instance, openssh uses the empty directory /var/empty/sshd for privilege separation.

If your need for an empty directory is transient, you can create an empty directory yourself, as a subdirectory of /run or /tmp. If you’re doing this outside the program, you can use mktemp -d for this, or use the mkdtemp(3) C function inside your program. Though if you always need the empty directory to be present, consider creating one under /var/empty as openssh does.

For this use case, creating a directory under /tmp is probably the best fit, though in practice it doesn’t matter very much where you put it.

Leave a Comment