Because people assume. I was one of those people. It's easy to understand why people assume. It looks dangerous. But you can't actually move things to /dev/null — It's a special file that just absorbs redirects (and sends them into nothingness).
If you try to move a directory to it, the filesystem will verbosely explode in your face and if you try to move a file to it, you will probably end up replacing it. The first link will deal with directories, but here's a separate test just for overwriting it with a file. As Rmano points out in the comments, this is probably something you shouldn't do without adult supervision. There is risk involved. $ echo 'this is my file' >test $ cat test this is my file $ sudo mv test /dev/null $ cat /dev/null this is my file # Fix this! $ sudo rm /dev/null $ sudo mknod -m 0666 /dev/null c 1 3. /dev/null is just a file, it's a 'special character' file but it's non the less still bound by the rules that files must follow.
That being said you could never run this command: $ mv ~ /dev/null The mv command won't allow this since you're moving a directory to a file, that just doesn't make sense contextually and mv knows this. Example $ mkdir dir $ touch afile $ mv dir afile mv: cannot overwrite non-directory ‘afile’ with directory ‘dir’ You can't copy onto /dev/null either, given it's a character file, if you try to copy a regular file onto it. $ cp ~/bzip2_1. Dying Light Crack Only Nitro. 0.6-4_amd64.deb /dev/null $ ls -l grep null crw-rw-rw- 1 root root 1, 3 Mar 16 14:25 null About the only thing you can do to this file is copy mv over it another file or delete it. $ mv /path/to/afile /dev/null After this command, /dev/null is a regular file. The most dangerous effect of this change is that /dev/null is supposed to never output any data, so a number of shell script will assume that `.
You can write files or other input streams to /dev/null but not directories. If you try moving a directory to /dev/null it would report an error since /dev/null is not a directory but a file. However, since you want to experiment with /dev/null, you are first suggested to know the consequences to moving a file to overwrite /dev/null and how to recover from that situation: • As suggested by in to that question, in order to experiment with /dev/null we should rather create a copy of it and then do our experimentation. So, let's create /tmp/null and use it for our experimentation purposes: sudo mknod -m 0666 /tmp/null c 1 3 Now onwards, /tmp/null is our /dev/null for all purposes: Let us create a test_file and a test_dir inside a directory called ask_ubuntu. $ mkdir ask_ubuntu $ cd ask_ubuntu $ touch test_file $ mkdir test_dir $ echo 'Let us test if we can recover our test_file.'
Cp /dev/null and ls issues. Is copying /dev/null onto a file generally something one shouldn't do? (It was -hopefully- a temporary solution in this case.).
>Spore Dark Injection Mod Free Download on this page. test_file The following shows the contents of ask_ubuntu directory: $ ls -la total 12 drwxr-xr-x 3 aditya aditya 4096 Mar 18 17:10. Drwxr-xr-x 4 aditya aditya 4096 Mar 18 17:10. Drwxr-xr-x 2 aditya aditya 4096 Mar 18 17:10 test_dir -rw-r--r-- 1 aditya aditya 0 Mar 18 17:10 test_file Now try to move our test_file to /tmp/null and see the contents of ask_ubuntu: $ sudo mv test_file /tmp/null # This succeeds $ ls -la total 12 drwxr-xr-x 3 aditya aditya 4096 Mar 18 17:12. Drwxr-xr-x 4 aditya aditya 4096 Mar 18 17:10. Drwxr-xr-x 2 aditya aditya 4096 Mar 18 17:10 test_dir The command succeeds and test_file is no longer available. Now try to move test_dir to /tmp/null which doesn't succeed: $ sudo mv test_dir/ /tmp/null mv: cannot overwrite non-directory ‘/tmp/null’ with directory ‘test_dir/’ test_dir is still present inside ask_ubuntu: $ ls -la total 12 drwxr-xr-x 3 aditya aditya 4096 Mar 18 17:12. Drwxr-xr-x 4 aditya aditya 4096 Mar 18 17:10.