1

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

mv directory/* /*
0

3 Answers 3

3

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).

1

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).

2
  • Would a reboot fix the problem?
    – user31200
    Apr 2, 2010 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. Apr 2, 2010 at 8:20
1

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.

2
  • How could I do that: "You will have to move the root directories back to the root."?
    – user31200
    Apr 2, 2010 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, 2010 at 17:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .