搞砸了 ~/.bash_profile 中的 PATH,現在無法編輯它

搞砸了 ~/.bash_profile 中的 PATH,現在無法編輯它

實際上,我在安裝一些軟體時搞砸了$PATH變數。~/.bash_profile而不是使用

export PATH=$PATH:/some/other/path

我愚蠢地這樣做了

export PATH=~/some/other/path

所以,不,我不能使用任何命令。如果我嘗試ls,我會得到這個;

 $ ls
bash: ls: command not found...
Similar command is: 'lz'

我該如何編輯我的內容~/.bash_profile來解決這個混亂?我無法使用 vim 或 emacs。

答案1

/bin/nano ~/.bashrc

或者

/usr/bin/emacs ~/.bashrc

或者

/usr/bin/vim ~/.bashrc

答案2

只需使用 emacs 或 vim 的完整路徑即可。 IE。

/bin/vim .bash_profile

答案3

適用於 Anaconda 3

$ /usr/bin/vim ~/.bashrc

PATH=$PATH:$HOME/anaconda3/bin

然後Esc按鈕

:wq 

儲存並退出 vim 編輯器,然後輸入

$ export PATH=~/anaconda3/bin:$PATH

確認安裝的版本

$ conda --version

答案4

如果您不想使用vimemacs或者nano只需使用您最喜歡的編輯器並編輯bash_profile位於您的主目錄中的檔案。

atom ~/.bash_profile

或者

subl ~/.bash_profile 

然後在底部編輯你想要的任何內容。

相關內容