You are not logged in.

#1 2020-08-01 09:03:12

funkaddict
Member
Registered: 2018-08-13
Posts: 83

[SOLVED] I just destroyed my user directory by mv /*

Hey there,

out of outrageous stupidity I

 find /* -type -f -print0 | xargs -0 mv -t /home/user/Desktop/ 

While being logged into my user account and running X (XFCE), I moved all files I could get my hands on (unintenionaly) to a certain folder.

Of course nothing works any more, as many symlinks have been moved. I cannot open a single program not even the terminal. What i can use are programs which I have opened before doing that mv command. Those are one Terminal window where it still reads all the feedback from the command above. A firefox window, and some other programs.

Despite this outrageus stupidity could please somebody help me, how to recover? Of course I have backups, but only of the files, not the system. And it would be great if I somehow could revert that command.

Edit: Maybe to specify things a bit more clearly: I did the command as user, not as root. So only user files have been moved. However, It would be fantastic if there is a way to restore those user files by somehow reverting that mv command. I know. That is not intenionally, and all I found so far says, that this doesn't work. But maybe, there is a workaround for such a case?

Last edited by funkaddict (2020-08-02 08:01:26)

Offline

#2 2020-08-01 10:03:53

frostschutz
Member
Registered: 2013-11-15
Posts: 958

Re: [SOLVED] I just destroyed my user directory by mv /*

Reinstall and restore backup is pretty much unavoidable here. This just isn't reversible in a sane way.

Preserve the mess you currently have, all of it not just the Desktop/ dir.

Then after reinstall/restore you can see if there are any files in the mess-up that are newer than or missing from the restored system. That way you can pull out some files.

Or you could treat it like a photorec restore that preserved filenames and designate new locations for them depending on file type.

Either way it involves some manual labor ( or more scripting with find, practice makes perfect :-) )

Offline

#3 2020-08-01 10:19:12

funkaddict
Member
Registered: 2018-08-13
Posts: 83

Re: [SOLVED] I just destroyed my user directory by mv /*

frostschutz wrote:

Reinstall and restore backup is pretty much unavoidable here. This just isn't reversible in a sane way.)

Thank you for the answer, even tough that was what I was afraid of hmm Especially with regard to the amount of work this implies.

frostschutz wrote:

Preserve the mess you currently have, all of it not just the Desktop/ dir.

Just to be shure that I don't get something wrong here. What do you mean with "not just the Desktop" dir. Of course I would also backup latest thunderbird user files, zotero library, etc. Is that what you mean?

frostschutz wrote:

Either way it involves some manual labor ( or more scripting with find, practice makes perfect :-) )

That's true. However, I did not intend to spend my weekend on a fresh install and config of my System. I have Arch in a encrypted folder, which allways gives me some headache when configuring wink Furthermore, I have win10 in vbox and another win10 physical installation.

Anyway, thank's again for your support.

Offline

#4 2020-08-01 10:39:15

frostschutz
Member
Registered: 2013-11-15
Posts: 958

Re: [SOLVED] I just destroyed my user directory by mv /*

funkaddict wrote:

What do you mean with "not just the Desktop" dir.

Preserve everything the way it is now.

When mv moves all files into a single folder, it tries to avoid clobbering files like this

mv: will not overwrite just-created 'bar/file' with 'foo/file'

So some files may be left at their original locations. Hence preserving only the target folder is not sufficient.

However, it's the nature of 'xargs' to run 'mv' more than once. It fills up the mv parameter list as long as it may be, and then makes another call to mv with the remaining files. Rinse and repeat.

Between separate mv calls there is no clobber protection, so it's possible you may have lost some same-named files if they weren't in the same call.

In short it's a big mess. And it can't be reversed.

The things you (probably) didn't lose are files with unique filenames across all folders, and thus if you preserve everything, you can pull them out after restore, if the backup didn't have the same file already anyway.

Offline

#5 2020-08-01 12:35:02

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 23,934
Website

Re: [SOLVED] I just destroyed my user directory by mv /*

You say you ran this while logged in as a user ... not as root?  Did you actually include 'sudo' in there somewhere?  If so, where?  If not, that command would not cause the problems you are describing.  It could displace all your user configs, but no system files.

EDIT: oops, I missed your edit.  But just the same, everything should still "work" if only user files moved.  Just newly launched programs will not have your user-defined settings but will fall back to defaults.

Last edited by Trilby (2020-08-01 12:36:53)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2020-08-01 12:50:10

ondoho
Member
Registered: 2013-04-30
Posts: 638
Website

Re: [SOLVED] I just destroyed my user directory by mv /*

funkaddict wrote:

Of course I have backups, but only of the files, not the system.

What exactly does this mean?


However studied and stilted your rant, it can never hide the base and primitve emotion that inspired it.

Offline

#7 2020-08-01 13:30:10

funkaddict
Member
Registered: 2018-08-13
Posts: 83

Re: [SOLVED] I just destroyed my user directory by mv /*

Trilby wrote:

You say you ran this while logged in as a user ... not as root?  Did you actually include 'sudo' in there somewhere?  If so, where?  If not, that command would not cause the problems you are describing.  It could displace all your user configs, but no system files.

EDIT: oops, I missed your edit.  But just the same, everything should still "work" if only user files moved.  Just newly launched programs will not have your user-defined settings but will fall back to defaults.

Indeed. Programs are working, except the user specific configurations. So

  • Keyboard has english layout instead of german (QWERTY)

  • IP configs are gone

  • XFCE configs are gone

  • BackInTime configs are gone

  • etc.

ondoho wrote:
funkaddict wrote:

Of course I have backups, but only of the files, not the system.

What exactly does this mean?

Sorry for the confusion. This means, that I have backup of my personal files, like documents for work, music, etc. However, this backup is one week old.

So basically it makes sense trying to restore the user configs or, configurate those which cannot be restored.

Last edited by funkaddict (2020-08-01 13:34:04)

Offline

#8 2020-08-01 18:30:47

u666sa
Member
Registered: 2020-08-01
Posts: 8

Re: [SOLVED] I just destroyed my user directory by mv /*

funkaddict wrote:

Especially with regard to the amount of work this implies.

So long as customization and nvidia drivers is not taken into account, installing arch is a 10 minute ordeal. Use zen installer.

Offline

#9 2020-08-01 18:33:00

Scimmia
Bug Wrangler
Registered: 2012-09-01
Posts: 7,781

Re: [SOLVED] I just destroyed my user directory by mv /*

u666sa wrote:
funkaddict wrote:

Especially with regard to the amount of work this implies.

So long as customization and nvidia drivers is not taken into account, installing arch is a 10 minute ordeal. Use zen installer.

At that point, you're not running Arch and your installation is NOT supported here, or in any of the official support channels.

Offline

#10 2020-08-01 20:00:41

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 23,934
Website

Re: [SOLVED] I just destroyed my user directory by mv /*

What the hell.  It's been established that no root owned file - nothing installed by pacman - has been touched.  So the advice on reinstalling the OS, whether via some unsupported installer or not, is just silly.

All that has been lost is user files, reinstalling is irrelevant to those and would be a waste of time.

OP, perhaps you should update your title: you have not destroyed your root directory, just your user's home directory.

Last edited by Trilby (2020-08-01 20:01:39)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#11 2020-08-02 08:00:40

funkaddict
Member
Registered: 2018-08-13
Posts: 83

Re: [SOLVED] I just destroyed my user directory by mv /*

u666sa wrote:

So long as customization and nvidia drivers is not taken into account, installing arch is a 10 minute ordeal. Use zen installer.

Well yes, I am talking mainly about the custimzation. Especially on a notebook with thunderbolt3, nvidia+intel gpu, dualboot+win10 in virtualbox, with drive encription, etc. etc.

And after some tries at the beginning, I am doing those things manually. The strength of Arch is the wiki and the forum. And that's the approach recommended.


Trilby wrote:

What the hell.  It's been established that no root owned file - nothing installed by pacman - has been touched.  So the advice on reinstalling the OS, whether via some unsupported installer or not, is just silly.

All that has been lost is user files, reinstalling is irrelevant to those and would be a waste of time.

OP, perhaps you should update your title: you have not destroyed your root directory, just your user's home directory.

Exactly. I did the mv command in the root folder, but as the command was run with user priveleges only, user files where moved.

So I am currently restoring the configurations and the files, based on my backups and the newer files (moved by use of mv)

I change the title and marking it as solved. Thank you all for the contribution. This was a really strange day yesterday.  Sorry for the misunderstandings.

Offline

#12 2020-08-02 08:23:22

frostschutz
Member
Registered: 2013-11-15
Posts: 958

Re: [SOLVED] I just destroyed my user directory by mv /*

Trilby wrote:

you have not destroyed your root directory, just your user's home directory.

that's assuming best case scenario.

worst case scenario:

- files had wrong permissions so anything goes (does not exist in theory but happens in practice all the time)
- user's homedir
- other users homedirs (when using shared directory permission scheme)
- anything mounted under /mnt /media with user permissions at the time (usb sticks mysteriously empty)
- network shares if they existed and were mounted (damage not limited to one machine)
- user's crontab, mail spool, http dir, user owned things commonly found in /var or /srv outside /home
...and so on

Saying it only affected your home directory is too narrow a view. It's difficult to make assumptions about other people's systems running in unknown configurations.

The find command traverses everything. That's a big mess to sort out. It's something you'd expect a malware to do, except you wrote it yourself and ran it on yourself.

Preserve everything (the current state as a whole for later analysis and so you don't lose config files, databases, anything important the user explicitely didn't own), reinstall, restore.

To me following a standard procedure (what you'd have to do anyway if the drive died entirely or if the system was actually compromised) seems simpler than making assumptions and hoping for the best. How to restore (from scratch) should be part of the backup strategy and implemented in a large scale data loss event such as this.

That is how I would go about it but it's an individual choice after all.

Maybe if it happened to my personal system, and I was (over-)confident it was set up correctly and I could assess the damage directly, I could do without reinstalling, too. Hard to say for sure until it actually happens. Hope it never does but we all make stupid mistakes sometimes.

Offline

Board footer

Powered by FluxBB