0

I used rsync -aiiP to copy the /etc from my old laptop to the /etc of my new laptop. After locking the screen and trying to log back in, my password no longer works. I rebooted but it gets stuck on the loading screen and my new user account never appears, instead I am entered into emergency mode where I can use root on the command line to navigate the filesystem.

I think the problem could be that I replaced /etc/shadow and /etc/passwd on the new system with the ones from the old system. The user account on my old system and new system are different.

How do I get access to my user account again and what caused this problem?

I'm thinking of freshly installing fedora 37 on a different laptop and then copying /etc to the broken laptop using root in emergency mode, but I don't know if there's a better way.

8
  • 2
    There's quite a lot of files that you can't transfer between systems from /etc "just like that", including network configurations, configured mount points, mail settings, host SSH keys and config files for other packages, and a number of other things. The best option would be to restore from backup. Commented Jan 30, 2023 at 23:47
  • @Kusalananda thanks, I see. What exactly do you mean by restore from backup? Commented Jan 31, 2023 at 0:10
  • 1
    You've never should have done that. /etc is highly dependent on installed packages and different systems mustn't be synchronized unless you're 100% sure you know what you're doing. This answer could help you: unix.stackexchange.com/a/731966/260833 only instead of /var you should use /etc. Mounting var is not necessary of course. Commented Jan 31, 2023 at 0:55
  • @ArtemS.Tashkinov thanks. Can you write an answer please? I'm not sure how to use the answer you linked. I'm also not sure how to mount /etc, can you explain? Commented Jan 31, 2023 at 2:23
  • 1. Boot in recovery 2. chroot into your system 3. restorecon -rv /etc 4. reboot Commented Jan 31, 2023 at 2:53

1 Answer 1

0

The best way to go is to reinstall your new laptop from scratch, unless you have backed up /etc, in which case you can restore it.

The /etc directory contains machine-specific configuration files for disks, network, services, and all installed packages. One cannot simply copy it from one machine into another and expect the machine to work (or ever to boot into an usable mode).

I think the problem could be that I replaced /etc/shadow and /etc/passwd on the new system with the ones from the old system. The user account on my old system and new system are different.

Correct, this is why you cannot log in. Besides, these files also contain UIDs, so replacing the files also messed up file ownership.

3
  • Thanks. I was under the impression that /etc contained application data files, is this wrong? Also what if I copy the /etc from another laptop from the same manufacturer but a newer model, will it work? Commented Feb 1, 2023 at 18:32
  • I don't know what you mean exactly by application data files, but it contains configuration files for all programs and services. And no, copying and pasting /etc from one machine to another won't work in 99.9% of cases. You need to find another way to do what you want. Commented Feb 2, 2023 at 9:21
  • won't work in 99.9% of cases modern Linux'es have very few HW specific bits in /etc. The most important is /etc/fstab which can be trivially fixed. Almost everything else is configured automatically at runtime. Commented Feb 2, 2023 at 9:36

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.