When executing an SSH session that simply launches a command instead of actually connecting you, it appears as though my PATH environmental variable differs from when I connect to the SSH session normally, and it's missing the location of my binaries for bash commands. Why would this be, and how can I avoid it?

Normal connection of : ssh root@host Yields a PATH env of


An ssh to execute command but not connect to the terminal directy (ssh root@host ls) yields "ls: command not found". Upon further inspection, the PATH environmental variable is missing /proc/boot, and thus missing the location of the ls binary file.

The PATH env of this 'non terminal' session yields:


but NOT /proc/boot, so it can't call standard actions like ls,mkdir, etc.

Why is this? How can I get my proper PATH when simply executing a command over SSH, but not connecting directly to a displayed terminal?


Because depending on the type of session (login/non-login, interactive/non-interactive) your .profile or your .bashrc are taken in account or not.

To distinguish between the various types of shells, see here.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.