
RHEL 6.5를 비교적 새로 설치했고 소스에서 GCCC 4.9를 설치했습니다. GCC 4.9를 설치한 후 다음을 통해 배포판에서 제공되는 이전 GCC 버전을 제거했습니다.
sudo yum remove gcc
걸프 협력 협의회나타나다올바르게 설치되고 사용자 및 사용자에게 표시되지만 컴파일러가 필요한 명령을 root
실행하려고 하면 sudo
찾을 수 없습니다.
이것이 while 을 PATH
가리키지 않는 것 같지만 그 이유를 이해할 수 없습니다.g++
sudo
g++
다음 위치에 설치됨:
[john@haley boost_1_55_0]$ which g++
/usr/local/bin/g++
성공 하면 사용자로 버전을 얻습니다 root
.
[john@haley boost_1_55_0]$ g++ --version
g++ (GCC) 4.9.0
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[john@haley boost_1_55_0]$ sudo su -
root@haley /root # g++ --version
g++ (GCC) 4.9.0
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
그러나 sudo g++ --version
실패했습니다:
john@haley boost_1_55_0]$ sudo g++ --version
[sudo] password for john:
sudo: g++: command not found
[john@haley boost_1_55_0]$
확인 PATH
사항 sudo
:
[john@haley boost_1_55_0]$ sudo echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/home/john/bin:/usr/local/bin
^^^^^^^^^
g++
...위치가 실제로 경로에 있음 을 나타내는 것 같습니다 .
왜 실패하며 이 문제를 해결하려면 어떻게 해야 합니까?
댓글의 질문에 답해 주세요.
예, 다음 명시적 경로를 사용하여 실행할 수 있습니다 sudo
.
[john@haley boost_1_55_0]$ sudo /usr/local/bin/g++ --version
[sudo] password for john:
g++ (GCC) 4.9.0
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[john@haley boost_1_55_0]$
확인해보니 제가 뭔가 잘못했다는 걸 알게 되었습니다 sudo PATH
. 올바른 방법으로 수행하면 /usr/local/bin
실제로아니요sudo
나 여기 있어 PATH
:
[john@haley boost_1_55_0]$ sudo env | grep PATH
13:PATH=/sbin:/bin:/usr/sbin:/usr/bin
[john@haley boost_1_55_0]$
답변1
OP에 대한 의견을 통해 이 솔루션을 찾았지만 그것이 내가 원하는 것인지 잘 모르겠습니다.~해야 한다하다.
를 포함하도록 sudo visudo
실행하고 편집하여 이 작업을 수행 할 수 있습니다 .secure_path
/usr/local/bin
내 시스템에서 원래 줄은 다음과 같습니다.
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin
다음으로 변경하세요.
Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
"문제를 해결:
[john@haley boost_1_55_0]$ sudo g++ --version
g++ (GCC) 4.9.0
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[john@haley boost_1_55_0]$