1

I accidentally ran the command chown -R MY_ACCOUNT / and now I can't start my computer anymore. It shows the Ubuntu logo, but gets stuck before showing the login prompt.

I've seen this question asked here before, and people have been recommended to reinstall Ubuntu with the option to keep all files.

However, when I try to reinstall from a USB, I am only given the option to install and delete all files, or to install a new Ubuntu 22.04 parallel to my previous Ubuntu 22.04. So I have the following questions:

  1. Can I run a suitable chown from a live version of Ubuntu so that I can log in again?

  2. If 1. is not possible, can I at least do something from the live version that allows me to reinstall Ubuntu and keep my files?

  3. If a new install is really necessary, is it safe to restore my files from the backup on my external drive, or are the changed ownerships stored in some files there, so that restoring will get me back to where I am now?

I'm grateful for any help.

1 Answers1

1
  1. Not really. There are methods and I had to do this twice myself where I used the permissions from another system to copy those over to the broken system but the end result was never really perfect; it always needed manual adjustment and that makes it very time consuming.

  2. Yes, you need to pick "something else", add the partitions, name and set the same filesystem as you have now and then -not- select "format". I used this method several times and it works very well. Just need to make sure you do it correctly as a mistake will be fatal so always make sure you have a backup when you do this.

If a new install is really necessary, is it safe to restore my files from the backup on my external drive,

Yes, but this yes is only valid for personal files.

or are the changed ownerships stored in some file there, so that restoring will get me back to where I am now?

No but it is very easy to restore permissions for personal files. Those are in their own directories outside of the system and all have the same permissions unless you have more than 1 user.

=== Do not do this on directories that are system related ===

Dirs:

find /dir -type d -print0 | xargs -0 chmod 0755

Files:

find /dir -type f -print0 | xargs -0 chmod 0644

where "/dir" is the location of your personal files for instance "/home/$USER/Desktop/" or any of the other directories in /home/$USER/. /dir can also be a partition if you have that. Also: this only applies to Linux filesystems like ext and not for NTFS, or FAT.

Rinzwind
  • 309,379