Bash는 $PATH에서 스크립트를 찾을 수 없습니다.

Bash는 $PATH에서 스크립트를 찾을 수 없습니다.

새로운 Ubuntu 16.04 Minimal 시스템을 설정하는 중인데 이상한 문제가 발생했습니다. 을 추가한 후에도 적어도 $HOME/bin.$PATHbashroot

여러 번 로그아웃하고 컴퓨터를 다시 시작한 적도 한 번 있었습니다. 경로는 /etc/profile.d: 의 스크립트 줄에 의해 설정됩니다 export PATH="$PATH:$HOME/bin".

root@Pioneer ~ # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/root/bin
root@Pioneer ~ # ls -la /root/bin
total 36
drwxr-xr-x 2 root root 4096 Feb  6 16:04 .
drwx------ 8 root root 4096 Feb  6 16:03 ..
-rwxr-xr-x 1 root root  174 Jan  5  2017 newuser
-rwxr-xr-x 1 root root  236 Nov  3  2015 own
-rwxr-xr-x 1 root root   87 May  6  2017 re-dns
-rwxr-xr-x 1 root root   57 May 10  2016 re-ftp
-rwxr-xr-x 1 root root   89 Oct 20  2015 re-mail
-rwxr-xr-x 1 root root   42 Oct 19  2015 re-smb
-rwxr-xr-x 1 root root   65 Oct 19  2015 re-web
root@Pioneer ~ # newuser
-bash: newuser: command not found

/root/bin/newuser에서와 같이 유효합니다 cd /root/bin && ./newuser.

이름 뒤에 공백이 없습니다.

# ls -lb /root/bin/newuser
-rwxr-xr-x 1 root root 174 Jan 5 2017 newuser

Root의 집은 실제로 다음과 같습니다 /root.

# getent passwd root
getent: root:x:0:0:root:/root:/bin/bash 

답변1

감사해요테든팁을 드리자면, 를 사용하여 strace -e stat bash -c "newuser" 2>&1 | grep /root/bin구성 파일 스크립트의 닫는 따옴표 앞에 보이지 않는 캐리지 리턴이 끼어 실제 경로를 /root/bin\r삭제하고 다시 입력한 것을 발견했습니다. 이제 작동합니다.

관련 정보