1

This question already has an answer here:

This question has been asked before online but with conflicting answers so I am looking for clarification.

What is the best way to add $PATH variables (below) in debian so that they are persitent for every user ?

I have used the below commands when logged in as root, which works fine but obviously when I reboot these are lost.

Another post I read suggested to paste the below lines into .bashrc or .profile but assume this will only work for the logged in user ? If so how would I set the below for all users ?

export PATH=$PATH:/etc/xcompile/armv4l/bin
export PATH=$PATH:/etc/xcompile/armv5l/bin
export PATH=$PATH:/etc/xcompile/armv6l/bin
export PATH=$PATH:/etc/xcompile/i586/bin
export PATH=$PATH:/etc/xcompile/m68k/bin
export PATH=$PATH:/etc/xcompile/mips/bin
export PATH=$PATH:/etc/xcompile/mipsel/bin
export PATH=$PATH:/etc/xcompile/powerpc/bin
export PATH=$PATH:/etc/xcompile/powerpc-440fp/bin

Golang

export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/Documents/go

marked as duplicate by Jeff Schaller, Christopher, Stephen Rauch, Romeo Ninov, Archemar Dec 5 '17 at 10:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

If you want the PATH set for all users when they log in, set it in etc/profile which sets up the environment for login shells

You can add several components in one statement:

export PATH=$PATH:/etc/xcompile/armv4l/bin:/etc/xcompile/armv5l/bin:etc/xcompile/armv6l/bin

If you want the PATH set for individual users when they log in, it should be set in ~/.profile.

And if you want it set for individual users every time they start an interactive shell, set it in ~/.bashrc

For a more complete discussion of this see the bash documentation

1

In my opinion you should not "mess" the /etc/profile it is more advisable to add it to a custom sh inside the /etc/profile.d/yoursh.sh. This will be imported for all users.

If you want for a single user you should use the .profile has it was said before or the .bashrc depending on the case.

  • I don't know how many systems use /etc/profile.d. Using /etc/profile will work anywhere – PiedPiper Dec 5 '17 at 9:38
  • thanks @PiedPiper i tested the .profile file and that worked fine. I will try adding it to file /etc/profile and see how I get on ! – Bat Dec 5 '17 at 10:00
  • both methods appear to work fine so will use the /etc/profile to set variable for all users - thanks for help @PiedPiper and Banjosa – Bat Dec 5 '17 at 10:06
  • @PiedPiper ok done my friend ! – Bat Dec 5 '17 at 13:28

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