![Ubuntu에서 다른 사용자로 명령을 실행하는 데 문제가 있습니다.](https://linux55.com/image/96977/Ubuntu%EC%97%90%EC%84%9C%20%EB%8B%A4%EB%A5%B8%20%EC%82%AC%EC%9A%A9%EC%9E%90%EB%A1%9C%20%EB%AA%85%EB%A0%B9%EC%9D%84%20%EC%8B%A4%ED%96%89%ED%95%98%EB%8A%94%20%EB%8D%B0%20%EB%AC%B8%EC%A0%9C%EA%B0%80%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
우분투 14.04를 사용하고 있습니다. 루트로 로그인한 상태에서 다른 명령(postgres)으로 명령을 실행해 보았습니다. 그러나 실패했다
root@remotebox:/home/rails/myproject# su - postgres 'pg_upgradecluster 9.3 main'
-su: pg_upgradecluster 9.3 main: No such file or directory
내가 뭘 잘못했나요?
답변1
'pg_upgradecluster 9.3 main'
postgres 사용자의 기본 쉘에 전달하려고 합니다 . postgres 사용자 구성에 따라 이는 'pg_upgradecluster 9.3 main'
postgres PATH에서 파일을 실행하는 것을 의미할 수 있으며, 이것이 "해당 파일 또는 디렉터리 없음" 오류가 발생하는 이유입니다.
인수를 명령(-c)으로 전달해 보세요.
su - postgres -c 'pg_upgradecluster 9.3 main'
쉘로서:
su - postgres -s /path/to/pg_upgradecluster -- 9.3 main
또는 명시적으로 셸을 선택합니다.
su - postgres -s /bin/bash -- -c 'pg_upgradecluster 9.3 main'