Debian $PATH variable change

2019-01-23 16:53发布

问题:

How can I change the $PATH variable in Debian? I tried to change /etc/profile but this affected only normal users (and yes, I added path to BOTH user's and root's paths).

After that I tried to edit /root/.profile and then /root/.bashrc also ...

Neither worked. Do you know where could be problem?

回答1:

This is set in the /etc/login.defs on debian 6.0 .

These are the lines you have to edit:

# *REQUIRED*  The default PATH settings, for superuser and normal users.
#
# (they are minimal, add the rest in the shell startup files)
ENV_SUPATH      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV_PATH        PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

EDIT:

I forgot to put where I found the solution: https://serverfault.com/questions/166383/how-set-path-for-all-users-in-debian



回答2:

Modify /etc/environment to include a line like this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"


回答3:

Edit your /etc/.profile to include set -vx near the top. Restart from fresh window. Then you can see what '.' files are processed AND where PATH is being reset.

Also, confirm that you are really in the shell that you think. After all startup scripts are finished, do echo $SHELL and confirm the value = the shell you expect, most likely bash.

I hope this helps.