Just garbled my system by doing sudo mv /*.mp4 $Downloads/* . Apparently I moved the entire filesystem. I can't even use ls or find. So I can't locate the binaries so I can restore it

Just garbled my system by doing sudo mv /.mp4 $Downloads/ . Apparently I moved the entire filesystem. I can’t even use ls or find. So I can’t locate the binaries so I can restore it. I’m blind as a mole. So stupid. Can a kind soul see by looking at the command where they would have been moved?

I was logged in as a normal user at
/home/emil

So $Downloads should be

/home/emil/Downloads

But apparently it is an empty variable, I wasn’t thinking straight.

the home directory and I mean

/home/

Is gone. I really didn’t think straight, guess I’ll never do that again.

Try shutting the system down gracefully by using the System Requests, as detailed in the post below… :arrow_down:

Boot up from the live USB, open up a terminal window, and issue the following command… :arrow_down:

sudo su -

Mount your root filesystem to /mnt, and look around in there. Then come and tell us what you’ve found. We’ll take it from there. :slight_smile:

1 Like

I don’t think that that is what caused whatever problem you have now.

sudo ls /.mp4
yields:
ls: cannot access '/.mp4': No such file or directory

so there is nothing to be moved to begin with
and
$Downloads/
is empty - so nothing to be moved to

When you boot a live system, you can access your $HOME directory and look in the shell history for the last commands you issued.
For Bash shell this file is /home/emil/.bash_history

Actually that would resolve to /, if /.mp4 exists then we’d end up with mv /.mp4 /.mp4 which would be a different error.

The title says *.mp4 and $DOWNLOADS/*, so it would result in this command

sudo mv /*.mp4 /*

/* would presumably list all the files and directories in /. If any files matched then something happened.

% ls                                                                                                                                                                                                             
file  file1  file2  test  test2  test3
% mv *1 *
mv: cannot stat 'file1': No such file or directory
% ls
test3
% ls test3
file  file1  file2  test  test2

*1 results in file1, then * lists all the files and dirs, so we end up with this

mv file1 file file1 file2 test test2 test3

Which of course is a list of files and dirs to move to test3.

If using zsh and *.mp4 doesn’t match then you get an error, in bash you get *.mp4 plus whatever comes after.

% echo *.mp4 *
zsh: no matches found: *.mp4

$ echo *.mp4 *
*.mp4 file file1 file2 test test2 test3

So if the command in the title is correct then this is roughly what was run

sudo mv /*.mp4 /bin /boot /desktopfs-pkgs.txt /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /rootfs-pkgs.txt /run /sbin /srv /sys /tmp /usr /var

In bash, mv would try to move everything to /var, and complain about 1 or more missing files (/*.mp4). This would happen whether /*.mp4 matches or not, as there are other files that do exist.

zsh would of course give zsh: no matches found: /*.mp4, unless 1 or more matching files were found in which case it would also run the command and mv would try to move everything to /var, and complain about 1 or more missing files (listed twice).

2 Likes

In the future, please know that you don’t need root permissions to move files within your home directory.

6 Likes

If this is literally the command that you executed and if $Downloads is not a variable containing a value, then it would simply have attempted to move a directory or file with the name .mp4 from your root directory — where there most likely is no such file or directory — to your root directory, and then that would normally have been a no-op. :thinking:

I’m not sure, but I think the behavior of moving something to a destination in the form of an asterisk is undefined. Shell expansion comes before execution, but given that the globbing character * is used as the destination — because the variable $Downloads most likely doesn’t exist, and therefore expansion would resolve to /* — I’m not really sure as to what the result will have been.

And again, this is if you really did type that as your command. :thinking:

I’ve updated my post. The only question in my mind is what would happen with mount points (I think probably an error), either way everything else would probably be moved to /var.

1 Like

Oh boy! That’s going to be a fun one to fix… :roll_eyes:

And no word from the OP since their opening post. :face_with_diagonal_mouth:

1 Like

Although it seems that exact command cannot produce that result, if the OP says it has been done , i cannot imagine how would that be salvageable. The mountpoints, the permissions, the directory tree and the subfolders…it is all one homogenous mass now.

So just boot from USB, backup your data and maybe .config from the home folder withouth the downloads, wipe the partition clean and reinstall. That’s it.

1 Like

That is also the advice I would give. We don’t know the OP’s skill level, and something like this would already be extremely difficult to repair even for an experienced user. Reinstalling is probably going to take less time and effort. :man_shrugging:

Gollum_Backupses

Ok so I got it figured out - all the root dirs were moved into /var/ , so I mounted a live partitition and moved them back, taking take not to move the ones that actually belonged in /var/ Very simple, once I figured it out.

Thanks for the feedback - and you’re right about all your warnings of course. phew. I couldn’t reply that well, but just reading your comments on the phone helped me get a sense of, so thank you again. and no reinstall needed!

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.