I read the Wikipedia article on /dev/null and was playing around by moving files to /dev/null.
For this I created a test_file and put some contents in it:
$ touch test_file
$ echo "This is written by Aditya" > test_file
$ cat test_file
This is written by Aditya
Thereafter I tried to move the file to /dev/null:
$ mv test_file /dev/null
mv: inter-device move failed: ‘test_file’ to ‘/dev/null’; unable to remove target: Permission denied
Since, this gave me a Permission denied Error; I went ahead and used sudo as I normally do whenever I encounter a Permission denied error.
$ sudo mv test_file /dev/null
The command succeeded and test_file is no longer present in the directory.
However, the Wikipedia article says that it is not possible to recover anything moved to /dev/null and it gives an EOF to any process that tries to read from it. But, I can read from /dev/null:
$ cat /dev/null
This is written by Aditya
What did I do wrong and how do I fix /dev/null back to normal? And why did I encounter Permission denied error in the first place?