0

I typed this command in the terminal while trying to check if I correctly installed LAMP (Linux, Apache, MySQL, PHP) equivalent packages in Ubuntu:

sudo mv /home testing.html /var/www/html

I am new to this, and i wanted to move the testing.html file from home to /var/www/html folder and then run the http://localhost/testing.html to check if installation is complete.

After that it started displaying that my home directory and my directory under it; named yashgugale has been deleted (yashgugale had all the system files). Every time i tried to access documents, pictures, etc. under yashgugale. Now it even refused to open terminal and I was unable to copy my yashgugale folder back into default start directory.

Where did I go wrong and how I can correct this problem?

3
  • I think by recreating a home directory for the user you can.
    – BDRSuite
    Aug 12, 2015 at 7:57
  • You will need a live CD to fix that. But just out of curiosity as I have never had your issue, but does the following work? Press Alt+F2, this will open dash in a way to allow to run a command. Try running pkexec mv /var/www/html/home /home in that box. If it works, this would save you lots of time as you won't need to use a live CD anymore.
    – Dan
    Aug 12, 2015 at 8:05
  • I reinstalled Ubuntu from bootable pd, and replaced previous version with new one. As it is there was less data on it, but now I know where I went wrong. Thanks :) Aug 13, 2015 at 7:45

1 Answer 1

1

Note: Before trying anything, try Dan's solution in a comment under your question:

Press Alt+F2, this will open dash in a way to allow to run a command. Try running pkexec mv /var/www/html/home /home in that box.


I suspect you may have moved /home to /var/www/html/home

If that's the case, run the following to reverse the process:

sudo mv /var/www/html/home /home 

Otherwise, if needed you can recreate a home for your user with:

sudo mkdir /home/$USER
sudo chown $USER: /home/$USER

You should have originally typed something like:

sudo mv /path/to/testing.html /var/www/html/

Note the trailing slash. /var/www/html is the html directory. /var/www/html/ means inside the html directory. It's not always needed but I prefer it as it gets me in the habit of giving the system unambivalent instructions.

Note: You will probably need to do this via a livecd:

As per http://www.howtogeek.com/howto/linux/reset-your-ubuntu-password-easily-from-the-live-cd/?PageSpeed=noscript, boot up your livecd, open a terminal and enter the following:

fdisk -l

This will show you which hard drive you are using, typically /dev/sda1. Then type the following, replacing sda1 with whatever your drive is:

sudo mkdir /media/sda1
sudo mount /dev/sda1 /media/sda1
sudo chroot /media/sda1

This mounts your hard drive to the livecd and puts you in chroot. You can now do what I said at the beginning of this answer.

exit

Now reboot your original system and you should be ok.

6
  • 1
    He will need a live dvd session to do this ;)
    – Rinzwind
    Aug 12, 2015 at 7:54
  • I don't have a testing environment set up, but would commands run in the Alt+F2 box in this case? (Though I'd presume pkexecwould be a better choice over sudo so they can enter the password). This would be easier over using a live CD.
    – Dan
    Aug 12, 2015 at 8:10
  • sudo is fine, no? None of the commands above use a graphic environment. You might be on to something. However, since you don't have a testing environment and neither do I, I can't really incorporate this in the answer ;) Good lateral thinking though. Bravo. Aug 12, 2015 at 8:14
  • @SimonHoare I agree, this is why I haven't added it as an answer myself as well; With Alt+F2, if you run sudo, you won't be able to have a prompt to ask you for the password to actually run the command with root. Instead, with pkexec, it will show a GUI prompt for a password. (I'm not suggesting pkexec because the commands use a graphic environment, instead I'm using it because with Alt+F2, you can't see the "command line feedback"; not sure if I'm making any sense lol).
    – Dan
    Aug 12, 2015 at 8:26
  • 1
    Ok that should work, provided pkexec in requesting the password doesn't require user details in /home, which I can't see why it would. Aug 12, 2015 at 9:06

You must log in to answer this question.

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