Hello, whenever I install Fedora I get the following error: “useradd: failed to reset the lastlog entry of UID 986 (or any other UID): No such file or directory”, but the file does exist. A temporary solution I found was to delete the lastlog file and recreate it with the original permissions and group of that file. It works, but then the same issue happens again. When I install a program or something that tries to use it, it happens again. I’ve reinstalled Fedora and the same thing keeps happening. I don’t understand what it could be. I did a minimal installation using Netinstall without a graphical environment. But it doesn’t matter how I install, it always happens. Do you know how I can fix it?
I have not seen that error, but I would guess it may be either an error in the script that causes that or an selinux context error where the update is blocked by selinux.
The problem should be seen by using journalctl and viewing the entries around the time where that installation / upgrade was being performed.
You do not tell us what hardware is in use nor what version or spin of fedora is being installed so we have no way to test and try to replicate the same results.
It may help us if you provide hardware details (e.g., the output from inxi -Fzxx
as pre-formatted text), which may help others with similar hardware and issues find thsi topic with a web search.
Error when creating a user on Fedora 40 is a similar report without a solution.
-
Are you using the install default filesystems (BTRFS subvolumes for root and home)?
-
Did you install any additional software after the minimal netinstall?
-
What do you get for
lastlog -t <N>
, where N is bigger than the number of days since the install?
Check that the “original permissions and group” are correct.
% ls -ld /var/log ; ls -l /var/log/lastlog
drwxr-xr-x. 1 root root 1264 Sep 17 15:38 /var/log
-rw-rw-r--. 1 root utmp 292876 Sep 16 17:32 /var/log/lastlog
If yours are the same, you can look for additional error messages with journalctl
using search terms like usradd
, ADD_USER
, and lastlog
.
What does ls /var/log/lastlog
show? Is the file there at all?
Note the difference in context between the directory and lastlog.
# ls -ldZ /var/log /var/log/lastlog
drwxr-xr-x. 28 root root system_u:object_r:var_log_t:s0 4096 Sep 17 13:15 /var/log
-rw-rw-r--. 1 root utmp system_u:object_r:lastlog_t:s0 292292 Sep 17 13:11 /var/log/lastlog
This is why I mentioned selinux.
2313559 – useradd returns an error message when creating system users
BTW, SELinux is trivial to rule out with permissive mode.
Thank you for passing me the information. I was going crazy trying to figure out what was happening, but I suspected it wasn’t a problem with my computer because I saw a YouTuber showing something on Fedora 40 and he was experiencing the same issue, but he didn’t notice it. Does this affect my system in any way or what could happen while they fix it? Should I disable SELinux? Thanks!
IMO, disabling SELinux long-term would be worse than missing a few lastlog entries. (lastlog just tracks who has signed in on your system and when. If you don’t know what it is or view it from time to time, then it’s not all that important.)
Edit: Apparently that error message is a false negative – useradd actually is completing successfully: useradd reports spurious warning "failed to reset the lastlog entry" · Issue #1072 · shadow-maint/shadow · GitHub