0

I assume this question has be asked many times.I just can't manage to change the PATH var permanently. This is what I do:

nano ~/.profile 
export PATH=$PATH:/my/additional/path
save changes

I even created the ~/.pam_environment file to try to define the PATH in there but it simply want last after the new login;.

What am I doing wrong? p.s. Im currently on Debian 8

Milan
  • 1
  • I would think the `.pam_environment` should work. The `.profile` `.bash_profile` and `.bashrc` files are sourced after pam environment though so depending on what sort of shell you are interacting with (or not) they may be overwriting the `PATH` variable if it's set in one of those files. – jesse_b Aug 12 '17 at 12:52
  • How will each path be unique for each user? Will it be in a common location in their user directory or a common directory that stores all user specific directories? If so like Christopher suggested you could still add that to the `/etc/skel/.bashrc` file as something like: `export PATH=$PATH:$HOME/usr/bin` or `PATH=$PATH:/usr/$USER/bin` or `PATH=$PATH:/usr/$(whoami)/bin` – jesse_b Aug 12 '17 at 12:57
  • `.profile` is the right place. How do you log into the account (GUI login, text console, SSH, …)? What is the value of `PATH`? What other dot files does the user have? What is the user's login shell? Post the output of `bash --login -x`. – Gilles 'SO- stop being evil' Aug 12 '17 at 21:57
  • Im using /bin/sh and would like to set a different PATH for each user in a .dot file in their home direcoty. That sound most logical to me. Gilles: when I do bash --login -x or -lx I see that the bash sets the PATH var as I wish to, but when I exit -lx and echo $PATH it goes back to the previous state. Maybe one file is overwriting the other or something? – Milan Aug 13 '17 at 07:18

1 Answers1

1

you need to edit the files in your /etc/skel directory, you can add an .profile there with that config, or in .bash_rc. Every time you create a new user it will take all the files from /etc/skel

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
  • 1
    I will try certainly this. But I dont want a universal PATH for each user, just the opposite, a unique PATH for each user I create. – Milan Aug 12 '17 at 06:05
  • Well as any other bash script, .bash_rc can hold variables so if you want something related to the user you could use `whoami` and save it or any other kind of variable, hope it helps. – Christopher Díaz Riveros Aug 12 '17 at 06:12
  • Is it really `.bash_rc` in debian or still just `.bashrc`? – jesse_b Aug 12 '17 at 12:50
  • honestly, don't know, I use Gentoo, but follow your `/etc/skel` directory, there are all the files with the appropriate names, hope it helps :) – Christopher Díaz Riveros Aug 12 '17 at 15:30
  • 1
    @Jesse_b It's `.bashrc`. And [it isn't a good place to set environment variables](https://unix.stackexchange.com/questions/3052/is-there-a-bashrc-equivalent-file-read-by-all-shells/3085#3085). – Gilles 'SO- stop being evil' Aug 12 '17 at 21:56