無法找到該指令

無法找到該指令

每當我打開終端機視窗時我都會發現這一點。有人能找到永久解決這個問題的方法嗎?

bash: /usr/lib/jvm/jdk-16.0.1: Is a directory
Command 'dircolors' is available in the following places
 * /bin/dircolors
 * /usr/bin/dircolors

The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable.
dircolors: command not found
Command 'dirname' is available in the following places
 * /bin/dirname
 * /usr/bin/dirname

The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
dirname: command not found
Command 'dirname' is available in the following places
 * /bin/dirname
 * /usr/bin/dirname

The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
dirname: command not found

我使用以下命令用於臨時目的:

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

答案1

有兩種方法可以解決此問題:

  • 將 /bin 和 /usr/bin 放回您的路徑中,以便 shell 初始化檔案中的命令可以正常運行
  • 編輯您的 shell 初始化檔案以刪除不在您的路徑中的命令,或者如果缺少所需的路徑元件則跳過執行它們

shell 初始化檔案是主目錄中的隱藏檔案。這些文件的名稱取決於您使用的 shell。例如,如果您使用的是 bash,這些檔案將包括 .bashrc、.bash_profile 和 .profile

但是,如果您向這些文件添加錯誤,編輯這些文件可能會導致您的帳戶無法正常運作。最好確保您的路徑正確,或者如果您確實需要暫時從路徑中刪除 /bin 或 /usr/bin,請忽略由此導致的錯誤。

相關內容