UbuntuはPATHを台無しにしました。

UbuntuはPATHを台無しにしました。

Goプログラミング言語の設定中に、LinuxでPATHを混乱させました。パスを指定しないと、どのコマンドも実行できません。

frede@frede-Lenovo-V110-15ISK:~$ ls
Command 'ls' is available in '/bin/ls'
The command could not be located because '/bin' is not included in the PATH environment variable.
ls: command not found
frede@frede-Lenovo-V110-15ISK:~$ echo $PATH
/home/frede/bin:/home/frede/.local/bin:PATH:/home/frede/go/bin

ただし、指定されたパスで実行できます。同様のスレッドを見てこの問題を解決しようとしましたが、私に合った解決策が見つかりませんでした。助けてください?

修正する

frede@frede-Lenovo-V110-15ISK:~$ grep 'PATH=' ~/.profile ~/.bashrc ~/.bash_profile /etc/profile
/home/frede/.profile:PATH="$HOME/bin:$HOME/.local/bin:$PATH"
/home/frede/.bashrc:export GOPATH=/home/frede/go
/home/frede/.bashrc:export PATH=PATH:/home/frede/go/bin
grep: /home/frede/.bash_profile: No such file or directory

ベストアンサー1

また覆う

あなた/etc/profileの道をどのように台無しにしたかはわかりませんが、ソーシングを介して/etc/profile状況を正常に戻すことができます。編集しない限り。だからこれを試してみてください:

. /etc/profile

正しいルート設定

bashを使用すると仮定すると、.bashrc(代わりに.profile)fileを使用してパスを設定できます。以下で見つけることができるものに似たものを使用できます/etc/profile

# set PATH so it includes your private Go bin folder if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/go/bin:$PATH"
fi

.profilebashを使用していない場合は、.bashの代わりに個人ファイルのPATHを上記のように調整してください.bashrc

最後に変更されたファイルをインポートします。

. ~/.bashrc   # or
. ~/.profile

(注:.profile共通ソース.bashrc- 詳細については参考資料を参照してください)

一部のファイルが誤ったPATH定義で汚染されている場合は、それらのファイルをクリーンアップする必要があります。あなたの質問についてTerdonのコメントに従ってください。

引用する

おすすめ記事