I've just spun up a brand new CentOS 7 VM (bash version 4.2.46) with Vagrant using the centos/7 box, and when I'm logged in as the vagrant user, this is my PATH:


When logged in as root, here's the PATH:


I know that /etc/profile is adding /usr/local/sbin:/usr/sbin (at the end for most users, at the start for root), and the /etc/skel/.bash_profile that ends up in the vagrant home directory is adding /home/vagrant/.local/bin:/home/vagrant/bin, but where is the initial setting coming from?

At present I have no explanation of why users end up with /usr/local/bin:/usr/bin in their PATH, and root gets the others.

(Frankly, the ordering of the root PATH seems very odd, given that /usr/local/sbin and /usr/sbin should be at the end, according to /etc/profile.)


In the bash source "config-top.h" has this:

/* The default value of the PATH variable. */

/* The value for PATH when invoking `command -p'.  This is only used when
   the Posix.2 confstr () function, or CS_PATH define are not present. */

Other people have asked the same thing on the CentOS bug tracker. The earliest post I found was this one.

/usr/local/bin is hardcoded in /bin/bash.

  1. https://bugs.centos.org/view.php?id=10200
  2. https://bugs.centos.org/view.php?id=10199
  3. https://bugs.centos.org/view.php?id=10198
  4. https://bugs.centos.org/view.php?id=7492

As you will see this problem was first reported in May 2012, and has existed in CentOS 6 and CentOS 7.

So as confusing as it may be, it looks like your analysis the paths are not coming from /etc/profile is correct. The paths are coming from /bin/bash.


It definitely looks hard coded into /bin/bash

strings /bin/bash | grep "\/usr\/local\/bin"

which seems to be the default PATH.


In addition to previous answers; If you are reaching you VM by ssh this could has sense.

In /etc/ssh/sshd_config:

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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