19

After trying to remove Wine from Ubuntu, all my files were suddenly gone. That is, I do not see any of my documents etc., but my hard drive says only 3 GB is still available (which is common for my small hard drive).

The problem occurred after doing this: How to remove wine completely and then the top rated answer (of pagal pila). Most likely I did something not appropriate for my version/pc (Learned the hard way that people shouldn't just try commands they don't understand).

Does anyone know how to recover/show my removed/hidden files?

As commented, I ran history:

    1  sudo apt-get remove --purge wine  
    2  rm -rf $HOME/ .wine  
    3  sudo  
    4  sudo rm -rf $HOME/.wine  
    5  sudo rm -f $HOME/.config/menus/applications-merged/wine*  
    6  rm -f $HOME/.config/menus/applications-merged/wine*  
    7  rm -rf $HOME/.local/share/applications/wine  
    8  rm -f $HOME/.local/share/desktop-directories/wine  
    9  rm -f $HOME/.local/share/icons/????_*.xpm  
   10  sudo apt-get remove --purge wine  
   11  sudo apt-get update  
   12  sudo apt-get autoclean  
   13  sudo apt-get clean  
   14  sudo apt-get autoremove  
   15  apt-get update
AsMek
  • 301
  • 2
  • 5
  • 5
    Please [edit] your question and show us the exact commands you ran. You can see them by opening a terminal and running `history`. – terdon Jun 23 '16 at 09:11
  • 6
    Lesson learned: Don't use `f` in `rm` unless you have confirmed it will delete what is intended and always check `rm` commands more than once ;-) Oh and the mandatory: always make a backup on regular intervals. – Rinzwind Jun 23 '16 at 10:04
  • 1
    Great tip on linking to the instructions you followed that caused the nuking, we have added comments on that page, hoping to prevent the next one following them from making the same mistakes as you – Ferrybig Jun 23 '16 at 19:03
  • 7
    Line 2 in your history says it all. An extra space bettween `$HOME` and `.wine` first deleted your entire home directory, and then a file called `.wine` in your working directory. – user35581 Jun 23 '16 at 20:57
  • 3
    Possible duplicate of [Made a huge mistake and deleted my /home/user folder (Ubuntu 14.04 LTS)](http://askubuntu.com/questions/779190/made-a-huge-mistake-and-deleted-my-home-user-folder-ubuntu-14-04-lts) – Andrea Lazzarotto Jun 24 '16 at 12:36
  • @AndreaLazzarotto While the two questions are about the same type of underlying problem, the question posed seems different. – user Jun 24 '16 at 14:15
  • @MichaelKjörling I understand from the question that the OP deleted the whole home directory. The scenario is exactly the same, the fact that the *original* intentions were to clean up Wine settings does not impact this. – Andrea Lazzarotto Jun 24 '16 at 14:29
  • @askme did you manage to restore your files? :) – Rinzwind Jul 15 '16 at 09:51

2 Answers2

62

rm -rf $HOME/ .wine I see a space there ... You nuked your home with that.

Does anyone have a clue how to recover/show my removed/hidden files?

Got a backup? If so use that. Otherwise ...

  • do NOTHING with that system. N O T H I N G. Any change to that bit of the disk lowers your ability to recover anything from it.
  • Boot up a Live DVD and install "testdisk" in it.
  • Run testdisk and have it scan that partition.
  • Start praying.
Rinzwind
  • 293,910
  • 41
  • 570
  • 710
  • 4
    Ouch!! That really hurts! Do you know why he used that `-rf` option? Like why `rm` wasn't enough? I think this a very good lesson for newbies not to trust commands (or arguments) they don't fully understand. – ipse lute Jun 23 '16 at 09:57
  • 3
    @ipselute, I don't know if this is exactly why, but when I have tried deleting Wine-related resources in the past it asks `rm: remove write-protected regular empty file 'FILENAME'?` for every single file. Using `rm -rf` skips the prompts. – user1717828 Jun 23 '16 at 13:13
  • 3
    My recommendation to avoid this kind of thing: always use the graphical file manager to delete things. – Jonas Czech Jun 23 '16 at 13:45
  • 1
    @MichaelKjörling, the `-r` option tells `rm` to operate recursively on the directory you pass it. The `-f` option suppresses a lot of prompts related to deleting read-only files or deleting files that were passed to `rm` but not present on the filesystem. – sherrellbc Jun 23 '16 at 14:50
  • 2
    Always do an equivalent `ls` to check what is shown and would be deleted. Plus I would advice to create a backup with `tar` so you can revert the deleting if you do not create backups regularly. – Rinzwind Jun 23 '16 at 14:54
  • I thought people only joke about this thing happening. And you would think modern systems will automatically alias `rm` to `trash` so that `rm` just moves items to the recycle bin, just like deleting them in a GUI or rewrite `rm` altogether to do that. – lightalchemist Jun 24 '16 at 08:03
  • 1
    servers do not have a trash and it is up to the admin to create backups. – Rinzwind Jun 24 '16 at 08:14
  • @ipselute the `-r` is necessary because `.wine` is a directory. You cannot just `rm .wine`, it won't work. – Andrea Lazzarotto Jun 24 '16 at 12:35
  • @lightalchemist Linux systems will often not prevent you from shooting yourself in the foot. You can even do `rm -rf /*`. – Léo Lam Jun 24 '16 at 18:23
  • If you look around, you can find various aliases you can install on your system to make the rm command effectively use a trash can, just like the GUI tools. Just don't become reliant on it. – Perkins Jun 24 '16 at 19:27
21

Here

rm -rf $HOME/ .wine  

There is a space between $HOME and .wine. So, it means that rm has to force (f) the recursive (r) removal of both $HOME and .wine.

So, you chose to remove all the things in your home folder :)

There is no "undo" option here, the best solution is to recover from a previous backup.

Or, you can try from a live file system to use testdisk and photorec in order to recover your data.

Please note that, if you used the computer after the disaster occurred, it is highly unprobable that you will succeed at it.

dadexix86
  • 6,596
  • 2
  • 39
  • 113