While moving a text file from desktop to /var/www/html directory using the command:
$ mv /home/xyz/Desktop /var/www/htmlI missed writing the file name after Desktop(I.e. The command should have been $ mv home/xyz/Desktop/test.html /var/www/html), now that I had moved an entire directory to /var/www/html I deleted it using the command:
$ rm -r Desktop (while I was in the html directory). Now, although I can see the files and folders on my desktop I'm unable to access or open them, it says
"This location cannot be displayed, perhaps it has been deleted". Please tell me how I can retrieve my files on the Desktop :(
2 Answers
The files were unlinked by the rm command. The data is still sitting there on your disk, but the link to them has been removed.
Therefore stop using the machine immediately as the more you use it, the more the unlinked files get destroyed...
Please use photorec: you can find more information about it here and here, and this video shows you how to use it.
For more info : Where do files go when the rm command is issued ?
1I'm sorry, the only way to retrieve them now is from backup.
After you mv (move) files, you still have only one copy of the file.
After you moved your Desktop to the wrong location, you should have just moved it back:
mv /var/www/html/Desktop /home/xyzBut you can't do that now because instead you removed (rm) them. Once a file is removed 99.9% of the time, there's no way to get it back.
Lessons learned.