0

I would like gentoo to allow users to have a bin directory which is added to the PATH variable for that user. The directory would be located at /home/user/bin.

Where is the best place to set the PATH variable to this directory for each user?

  • Every user should have a .bashrc or .bash_profile file in their home directory. Add export PATH="$HOME/bin:$PATH" to the file you choose to use. – danemacmillan Jun 28 '15 at 02:35
  • Worth a glance, particularly if you use .bashrc: http://unix.stackexchange.com/q/124444/25985 Note that which startup files are sourced depends on how the user logs in and there is no singular, universal solution. – goldilocks Jun 28 '15 at 14:52

2 Answers2

3

After looking into /etc/profile. The best place to do this is in /etc/profile.d. Place a script in this directory that looks like this:

# add ~/bin to path for all users.
PATH="${HOME}/bin:${PATH}"
export PATH

When /etc/profile runs it calls

for sh in /etc/profile.d/*.sh ; do
        [ -r "$sh" ] && . "$sh"
done

This will run the new script in /etc/profile.d.

The advantage of this in gentoo is when /etc/profile is updated through emerge there will be no dispatch-conf changes that need to be merged.

1

If you want to apply to each user, you can do what danemacmillan has said.

But if you want to apply to a system wide, especially for newly created users, you have to modify the file /etc/skel/.bashrc with these following lines:

export PATH="$PATH:$HOME/bin"

Have fun!

unsung
  • 41