I was changing some settings when I came across the user id in the accounts section. For some inexplicable reason I thought it meant my network User ID, ie what I would identify to a router with. No idea why I thought this. Anyway.
I changed my User ID.
I am still logged in.
I cannot open any programs, including terminal, to try and change it back.
Currently open programs include: Finder (downloads folder), Firefox, Sublime and Outlook.
Currently I'm afraid to reboot. However I do have access to several other Windows/Linux machines and lots of flash drives if I need to download/install/prep a live boot/etc.
I need to figure out how to change my User ID back.
Solution I'm currently trying to work:
I have a file explorer open. I have sublime open.
If I can find where OS X stores the User ID, I might be able to navigate to it and change it back to whatever it's supposed to be (501 I think?).
If anyone else has any ideas or solutions, I am all ears. In any case, I will post an update when it's solved one way or the other.
Edit: Update (since I said I would). The problem has been solved, Klanomath's solution below worked perfectly first time through. Thank you!
Best Answer
Reboot your Mac to Single User Mode (cmdS while booting) and enter at the prompt:
Launch opendirectoryd:
You will get some error messages - repeatedly.
Then enter (replacing username with your real user name):
You should get something like 272 (if you changed it to 272 accidentally)
Now change it back to 501 again and check the result:
which should yield the original 501.
Then enter
exit
and boot to your GUI or better: reboot your Mac immediately withshutdown -r now
to avoid errors based on the premature launch of opendirectoryd. I got some kextunload errors trying to shut down/reboot after booting directly to the GUI.