I was trying to remove python environment and I think I accidentally removed the one comes default with fedora and makes dnf command not available.
I did(not consecutively but I think those three commands are the relevant ones):
sudo rm /bin/python
sudo rm /usr/bin/python
sudo rm /bin/python3 /bin/python3.12 /bin/python-argcomplete-check-easy-install-script /bin/python-argcomplete-tcsh
Then I found that:
n349@fedora:~/Downloads$ sudo dnf upgrade
Place your right index finger on the fingerprint reader
^C[sudo] password for n349:
sudo: dnf: command not found
I tried to reinstall dnf, but it seems that dnf-4.19.0-1 is currently still installed on my machine and i cannot do it again.
~/Downloads$ dnf --version
bash: dnf: command not found...
Install package 'dnf' to provide command 'dnf'? [N/y] y
* Waiting in queue...
* Loading list of packages.... Failed to install packages: dnf-4.19.0-1.fc39.noarch is already installed
n349@fedora:~/Downloads$ ls -l /usr/bin/dnf
lrwxrwxrwx. 1 root root 19 Mar 11 01:37 /usr/bin/dnf -> /usr/bin/dnf-4.19.0
I am using fedora 39 upgraded using dnf from fedora 38 preinstalled on a thinkpad x1 carbon.
n349@fedora:~/Downloads$ uname -a
Linux fedora 6.7.7-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Mar 1 16:53:59 UTC 2024 x86_64 GNU/Linux
I searched online and didn't found a solution to this problem and hope someone could help me to restore the functionality of dnf.
I tried to reinstall the dependencies:
$ sudo rpm -ivh --force dnf-data-4.19.0-1.fc39.noarch.rpm \
dnf-automatic-4.19.0-1.fc39.noarch.rpm \
python3-dnf-4.19.0-1.fc39.noarch.rpm \
yum-4.19.0-1.fc39.noarch.rpm
sudo rpm -ivh --force dnf-4.19.0-1.fc39.noarch.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:dnf-data-4.19.0-1.fc39 ################################# [ 25%]
2:python3-dnf-4.19.0-1.fc39 ################################# [ 50%]
3:dnf-automatic-4.19.0-1.fc39 ################################# [ 75%]
4:yum-4.19.0-1.fc39 ################################# [100%]
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:dnf-4.19.0-1.fc39 ################################# [100%]
But it still does not work and the error messages change:
n349@fedora:~/Downloads$ dnf --version
bash: /usr/bin/dnf: cannot execute: required file not found