Dnf not working in version 10

/usr/bin has a dnf but getting message file or directory not found

sudo: unable to execute /bin/dnf: No such file or directory

/bin is a symlink to /usr/bin - Have you made any configuration changes, path changes, or customizations to your system?

dr-xr-xr-x.   2 root root    6 Apr  1  2025 afs
lrwxrwxrwx.   1 root root    7 Apr  1  2025 bin -> usr/bin
dr-xr-xr-x.   7 root root 4096 Oct  4 00:45 boot
drwxr-xr-x.  18 root root 3800 Oct  4 02:57 dev
drwxr-xr-x. 129 root root 8192 Oct  4 03:45 etc
drwxr-xr-x.   7 root root   73 Oct  4 02:16 home
lrwxrwxrwx.   1 root root    7 Apr  1  2025 lib -> usr/lib
lrwxrwxrwx.   1 root root    9 Apr  1  2025 lib64 -> usr/lib64
drwxr-xr-x.   2 root root    6 Apr  1  2025 media
drwxr-xr-x.   2 root root    6 Apr  1  2025 mnt
drwxr-xr-x.   2 root root    6 Apr  1  2025 opt
dr-xr-xr-x. 450 root root    0 Dec 31  1969 proc
dr-xr-x---.   8 root root 4096 Oct  4 02:31 root
drwxr-xr-x.  54 root root 1580 Oct  4 02:54 run
lrwxrwxrwx.   1 root root    8 Apr  1  2025 sbin -> usr/sbin
drwxr-xr-x.   2 root root    6 Apr  1  2025 srv
dr-xr-xr-x.  12 root root    0 Jun  2 17:00 sys
drwxrwxrwt.  16 root root 4096 Oct  4 12:41 tmp
drwxr-xr-x.  12 root root  144 Oct  3 22:26 usr
drwxr-xr-x.  21 root root  288 Oct  3 22:53 var

Does yum work?

Could you also show the output of:

ls -l /bin/dnf /usr/bin/dnf
ls -l /bin/yum /usr/bin/yum
yum --version

python 3.19 installed, yum also not working.dnf soft link is there but command is not executed

imtiaz@localhost:~$ ls -l /bin/yum /usr/bin/yum
lrwxrwxrwx. 1 root root 5 May 19 05:00 /bin/yum → dnf-3
lrwxrwxrwx. 1 root root 5 May 19 05:00 /usr/bin/yum → dnf-3
imtiaz@localhost:~$ ls -l /bin/dnf /usr/bin/dnf
lrwxrwxrwx. 1 root root 5 May 19 05:00 /bin/dnf → dnf-3
lrwxrwxrwx. 1 root root 5 May 19 05:00 /usr/bin/dnf → dnf-3
imtiaz@localhost:~$ yum --version
bash: /usr/bin/yum: cannot execute: required file not found
imtiaz@localhost:~$

yum not working like dnf

First, the error one would get when symlink does not point to a file (is a dangling link):

$ touch foo
$ chmod +x foo
$ ln -s foo bar
$ rm foo
$ ./bar
bash: ./bar: No such file or directory

Where is that “dnf-3” and what does it use?

$ readlink -f /bin/yum
/usr/bin/dnf-3

$ head -1 /usr/bin/dnf-3
#! /usr/bin/python3 -s

$ readlink -f /usr/bin/python3
/usr/bin/python3.12

A Python script that requires python3.12.

How? (The 3.19 is in far future.)

try this

ls -l /usr/bin | grep dnf

the output must be like this:

dnf-3 should exist in any case

what should I d now?

still same issue

sudo: unable to execute /bin/dnf: No such file or directory

On my AlmaLinux 10 system, the paths look like this:

[root@alma10 ~]# readlink -f /usr/bin/python3
/usr/bin/python3.12

[root@alma10 ~]# readlink -f /usr/bin/yum
/usr/bin/dnf-3

[root@alma10 ~]# readlink -f /usr/bin/dnf-3
/usr/bin/dnf-3

[root@alma10 ~]# /usr/bin/python3 --version
Python 3.12.14

So I suspect /usr/bin/python3 may have been changed when Python 3.19 was installed, and that could be why dnf can no longer be executed.

Could you check:

