Ubuntu에서 다른 사용자로 명령을 실행하는 데 문제가 있습니다.

Ubuntu에서 다른 사용자로 명령을 실행하는 데 문제가 있습니다.

우분투 14.04를 사용하고 있습니다. 루트로 로그인하면 anotehr(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'

관련 정보