Today, I had a very annoying problem that I managed to fix. It's a couple of hours of my life that I won't get back, and I found very little online to help me.
So, to help anyone else with the same problem, here's the problem and the solution.
For what it's worth, this is with Fedora 39, KDE Plasma spin. But I honestly suspect that makes little difference. Other distros (Debian, Ubuntu, etc.) are probably just the same.
What happened: An innocent power cut?
Our power tripped. My computer is connected to a UPS, which shut the computer down when the battery drained too low. I turned the power back on, and brought the computer back up. But I couldn't log in.
I tried all the obvious things. Did I have capslock on? (No). Type the password really slowly, checking every key. (No joy).
My next trick was to press Ctrl+Alt+F3 to enter TTY3, and try a terminal login. I was able to confirm I was entering the correct password. If you type in the password wrongly, you get "Login incorrect". If you type it in correctly, you still can't log in, but you get a different error:
Fedora Linux 39 (KDE Plasma)
Kernel 6.6.14-200.fc39-.x86_64 on an x86_64 (tty3)
mypc login: james
mypc login: james
TL;DR: It was a marker file placed there by my UPS.
Digging around to find the problem
Searching the internet for login problems where the error is "POWER FAILURE" led me nowhere.
So I made a Fedora Live USB and booted into that. I did other things that were red herrings (ran fsck on every disk partition I have in the computer) and was able to mount the root file system of the computer. (Remember, in a Live USB, you need sudo to make any changes to the physical hard drives in the computer to prevent accidental alterations.)
sudo mount /dev/sdc2 /mnt
That meant I could search my logs, and I found this
sudo grep POWER /mnt/var/log/messages
Feb 8 07:47:33 mypc sddm: Authentication error: SDDM::Auth::ERROR_AUTHENTICATION "POWER FAILURE\n"
Feb 8 07:47:43 mypc sddm: Authentication error: SDDM::Auth::ERROR_AUTHENTICATION "POWER FAILURE\n"
Feb 8 07:47:52 mypc sddm: Authentication error: SDDM::Auth::ERROR_AUTHENTICATION "POWER FAILURE\n"
Armed with the actual error message, I was able to search the internet more exactly. That led me to this page on the Fedora forums. There was only that one page on the entire internet. That's why I'm writing this up: It's highly like there are more than two of us who encounter this problem, so I want to make it easier for people to search and find the answer.
The user who was asking for help there figured out the problem himself:
Nevermind...figured it out.
apcupsd created a nologin file presumably to prevent new logins during the shutdown process. That should have been removed at some point but when the power came back up, there were a couple of "hiccups" where the power went out and came back in quick succession before going down again for a bit. I'm guessing that those hiccups somehow prevented apcupsd from removing the nologin file.
Solving the problem
I now knew I could solve this. Thanks, dciarnie, whoever you are.
Checking the man file for apcupsd.conf told me that the default location for the nologin marker file is
/var/run. I checked in my live USB environment
sudo ls /mnt/var/run -l
and it was empty.
So I found my apcupsd.conf file at
/etc/apcupsd/apcupsd.conf and checked it (again, remember, I'm doing all this in my live USB environment).
sudo grep -i login /mnt/etc/apcupsd/apcupsd.conf
# NOLOGINDIR <path to nologin directory>
# Directory in which to write the nologin file. The existence
# of this flag file tells the OS to disallow new logins.
Sure enough, there was a file named
/etc/nologin. The contents of that file? You guessed it:
sudo cat /mnt/etc/nologin
Remove the file
sudo rm /etc/nologin
Reboot. And away we go.