When configuring an application, you can often use /dev/null as config file if you want the application to read an empty file. But, if the application reads a list of files from a directory, you cannot use this trick. You would need to give it an empty directory to read.
I was wondering: does Linux have a default empty directory that can be used for such purposes? I know OpenSSH used /var/empty for a while, and I can of course create an empty dir myself, but maybe the FHS has specified a standard directory for this?
/var/emptyis not empty, but contains a folder calledsshd, so you probably don't want to use that. – knub Dec 07 '16 at 11:30/var/empty– user253751 Dec 07 '16 at 20:47/dev/nullisn't so much for reading as for writing. Data written to/dev/nulljust disappears. So, a directory equivalent would be a place wheremv yourfile /dev/emptywould result in deleting your file. – Wildcard Dec 07 '16 at 21:03mv yourfile /dev/empty/. If you domv yourfile /dev/empty, you're trying to replace the special directory. – Rhymoid Dec 07 '16 at 22:24mvwill copy all the files first and then delete the originals. So that could turn into a very inefficient way to delete files. – kasperd Dec 07 '16 at 23:48/dev/nullthroughddis often used to initialize swapfiles. – Jules Dec 08 '16 at 16:42mvinterprets a command such asmv file /path/to/directoryas "move the file into the directory". – micheal65536 Dec 08 '16 at 17:15/dev/nullandddbecauseddwill get an EOF before it's even written a single byte. I think you're thinking of/dev/zero, which is often used to fill something with or generate a specific number of zeros. – micheal65536 Dec 08 '16 at 17:16mvdetects that, and whether it will know that a special directory is "special" or not. – Rhymoid Dec 08 '16 at 17:42/dev/nullwith/dev/zero. – Jules Dec 08 '16 at 17:52dd if=/dev/null of=target seek=100 bs=1Gif the needed size is 100GB. It won't work for swap files though because the created file will be sparse and a swap file must not be sparse. – kasperd Dec 09 '16 at 21:36/dev/nullreturn an immediate EOF on input, because asynchronous (background) processes have their stdin redirected to/dev/null. This is better than just closing stdin (as in<&-) because (1a) that would causeread()to return an error rather than EOF, and (1b) it would allow the nextopen()to return 0. (2)grepdidn’t always have the-H(--with-filename) option. Before that existed,grep pattern /dev/null *was the standard trick to getgrepto report the filename even if*expanded to only one file. – Scott - Слава Україні Dec 12 '16 at 06:35mkswapon the 100G file finish making it swap? – warren Dec 12 '16 at 18:07mkswapdoes is to write a header to the file. It will still be sparse. Test this sequence of commandsdd if=/dev/null of=target seek=100 bs=1G;mkswap target;swapon target. (You don't even need to berootto test that as it fails before you even reach the step that checks for root privileges.) – kasperd Dec 12 '16 at 21:30