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?

2
  • 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 2:35
  • Worth a glance, particularly if you use .bashrc: 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
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.

0
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!

1
  • Note that this won't make any difference for existing users. Modifying /etc/profile is probably an option. – Faheem Mitha Jun 28 '15 at 5:59

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.