All user accounts on iMac running OSX 10.10.5 vanished on login screen So a few nights, ago our iMac (OSX 10.10.5) started to run slowly, so I figured that all 4 family members have active logins – so one by one, I logged everyone out then rebooted the machine. 

When it started to reboot, the iMac entered the safe mode loading process and never completely rebooted; it just hangs there around 50%.

I managed to get the iMac to boot up to at least the login screen, but all four users are gone and only the Guest option exists. 

None of the usernames and passwords for any family member work. I've tried resetting passwords via Terminal and also to activate and use the root single user, but nothing works. When I run ls /Users, I can still see all the folders of the users.

I'm at a loss as to where to start. I'd happily rebuild the OS from scratch if I could backup the disk from Terminal in some way.

Any suggestions on restoring the user accounts or backing up from Terminal?
Backup first, via a second Mac if possible:

If you have a second Mac, you can put the troublesome one in Target Disk Mode:


During startup, hold the "T" key.  
Connect the two devices with Thunderbolt cable, or Firewire
The Target Mode device should mount like an external disk on your second Mac.
Make your backup.    


After you have a backup (or choose not to make one)...

Try to create a new (admin) user:


Boot back into Single-User Mode (CMD-S) during startup.
Mount the drive: /sbin/mount -uw /
Remove this file: rm /var/db/.AppleSetupDone
Restart the computer: reboot 
Go through Setup Assistant


Once you have a new Admin user, see what you can do with the accounts.