Wie behebt man den Fehler „Der Befehl konnte nicht gefunden werden, da ‚/bin:/usr/bin‘ nicht in der Umgebungsvariable PATH enthalten ist“?

Wie behebt man den Fehler „Der Befehl konnte nicht gefunden werden, da ‚/bin:/usr/bin‘ nicht in der Umgebungsvariable PATH enthalten ist“?

Ich habe Ubuntu 20.04.3 LTS und Anaconda3 installiert, musste Anaconda3 jedoch deinstallieren, da ein Problem auftrat. Ich habe es mit diesem Befehl als Root und aus dem /home/userVerzeichnis entfernt:

# rm -f anaconda3

Danach hatte ich das folgende Problem:

$ sudo -s
# ls
Command 'ls' is available in the following places
 * /bin/ls
 * /usr/bin/ls
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
ls: command not found

Hier sind die letzten Zeilen meines .bashrc:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/thilipkumar/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/thilipkumar/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/thilipkumar/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/thilipkumar/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

Und hier sind die Ausgaben echo pathfür den normalen Benutzer und Root:

~$ echo $PATH
/home/thilipkumar/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
~$ sudo -s
/home/thilipkumar# echo $PATH
/root/anaconda3/

Kann mir jemand einen Vorschlag machen, was ich als nächstes tun soll?

Antwort1

Überprüfen Sie die /root/.profileund /root/.bashrcDateien des Root-Benutzers, um zu korrigieren, wenn der Pfad falsch festgelegt ist.

Sie können diese Dateien auch auf die Standardeinstellungen zurücksetzen, indem Sie die jeweiligen Dateien nach /etc/skelkopieren /root.

Antwort2

Bitte ersetzen Sie den Dateipfad durch:

export PATH=$PATH:/usr/bin:/bin

Dieser Befehl ersetzt den Pfad zum Original dauerhaft. Hier ist ein Beispiel:

/$ nano .bashrc
Command 'nano' is available in the following places
 * /bin/nano
 * /usr/bin/nano
The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable.
nano: command not found
/$ export PATH=$PATH:/usr/bin:/bin
/$ ls
backups  bin  boot  cdrom  dev  etc  home  lib  lib32  lib64  libx32  lost+found
madhu  media  mnt  opt  proc  root  run  sbin  snap  srv  swapfile  sys
tmp  usr  var

verwandte Informationen