Add variables to $PATH RHEL5/6

Permanently deleted user -

To view your path variables you can print them to a terminal using the following command:

[user@host]# echo $PATH

The result might be something like this:

[user@host]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/cvfs/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

 

You may want to add paths to the path to allow you to type the name of a service instead of a path to the executable.  The file in RHEL5/6 that contains the path is: /etc/profile

This file might look something like:

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
        if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
           if [ "$2" = "after" ] ; then
              PATH=$PATH:$1
           else
              PATH=$1:$PATH
           fi
        fi
}

# ksh workaround
if [ -z "$EUID" -a -x /usr/bin/id ]; then 
        EUID=`id -u`
        UID=`id -ru`
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
        pathmunge /sbin
        pathmunge /usr/sbin
        pathmunge /usr/local/sbin
        pathmunge /usr/cvfs/bin
fi

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

if [ -x /usr/bin/id ]; then
        USER="`id -un`"
        LOGNAME=$USER
        MAIL="/var/spool/mail/$USER"
fi

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
    INPUTRC=/etc/inputrc
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
    if [ -r "$i" ]; then
        . $i
    fi
done

unset i
unset pathmunge

*NOTE: edit the portion under # Path Manipulation to add a path for the root user.

Additionally, path info can be added as a file to /etc/profile.d/

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.