无法找到该命令

无法找到该命令

每当我打开终端窗口时我都会发现这一点。有人能找到永久解决这个问题的方法吗?

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,请忽略由此导致的错误。

相关内容