Permission issue in dnf history after upgrade to 9.7

I have in place a check to spot issues in dnf transactions. This check runs, as a regular user the command:

dnf history last

and starts to grep the output.

After the upgrade to 9.7 I started to receive an error

Error: SQLite error on “/var/lib/dnf/history.sqlite”: Executing an SQL statement failed: attempt to write a readonly database

but if i lauch the same command with sudo, not only works correctly but fixes also the original command that starts to work again.

What’s happening?

Thanks to everyone

Probably because the normal user doesn’t have permissions on the sqlite database. Easy enough to check by going to the directory and checking who is the owner of the files, and who the group owner is.

Since the command works with sudo or as root user, that would confirm that it is due to lack of permissions. And thus, normal situation.

Hi, thanks for the response. To be honest things are a little different.

Before upgrading to Rocky 9.7:

dnf history last - works from normal user

After upgrating to Rocky 9.7

dnf history last - return sqlite error

sudo dnf history last - works

dnf history last - works again after attempt with sudo as normal user.

For the record, I can dnf history last as regular user on AlmaLinux 9.7.
All I have is read for that sqlite file:

$ ls -la /var/lib/dnf
total 8596
drwxr-xr-x.  4 root root    4096 Dec  5 14:50 .
drwxr-xr-x. 57 root root    4096 Oct  5 23:44 ..
-rw-r--r--.  1 root root 2457600 Dec  5 14:45 history.sqlite
-rw-r--r--.  1 root root   32768 Dec  5 14:52 history.sqlite-shm
-rw-r--r--.  1 root root 6291272 Dec  5 14:50 history.sqlite-wal
drwxr-xr-x.  2 root root    4096 Apr 30  2025 modulefailsafe
drwxr-xr-x. 15 root root    4096 Jul 15  2024 repos

I avoid running dnf as myself since that creates additional cached files. Hence I did not know whether regular user can dnf history. I do know that dnf refuses some operations, unless user is root.


When launched with sudo it is user root that runs the command (unless you have custom sudoers ruleset).

I just moved from 9.6 to 9.7, and I can run
dnf history last
as standard user
no errors