readlink -f /usr/bin/python3
/usr/bin/python3 --version
head -1 /usr/bin/dnf-3

If /usr/bin/python3 no longer points to the distribution-provided Python, that may explain the problem.

$ readlink -f /usr/bin/python3
/usr/local/bin/python3.12
imtiaz@localhost:~$ /usr/bin.python3 --version
bash: /usr/bin.python3: No such file or directory
imtiaz@localhost:~$ /usr/bin/python3 --version
bash: /usr/bin/python3: No such file or directory
imtiaz@localhost:~$ head -1 /usr/bin/dnf-3
#! /usr/bin/python3 -s
imtiaz@localhost:~$

here is output, please let me know to fix it

unable to fix the issue till now

Since /usr/bin/dnf exists but cannot be executed, the issue may be related to a missing Python interpreter specified in the DNF script’s shebang.

Could you please provide the output of the following commands?

head -n 1 /usr/bin/dnf
head -n 1 /usr/bin/dnf-3
ls -l /usr/bin/python3*
readlink -f /usr/bin/python3
/usr/bin/python3 --version
rpm -V dnf python3-dnf python3

AlmaLinux 10 uses Python 3.12 for DNF 4.

If the interpreter specified in the shebang is missing, that could explain the “No such file or directory” error even though the DNF executable exists.

Please share the results so we can identify the cause before attempting any repairs.

imtiaz@localhost:~$ head -n 1 /usr/bin/dnf
#! /usr/bin/python3 -s
imtiaz@localhost:~$ head -n 1 /usr/bin/dnf-3
#! /usr/bin/python3 -s
imtiaz@localhost:~$ ls -l /usr/bin/python3*
lrwxrwxrwx. 1 root root 25 Sep 10 16:48 /usr/bin/python3 → /usr/local/bin/python3.12
-rwxr-xr-x. 1 root root 15800 Aug 13 05:00 /usr/bin/python3.12
imtiaz@localhost:~$ readlink -f /usr/bin/python3
/usr/local/bin/python3.12
imtiaz@localhost:~$ /usr/bin/python3 --version
bash: /usr/bin/python3: No such file or directory
imtiaz@localhost:~$ rpm -V dnf python3-dnf python3
…U… /usr/bin/dnf-3
…L… /usr/bin/python3
imtiaz@localhost:~$

At this point, it is difficult to determine the exact cause without checking the actual DNF executable and Python interpreter.

Could you please provide the output of these four commands?

ls -l /usr/bin/dnf-3
head -1 /usr/bin/dnf-3
ls -l /usr/bin/python3*
readlink -f /usr/bin/python3

If the default Python interpreter has been replaced or removed, that could explain why both dnf and yum fail.

If the DNF executable or required Python interpreter is missing or damaged, recovery may require reinstalling the affected RPM packages from rescue mode.

If we cannot identify the cause or recover the damaged components, reinstalling AlmaLinux 10 may be the most practical solution.

Based on what I’m seeing, it would be better to rebuild the system and start over. I personally wouldn’t be able to trust a system in this state, even if I did manage to get python (via dnf) to start working again.

It’s not entirely clear what was done to this system and any full explanation of what was actually installed or done to the system (customizations) wasn’t provided (python 3.19 doesn’t exist, python 3.12 is the default, so what was actually done on this system?)

If the system is reinstalled and the customizations are done again that causes this issue, that’s when we need to know what exactly is being done to get to this point.

Both commands do show that file /usr/bin/python3 is a symbolic link that points to file /usr/local/bin/python3.12 and not to file /usr/bin/python3.12 as one would expect.

The first command does show that file /usr/bin/python3.12 does exist.

That result does most likely mean that file /usr/local/bin/python3.12 does not exist.
One could obviously verify that conclusion with:

ls -l /usr/local/bin/python3.12

(which either lists something or says that no such file exists)


The /usr/bin/python3.12 is a file. It could be real Python. One can try:

/usr/bin/python3.12 --version

If that behaves like Python, then one could replace the bad symlink:

rm /usr/bin/python3
ln -s /usr/bin/python3.12 /usr/bin/python3

I do agree with others that a full reinstall could be easier and safer.

hi, dnf working now - removing soft link helped. surprise to know how simple it was when issue is addressed by Genius. Bravo- Thanks all who contributed and helped me come out this quirk