Sthu Deus wrote: > $ su -c 'abc' -l anotheruser > -su: abc: command not found > > The abc is in the anotheruser's path, but it seems option '-l' does not > work here. A very confusing topic and one often discussed is the process bash uses to start up and what environment files are processed and at what times. PATH is usually set in a user's .profile (or .bash_profile). The .bashrc is not loaded at login time and is usually sourced from the .profile. If a user has added PATH to .bashrc and hasn't sourced the .bashrc in the .profile then something like the above can occur. But that isn't a "correct" configuration IMNHO. Try this to print the PATH: su -l anotheruser -c 'printenv PATH' > How I can accomplish the goal (without manually specifying complete > path)? Put PATH setup in the .profile (or .bash_profile) and source the .bashrc from the .profile. If modifying the other user environment is not possible then you would need to source the files expliclitly. su anotheruser -c '. ~/.bashrc ; printenv PATH' Bob
Attachment:
signature.asc
Description: Digital signature