Do we have anyway to add a path globally so that each user gets it in $PATH. I want to add path of ANT so that each user doesn't need to add it in his $PATH variable.

  • 1
    If you intend users to run a particular shell, say bash, then you could add the export line in /etc/bashrc as it will be read systemwide. – mkc Dec 11 '13 at 16:54

Global paths should be set in /etc/profile or /etc/environment, just add this line to /etc/profile:


Many Linux distributions support the Linux Standard Base /etc/profile.d directory where configurations such as additional paths directives can go without touching the stock system files. The file name just needs an .sh extension.

For example

cat >> /etc/profile.d/some_name.sh << \EOF

Edit /etc/profile and update the Path manipulation section. Centos does not include the /usr/local/bin in the path.

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
    pathmunge /usr/local/bin
    pathmunge /usr/local/bin after
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
  • 2
    It looks like your code assumes bash is being used. Also, notice the aix tag on the question. This user is not using CentOS. – Kusalananda Mar 20 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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