Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I'm logged in my ArchLinux server and type:

$echo $PATH
I get...

But when I'm NOT logged in and try:

ssh myyser@mysever 'echo $PATH'
i get..

The PATH is correct in my /etc/profile but ssh seems to not load that.

Is there any way to fix it for all users/ssh sessions?

It does not happen when i using ubuntu

Posting here as suggested by Eugene Mayevski 'EldoS Corp

share|improve this question

If you're using Bash as the default shell for the user, your ssh command starts a non-interactive non-login shell so it doesn't process /etc/profile. You will need to source that file in your script.

share|improve this answer
is there any other way? I'm asking because its working on ubuntu, maybe is an Archlinux problem... – Alexandre Bini Feb 6 '11 at 18:30

When you run a command via ssh, it does not start a login shell on the remote host. The practical implications of this vary, but typically it means that shell initialization files that run at login will be ignored. On the other hand, shell initialization files that for every shell instance will still be processed.

If you're using bash, this means that only your .bashrc file is used. I often put something like this in my .bashrc file:

if [ ! "$RAN_PROFILE" ]; then
  . $HOME/.profile

And in the bottom of my .profile:


This ensures that I get .profile services even for non-login shells.

share|improve this answer

I fixed this issue adding the path into /etc/environment


Don't know if this is a good practice, but is working.

Thank you!

share|improve this answer
It's perfectly acceptable to 'accept' your own answer if it fixes the problem. You won't get rep, but it lets the system know that the problem is resolved, and later viewers may upvote it when it helps them. – sysadmin1138 Feb 6 '11 at 23:11
sorry, but how can i mark this question as resolved? – Alexandre Bini Feb 7 '11 at 0:02

The shell on your client expands the PATH variable, so you'll need to escape the dollar sign.

foo$ ssh 'echo \$PATH'

share|improve this answer
Not when it's inside single quotes. Your command will echo "$PATH" literally. – Dennis Williamson Feb 6 '11 at 18:09
Well, that was a silly mistake to make. – Alex Holst Feb 6 '11 at 18:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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