Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I ran mv -n /desktop /user/local/bin and as a result everything on my desktop is gone. I tried the opposite mv -n /user/local/bin /desktop in the hopes of undoing it but now only one of those directories will exist at one time. What should I do? How badly did I screw things up?

share|improve this question

migrated from stackoverflow.com Jun 28 '11 at 23:45

This question came from our site for professional and enthusiast programmers.

    
What's in /desktop now? All your files PLUS the original content of /user/local/bin? In that case you could try to separate the two manually. –  Kerrek SB Jun 28 '11 at 23:50
1  
How did you have filesystem permissions to do that? You aren't running as root, are you? And why do you have a desktop folder in the root directory? –  Keith Jun 29 '11 at 0:26
    
I ran sudo. As you can tell, my sh*t's messed up. –  Justin Meltzer Jun 29 '11 at 1:04

3 Answers 3

The opposite of

mv /desktop /user/local/bin

is

mv /user/local/bin/desktop /

However:

  • I assume you meant /usr instead of /user. If you really typed /user, you have a different problem.
  • Don't just type the above command without actually understanding what you've done. You may be royally messing things up by moving directories around arbitrarily.
  • Don't run as root. If you weren't, you wouldn't have been able to mess it up in the first place (since normal users can't write to /usr/local).
share|improve this answer
    
Beat me to it.. –  tjm Jun 28 '11 at 23:48
    
well right now /desktop is a directory but /usr/local/bin is not. What should i do to restore order? –  Justin Meltzer Jun 28 '11 at 23:50
    
ok everything you said has been right, but you havent helped me fix my problem. Right now I have /desktop as a directory, but /usr/local/bin is not. How can I fix this? –  Justin Meltzer Jun 29 '11 at 0:05
    
You probably now have a /desktop/desktop also, which is the original contents of /desktop. If so, then try: mv /desktop /usr/local/bin followed by mv /usr/local/bin/desktop /. –  Greg Hewgill Jun 29 '11 at 0:08
    
I don't have /desktop/desktop. Now /desktop has all of its old stuff –  Justin Meltzer Jun 29 '11 at 0:11

The -n flag should have prevented anything from being overwritten.

The first move: mv -n /desktop /usr/local/bin could have done several things:

  1. If /usr/local/bin was a directory, then the /desktop should have been placed in it creating /usr/local/bin/desktop
  2. If /usr/local/bin did not exist but /usr/local was a directory then /desktop was moved to /usr/local and renamed to 'bin' creating /usr/local/bin with the contents of /desktop.
  3. If /usr/local/bin existed and was a file then the -n should have just given you an error message.

The second move: mv -n /usr/local/bin /desktop was not the opposite if #1 was true. If #1 was true then /usr/local/bin is likely now just /usr/local and what was 'bin' is now in /desktop, but there is a /desktop/desktop

The confusion comes because mv has both a rename function and a move function that depends on what the source and destinations are (i.e., files or directories).

Good luck, do a bunch of lss to see what is where and once you have found everything, read and re-read the man-page for mv, then proceed with caution... oh and by the way, as has been said above, operating as root is not a good idea... with great power comes great responsibility, and the ability to trash your system fas

share|improve this answer

You can always (as root) recreate /usr/local/bin

Do you have the executable files to move back into it? Maybe not, since you said you moved the files, rather than copied them.

The /bin directory is not the same thing. It is meant for system binaries, like bash.

/usr/local/bin is meant for executables installed by the user (hence /usr/...)

But your comment about sudo suggests that it will be dangerous to do these things unless you have a better understanding of the system and the use of sudo.

Don't rush into it

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.