Skip to content
Home » Linux Unix » SSH Remote "Command not found"

SSH Remote "Command not found"

Remote: command not found

Tried to execute a command on a remote server simply by using SSH tunnel, but it failed with "command not found".


In Linux, we saw command not found.

[grid@primary01 ~]$ ssh primary02 "lsnrctl status"
bash: lsnrctl: command not found


In AIX, we saw a similar message.

[grid@primary01 ~]$ ssh primary02 "lsnrctl status"
ksh: lsnrctl: not found.

Let's see what manual says about it.

[grid@primary01 ~]$ man ssh
     If a command is specified, it is executed on the remote host instead of a login shell.

Which means that we didn't login the remote shell to execute the command.


To reach our goal, we should set environment by sourcing the profile by a dot command before executing the command.


For bash shells, we should source .bash_profile.

[grid@primary01 ~]$ ssh primary02 ". ~/.bash_profile; lsnrctl status"


For ksh shells, we use .profile.

[grid@primary01 ~]$ ssh primary02 ". ~/.profile; lsnrctl status"

Please note that, the first dot command is the same as the command source.

Leave a Reply

Your email address will not be published. Required fields are marked *