I set the $ PATH variable in the / etc / profile file like this:

export PATH=$PATH:/usr/app/cpn/bin 

My team is in:
$ which ydisplay /usr/app/cpn/bin/ydisplay

Thus, when I execute echo $PATH , the result looks like this:

$ echo $PATH ...:/usr/app/cpn/bin

And everything works fine, but when I try to do the same for SSH, I get the following error:

 $ ssh 127.0.0.1 ydisplay $ bash: ydisplay: command not found 

But at the same time, as you can see, my path is in place:
$ ssh 127.0.0.1 echo $PATH ...:/usr/app/cpn/bin

Please explain to me why this is happening and how to properly configure $ PATH?

The most mysterious thing for me is that if you specify $ PATH in the same way in a user’s .bashrc file, everything works fine. However, I do not want to modify each .bashrc file for each user; instead, I want to make changes only in / etc / profile.
I suspect that this is a feature of the non-interactive Shell.

  • Of course you added the last line in / etc / profile?> Export PATH = $ PATH: / usr / app / cpn / bin - pyatak
  • @pyatak, yes - SIGSEGV
  • Of course this option doesn't suit you?!> Ssh localhost ". / Etc / profile; ydisplay" - pyatak

2 answers 2

* .profile files are used only when the login shell starts.

You can transfer the PATH change to bashrc or:

 ssh 127.0.0.1 "bash -l -c ydisplay" 

    When you connect via ccx, the file with the settings ~ / .ssh / environment is read.

    Read

    man 1 ssh

    and you will understand everything.