2

I made a directory /opt. How can I add it to the path for all users?

I tried adding it to /etc/profile but it didn't work.

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt"
fi
export PATH
Michael
  • 160
  • 1
    Are the binaries directly in /opt, or a subdirectory of it? – Jeff Schaller Dec 11 '17 at 18:35
  • of course, there's a minor possibility that a user overrides the whole PATH in their personal shell startup files – ilkkachu Dec 11 '17 at 18:41
  • @JeffSchaller, the binaries are directly in /opt. @ilkkachu, that is not the case here. If a user does that, they deserve to have everything not work. – Michael Dec 11 '17 at 18:43
  • Just to make sure, did you have the user log out and back in after making that change? – Andy Dalton Dec 11 '17 at 19:04
  • Are you sure your users are using bourne shell or its compatible versions? If they are using zsh or csh for example, they may not use /etc/profile – Patrick Mevzek Dec 11 '17 at 19:46
  • @PatrickMevzek, until all of the kinks are worked out, I will be the only user. – Michael Dec 11 '17 at 21:08
  • @AndyDalton, I rebooted the machine. – Michael Dec 11 '17 at 21:08
  • 1
    Putting it into /etc/profile should work. If it doesn't then I guess you should be able to debug it by putting a echo PATH=$PATH at the beginning and at the end of all the shell config files (/etc/profile, /etc/bash.bashrc, ~/.bashrc, etc.). Note that you did not mention which shell you are using. – Tomáš Pospíšek Dec 11 '17 at 22:29

0 Answers0