질문
입력하다
source ~/.bashrc
다음 오류가 보고되었습니다.
Command 'lesspipe' is available in the following places
* /bin/lesspipe
* /usr/bin/lesspipe
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
lesspipe: command not found
Command 'dircolors' is available in '/usr/bin/dircolors'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
dircolors: command not found
해결책
명령줄에 입력
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
이 방법을 사용하면 이 명령줄에서 일반적으로 bin 아래의 명령 (예: source, ls 등) 을 사용할 수 있습니다.
영구 솔루션
먼저 위에서 언급한 명령줄에서 내보내기를 실행합니다.
그런 다음 사용자 디렉토리의 .bashrc 파일을 수정하고 실수한 경우 다시 변경하고 무엇이 잘못되었는지 모르는 경우 마지막 변경을 취소하십시오.
vim ~/.bashrc
export ... $PATH ... 의 진술이 올바른지 관찰하는 데 집중하십시오.
예를 들어, 이전 실수는 cuda 도구를 구성할 때 PATH를 추가하는 것을 잊은 것입니다.
내 .bashrc는 잘못되었을 때 다음과 같이 보입니다.
...
export PATH=$PATH:/home/zhoug/cuda-10.2/bin/
export PATH=/home/zhoug/cuda-10.2/lib64/
보시다시피 4행 중간에 $PATH를 추가하지 않아서 오류가 발생했습니다.
이전에 말했듯이 다음으로 변경하십시오.
export PATH=$PATH:/home/zhoug/cuda-10.2/bin/
export PATH=$PATH:/home/zhoug/cuda-10.2/lib64/
이 줄을 삭제하고 마지막으로 원래 줄로 변경하십시오.
...
# export PATH=$PATH:/home/zhoug/cuda-10.2/bin/
# export PATH=/home/zhoug/cuda-10.2/lib64/
그런 다음 수정된 .bashrc 를 소싱합니다 .
source ~/.bashrc
시스템 명령이 정상으로 돌아갑니다.
이유
이것을 보면 .bashrc 및 소스를 업데이트한 후 알아야 합니다.
vim ~/.bashrc
source ~/.bashrc
시스템이 내보내기의 경로 PATH를 구문 분석할 때 올바른 위치를 확인하지 못했습니다.
그 99.99%는 .bashrc 수정을 수정하지 않았기 때문일 수 있습니다.
이 경우 시스템 명령을 실행하려는 경우 예를 들어 ls를 원하는 경우에만 수행할 수 있습니다.
/usr/bin/ls
따라서 .bashrc 파일로 다시 수정해야 하며 다음과 같이 vim을 사용해야 합니다.
/usr/bin/vim ~/.bashrc
그러나 가장 어려운 문제는 이러한 방식으로 출처를 밝히고 싶을 때 처음에 말한 오류를 보고해야 한다는 것입니다.
/usr/bin/source
Command 'lesspipe' is available in the following places
* /bin/lesspipe
* /usr/bin/lesspipe
The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable.
lesspipe: command not found
Command 'dircolors' is available in '/usr/bin/dircolors'
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
dircolors: command not found
가능한 이유는 source가 결합된 명령이고 이 결합된 명령이 실행될 때 lesspipe 및 dircolors를 호출할 때 여전히 올바른 PATH 경로가 필요하기 때문입니다.
내가 언급한 해결 방법은 이 문제에 대해 잘 작동합니다.