0

I mistakenly changed permission recursively, issuing the following command on many files, including /usr/bin/sudo:

chown -R $USER:$USER sudo

Now I want to reinstall my Ubuntu OS but I need to back up my files on my external hard disk from the TTY. How do I do that step by step?

I currently do not have access to a Ubuntu installation medium and I don't want to loose my files.

7
  • @AndreaLazzarotto I don't know what that is the only tool I have at my disposal is my external hard drive, Jun 6, 2016 at 15:54
  • If you still have an Ubuntu USB or live DVD (the one you used for installation), you could use that to do this. Jun 6, 2016 at 15:59
  • @JonasCz oh I don't have that Jun 6, 2016 at 16:02
  • @AndreaLazzarotto is that my only option because I don't have that on me and my major priority is backing up before reinstalling Jun 6, 2016 at 16:03
  • 1
    Not the only one, but surely the easiest one. I will provide an answer with the "complicated" option, nevertheless. Still, you need an installation disk or USB drive for reinstalling Ubuntu. You should borrow a computer from a friend or in a library and burn the disk or the USB drive in any case. BTW: you gave details in the comments, please also append them to your question. Comments may be cleaned up any time. Jun 6, 2016 at 16:05

1 Answer 1

1

I need to back up my files on my external hard disk from the TTY.

You can't do it precisely from the TTY because you destroyed your sudo ability and probably you won't be able to mount the external drive. However, you have two options:

  • booting in a root shell
  • using a live DVD or USB

Backup booting in a root shell

You cut yourself superuser powers, so you need to "hack" your own computer. As I explained in a slightly related answer:

Boot your PC while holding Ctrl+Shift, you should see the GRUB menu appear. While focusing on the first Ubuntu entry, press e to edit it.

You should see a line which ends with ro quiet splash --. Change this last part to:

rw verbose init=/bin/bash --

Don't touch the first part of the string, leave it the same as before. Now press Ctrl+X to boot. You should boot straight into a root shell.

Now you have root access and you can connect your external drive. After connecting it, wait a few seconds and do:

dmesg | tail

It will show a few lines where you can detect the device associated with the main partition of the external drive, probably /dev/sdb1. Create a mount point and mount the partition:

mount -o remount,rw /
mkdir -p /mnt/external
mount /dev/sdb1 /mnt/external

Now prepare an output directory and copy the files:

mkdir /mnt/external/RECOVERED
cp -v -r /home /mnt/external/RECOVERED/

Note: if your home directory is in a separate partition you might need to mount it before doing the above. In that case mount /home should suffice.

When it's done, assure the data is written on the drive completely and unmount the file system:

sync
umount /mnt/external

Disconnect the external drive now. Since you plan to reinstall, I won't discuss how to clean up and shut down the computer safely. Just long-press the hardware power button. ;)

Backup using a live DVD or USB

If you have access to a Ubuntu installation medium, do the following:

  • boot your computer using the live DVD or USB
  • connect the external hard drive
  • run sudo nautilus in the terminal
  • copy all the files you want in the external drive
  • safely disconnect the drive
  • re-install Ubuntu
7
  • I'm trying option one and it's telling me BOOTMGR is missing ? Jun 6, 2016 at 17:00
  • Okay for the second option all I need to do is download ubuntu on a separate system load into an empty flash and use it as a live USB for booting ? , With the error message showing how do I use the USB for booting ? Jun 6, 2016 at 17:39
  • @temiloluwaadesina «BOOTMGR is missing» then you are booting with another device inserted (probably a USB drive). You have to boot your hard drive as usual, just making sure that the GRUB menu shows up by pressing those keys. Jun 6, 2016 at 21:39
  • →okay, I'm already downloading ubuntu Os and Rufus to make my USB stick live, so you're saying once I've done that I insert the USB stick and hard drive, use ctrl + shift and press e or do I insert the USB stick use the try ubuntu option and run the sudo nautilus cmd to transfer my files and then install Ubuntu ? Jun 7, 2016 at 7:43
  • @temiloluwaadesina the choice is yours. I included both methods for completeness. Maybe the GUI approach is more user friendly, but honestly you can use both. Jun 7, 2016 at 10:12

You must log in to answer this question.

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