Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

my server (Ubuntu) doesn't went right and I think it's because I entered that command:

mv directory/* /*
share|improve this question

3 Answers 3

up vote 3 down vote accepted

Yeah, that could really mess things up, if you did it as root. If you think about how the shell would've expanded that, you probably moved everything from / into whatever the last directory in / was...maybe /var?

Do an ls -Al / and paste in the results here. If you only see one directory, do an ls -Al of that directory and paste in the results here.

One way to try to fix it is to figure out which files and directories got erroneously moved, find there they are, and move them back into /. You might do something like this:

  1. Look at a similar installation of Ubuntu on another machine and do an ls -Al / there, to see what files and folders are usually there.
  2. Still on the other, working Ubuntu server, do an echo /* and make a note of the last directory mentioned in the output of the echo command. I've been guessing that it'll be /var but that's based on my experience with other Unices and distros, not Ubuntu.
  3. Back on the failing machine, do an ls -Al of whatever that last directory was, and see if all those files and directories that were supposed to be in / are now in that other directory.
  4. If you found the missing root-level directories in this subdirectory, issue a mv command to move them back to /. Make sure not to leave the normal contents of that subdirectory alone. You don't wan't to move everything out of /var and into /, you just want to move the stuff that was supposed to be in /.

Note that you'll need to issue that mv command as root, (e.g. by using sudo).

share|improve this answer

The real question, of course, is how to fix it. :)

Boot into your Ubuntu LiveCD, mount the filesystem, and move the other contents of your root directory out of /var (or wherever they ended up).

share|improve this answer
    
Would a reboot fix the problem? –  user31200 Apr 2 '10 at 7:36
1  
No. It can even make things worse, as, depending on what files and directories got moved, the system may not be able to boot. You should try to fix it with the shell session you have available. As the things are probably really broken, it may be hard to even open another shell session. –  Jacek Konieczny Apr 2 '10 at 8:20

Would a reboot fix the problem?

Not a chance .. You will have to move the root directories back to the root. Look, this is what happened:

$ mv -v source/* target/*
`source/1' -> `target/3/1'
`source/2' -> `target/3/2'
`source/3' -> `target/3/3'
`target/1' -> `target/3/1'
`target/2' -> `target/3/2'

Look at the last two lines there. That means e.g. '/bin' will have been moved to '/var/bin' on your machine.

share|improve this answer
    
How could I do that: "You will have to move the root directories back to the root."? –  user31200 Apr 2 '10 at 8:57
    
@poru I updated my answer (Spiff's answer, not Jean's) to suggest how you could move your directories back to the root. –  Spiff Apr 2 '10 at 17:01

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.