Hi,
so well, except for 6 directories, all other files and directories in my /home/user/ directory are just gone. The mentioned 6 directories have their change time set to the exact same time, but are empty (all files in this folders are also gone).
What I did:
on desktop1 I opened dolphin in one of my dirs, rightlicked a scriptfile (few lines, containing some echos, scaimage and convert), picked “open with Kate”. I have Kate already opened with a simple textfile on desktop2. KDE switches to desktop2 and kate, shows the file, but it is empty… (which should not be). At first I thought I opened the wrong file, switched by to desktop1 and… the dir opened in Dolphin was empty. Then I saw the Desktop and it is also empty… all files linked to there just gone.
Then I opened a terminal, using cd ~ and ls -l and… everything is gone, except for 6 directories, which on the other side, are empty as well now.
Since I am not a linux expert, I have not the slightest idea where to start looking/troubleshooting (and find all the files, that are gone).
Hope someone can point me in the right direction (I gues the files are for some reason just not visible, ls -la is not helping, because firefox have still all its settings and bookmarks and the profile-dir is also located in /homer/user/)
I assume that the directory name user you use above in /home/user/ is the username of the user that is loged in and that is having the problem? (giving a user the name user isn’t making things vvery clear imho ).
And is the assumption correct that
ls -la $HOME
shows that all directories/files where the name starts with a . (dot) are still there?
user = general, of course for me its /home/mla/ sorry
ls -la $HOME
shows all hidden files, all hidden directories (the contents of the hidden directories are still there), and it shows 6 non-hiddden directories, which are empty
If, for whatever reason, openSUSE executed the script while opening it in a texteditor, and if the rm command parameters were ignored (targetdir and actualy not recursively), then the question is, how do I recover the deleted file? I doubt it is as easy as in windows.
I was also thinking along the same lines as Miuku.
But when you only shhow one line of your script, that will not help much when others should analyze it. Remember that you NOT seeing where it goes “wrong” does not mean that others wouldn’t see it. The writer/owner/maintainer of a program always has some blindness in running through the same loop agian and again. A fresh eye/mind will then probably see things.
Analyzing those 6 names that are still ther might be interesting also.
And for your deleted files, restoring them from your (or the systems) backup is the fatstest way.
The reason I asked you about the rm is because even a space in the command in the wrong place may accidentally execute it in your “default path” (which would be your home).
Also, did the command have any move commands that could have moved the files to another location, such as /tmp ?
You’ve (without a doubt?) checked Trashcan already?
There are ways to recover data from ext4, such as Testdisk or extundelete but under no circumstance should you write anything to the drive as it may overwrite the data you are trying to recover.
Now that explains a lot, thanks! If the script got somehow executed by accident, the parameters were missing (blanks?) and thus could delete the default path, line 21? (could recover the script, sorry no linux expert and only had to remember the script from last time I saw it, … well, already (hours ago) unmounted the device in question, and making it suffer from dd and ext4magic.
When you like to go for serious programming, then you must learn that cheking all parameters comming from outside is a very important security thing to do. IMHO a high percentage of cracking is due to sloppy testing of parameters.
Be glad you did not run this while being the Superuser.
Yeah I agree with hcvv, the TMPDIR parameter was your home directory and it ran the rm -r command there. Stuff like this happens - unfortunately in a system that gives you unlimited power, it also gives you the power to cause unlimited damage.
So the recovery is nearing its completion, unfortunately it consists of names like “RECOVERDIR/MAGIC-3/text/x-c/0007380800.c”. A lesson I am not going to forget. Thanks for your input.
Also using upper case variables for internal purposes is a disaster waiting to happen because all the internal builtin variables are uppercase already so expect more deleted files and directories in the future lol!.
Quote all your variables and please do not parse the output of **ls **a glob will suffice
files=(*)
printf '%s
' "${files@]}"
Or in your case with an extension
pics=(*.jpg)
for i in "${pics@]}"; do
echo "**DO SOMETHING WITH** $i"
done
If $TMPDIR is undefined, $TMPDIR/ will give / and “rm -r $TMPDIR/*” will run
rm -r /*
Which will recursively try to delete all files/directories on your system.
Of course when run as user it will not have permissions to remove everything, but it will in particular delete everything in $HOME of course.
I stand corrected about the trailing / and prolly ~ but most characters will not have the same result. Also if you qoute the * (globe) it will not expand too.