Sep 7, 2010

Quick Tip: Set default path in RHEL

I've recently had to do some work on Red Hat Enterprise Linux and both of the snags I hit were related to the path. First, when doing a sudo to another user in RHEL you need to pass along a dash ( - ). So whereas in Ubuntu you might to

sudo su deploy

In RHEL that equivalent is:

sudo su - deploy

Failing to do so gives you the default path. Which brings me to the 2nd issue.. how do you add something to that default path?

Turns out in Red Hat that you can add something to the default path by creating a new file in /etc/profile.d/

For me I was wanting to add Ruby Enterprise Edition to the default RHEL path so I created a new file (as root) called and added this content:

if ! echo ${PATH} | /bin/grep -q /opt/ruby/bin ; then

I've got REE installed in /opt/ruby but you may need to adjust your path accordingly if you've got it somewhere else. This tip should work with other packages as well. If /usr/local/bin isn't in your default path maybe it should be..

No comments:

Post a Comment