2

I did a silly thing by renaming the /etc folder. I was asked for the admin password to change the folder's name. But it's not possible to rename it back to /etc. As if my password was wrong.

I assume the association between password and username is stored in this folder. I can still change the admin's password in the system settings. But I can't login to the advanced options that expect admin rights.

Unfortunately I don't have a recent time machine backup to replace the /etc folder.

Now I'm concerned about rebooting my Mac, as I'm not sure if I'll be able to login again.

How do I fix this issue?

6
  • Where did you change it? Did you do it from the alias or inside /private/ ? I'd check it hasn't simply made a new folder or alias itself, that you'd need to clear first.
    – Tetsujin
    Apr 10, 2019 at 11:54
  • Can you still open Terminal and run sudo ls -ld /etc /private/etc? If yes, please add the result to your question.
    – nohillside
    Apr 10, 2019 at 12:01
  • @Tetsujin I changed the folder's name from the favorites list in the finder by right clicking it and rename. I thought I was just changing the favorite's name and not the folder's name itself. The "private" folder contains only 4 folders now. "hosts etc" which is the old "etc", "tftpboot", "tmp" and "var".
    – w2m
    Apr 10, 2019 at 12:18
  • 1
    @nohiliside when opening the terminal I can't log in anymore
    – w2m
    Apr 10, 2019 at 12:21
  • Could this work to create a new admin account and rename the folder? apple.stackexchange.com/a/323501
    – w2m
    Apr 10, 2019 at 13:27

1 Answer 1

7

I would try booting in single user mode (holding the Apple and S keys while rebooting), mount the hard drive (mount -uw /) and then check and rename etc as needed (there should be an alias at the root of the HD named etc pointing to /private/etc).

I would do an ls -al / and a ls -al /etc to see which directory name was changed and then fix the bad directory name with mv. Checking each directory would be important regardless of which fix you used (the one above or below).

If single user boot doesn't work, I would “Target Disk Mode” using another Mac (turn off the bad Mac, connect the two Macs with Firewire or Thunderbolt cable, start the bad Mac while holding down the T key), this will mount the bad Mac's drive as an external drive on the other Mac and you should be able to use the command line to change the name there.

Or, as someone else suggested, booting from the recovery partition.

Last resort is to reinstall the system, it should allow you to do that without wiping the drive.

11
  • 1
    @w2m And while in target disk mode, take the opportunity to back up your files...
    – Solar Mike
    Apr 10, 2019 at 15:52
  • 1
    With /etc missing, booting into single-user mode will fail. There's no hope of that working.
    – user101978
    Apr 10, 2019 at 20:32
  • Sounds like the "Target Disk Mode" is my last option without wiping the drive. Reinstalling will probably ask for the login. See section 3.2. support.apple.com/en-us/HT204904 Tomorrow I'll buy an external drive and run a time machine backup just in case I'll have to erase the drive. Owly will have to keep my Mac running until then :)
    – w2m
    Apr 10, 2019 at 22:04
  • 1
    You should be able to boot into recovery mode, command + r at boot. Then you into terminal and change the name. Be sure to navigate the the correct drive. Apr 10, 2019 at 23:38
  • Update: the time machine backup was successful. But as I expected I couldn't reboot the system. I am able to start pressing command r and command s. I tried to rename the folder using the following command : mv '/private/hosts etc' '/private/etc'. But then I receive the terminal notification that the folder doesn't exist: i.ibb.co/xMjgjQt/20190412-180421.jpg. Would appreciate if anyone could help me out.
    – w2m
    Apr 12, 2019 at 16:42

You must log in to answer this question.

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