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?
rmto remove files/directories... I just read about/dev/nulland in order to understand more about it, I tried to move files to/dev/nulland see the effect.. This question is about understanding what did I do wrong by moving files to/dev/nullas a result of which I can read from it now... The question is not about how to remove files from system... I hope it is clear... But your answer is still welcome and good enough to be kept as an answer... :-) – Aditya Mar 18 '14 at 18:18