Score:1

Accidentally moved directories and files under root and reboot the machine

jp flag

I've accidentally run this command

sudo mv /* /applications/minced/

instead of

sudo mv ./* /applications/minced/

Unfortunately, I rebooted the machine And now I am getting this error

view the error

please help me

in flag
The simplest method is to attach your disk to a machine which is booted up on its own system disk.. Then mount the disks as /mnt/root and then after cd to /mnt/root fix your accidentlal command.
Muaath Alhaddad avatar
jp flag
How do I attach the disk? it's an internal disk.
cn flag
Unscrew it and take it out, get an USB casing, insert the disk and connect it over USB. My 1st solution is a lot simpler ;-) The 2nd one I posted it a lot more dangerous than the 1st hence the comment about making a backup 1st.
in flag
I use a USB adapter on my disks.. Then just plug it into another computer as a USB device. Linux won't mind..
bac0n avatar
cn flag
You only need to change the prefix (`set prefix=($root)/applications/minced/boot/grub`), this will enable loading of the missing modules, from there you can take one of two ways, either `insmod normal` that will load the menu, from there you can edit *linux, initrd* path to reflect the current location of the kernel image and initramfs **or** `insmod linux` then `linux ($root)/path/to/vmlinuz`, `initrd ($root)/path/to/initrd.img`, last `insmod boot` and `boot`. This will take you at least to the initramfs (busybox). now you can mount your root partition
Score:3
cn flag

Use a live session, mount the partition and do

sudo mv /media/{id}/applications/minced/* /media/{id}/ 

where {id} is your mountpoint. The files should not have changed owner or group or permissions so that should be relatively safe.

EXAMPLE from comments (so this only works for this occasion; others reading this: change the id and the source dir):

cd /media/ubuntu/5b1d3376-8683-4eb8-9a11-fe346ad3d76e
sudo mv applications/minced/* .

General advice: making a mistake is OK, making a mistake while fixing a mistake is a capital offense. Check what you do 2, 3, 4 times and , if possible, make a log of anything you do so you can backtrack what you did.

===

Otherwise do a reinstall without formatting your disks (only set the filesystems for all partitions related to this install to what it already is (likely ext4) and do NOT pick "format"). If possible make a backup from the live session.

After the system is up you need to clean out /applications/minced/ as it will hold files that used to belong to /.

===

And next time do NOT use sudo for a mv that does not need it. Those files are yours are they not? If so you do not need it. If you did please add yourself to the GROUP that owns the file so you do not need it.

Muaath Alhaddad avatar
jp flag
wait .. Are you suggesting two solutions here. The first one, using Live session. And the second one, reinstalling without formatting?
cn flag
2 possible methods :) "Otherwise " means it is another option ;-)
Muaath Alhaddad avatar
jp flag
I see .. Which way is safer for my data?
cn flag
The 1st one. ANY method that requires you to do something to the hardware (and formatting is a hardware related action) is dangerous and should be avoided. That is why there is a comment about making a backup with that 2nd option ;-)
Muaath Alhaddad avatar
jp flag
This is what I found `media/ubuntu/5b1d3376-8683-4eb8-9a11-fe346ad3d76e/home` Where should I move the files to? inside ubuntu?
Muaath Alhaddad avatar
jp flag
What a wonderful explanation you have !! Thank you so much .. you saved me
cn flag
The 5* is the ID and below that there should be the / of the system itself. Move it to that directory. Oh and you are benefitting from my past mistakes ;-) Been there done it over the past 30 odd years of using Unix, Xenix and Linux ;-)
Muaath Alhaddad avatar
jp flag
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/128796/discussion-between-muaath-alhaddad-and-rinzwind).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.