Who sets the PATH? [SOLVED]

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
ingeva
Level 4
Level 4
Posts: 207
Joined: Wed Jun 20, 2012 3:39 am
Location: Sandvika, Norway

Who sets the PATH? [SOLVED]

Post by ingeva »

I'm running Mint MATE 18 and have just done some rearrangement of my directory structure.
During this process I discovered that my PATH has been set incorrectly. For instance I have a private "bin" direcory that I want to have first in my PATH.
When I start Terminal,
PATH=/home/inge/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

The first direcory is wrong; that's not where my "bin" directory is.
The last two, "games" directories, don't even exist in my system (I have no use for them).

I've changed /etc/environment to
PATH="/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

but it has no effect.

I've made a temporary solution by setting the correct PATH in my .bash_aliases file, but that requires one setting for each user. So WHERE is the PATH actually set by bash, so I can set it once and be done with it?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Mint rules! (20.1 MATE) Cinnamon go home! :)
Cosmo.
Level 24
Level 24
Posts: 22968
Joined: Sat Dec 06, 2014 7:34 am

Re: Who sets the PATH?

Post by Cosmo. »

The path variable gets set for the system in /etc/environment. You can add folders for the user in the hidden file .profile in your home. There is by default the folder ~/bin set, that is the reason, why home/inge/bin is in your path list. You can either change this in your .profile file or move the folder bin to the base of your home.
User avatar
ingeva
Level 4
Level 4
Posts: 207
Joined: Wed Jun 20, 2012 3:39 am
Location: Sandvika, Norway

Re: Who sets the PATH?

Post by ingeva »

Cosmo. wrote:The path variable gets set for the system in /etc/environment. You can add folders for the user in the hidden file .profile in your home. There is by default the folder ~/bin set, that is the reason, why home/inge/bin is in your path list. You can either change this in your .profile file or move the folder bin to the base of your home.
I modified /etc/environment, but it's ignored.
I deleted .profile, and the PATH is still set.
I deleted .bashrc to see if something funny happened, but the PATH is still wrong.

I know I can add a PATH statement in the profile, but then I would need to modify all user profiles.
I know I can move the bin directory, but that's not where I want it to be, and in order to do so I must edit a number of batch files.

I'm a firm believer in solving problems at the source. Make the engine silent instead of packing it in sound damping material.

EDIT:
Came to think that I might have to reboot. I did - and the PATH is now set correctly. No one said I had to reboot. I "never" do that with linux! :)
Last edited by ingeva on Sat Nov 19, 2016 6:46 am, edited 1 time in total.
Mint rules! (20.1 MATE) Cinnamon go home! :)
Cosmo.
Level 24
Level 24
Posts: 22968
Joined: Sat Dec 06, 2014 7:34 am

Re: Who sets the PATH?

Post by Cosmo. »

Please provide the content of your /etc/environment.
Did you reboot after changing it? (I am not sure, if this is needed, but it might be that this gets only read when booting, perhaps when login in.)

There is one thing I do not understand. Following the starting post you want to add the bin folder from your account. What might be the sense to add it for the complete system? Your home is your home.
User avatar
ingeva
Level 4
Level 4
Posts: 207
Joined: Wed Jun 20, 2012 3:39 am
Location: Sandvika, Norway

Re: Who sets the PATH?

Post by ingeva »

Cosmo. wrote:Please provide the content of your /etc/environment.
Did you reboot after changing it? (I am not sure, if this is needed, but it might be that this gets only read when booting, perhaps when login in.)

There is one thing I do not understand. Following the starting post you want to add the bin folder from your account. What might be the sense to add it for the complete system? Your home is your home.
I found that the /etc/environment was read at boot time, not at session time, as you can now see after I edited the post.
The "bin" directory is still under "home", but another place in the directory structure, for convenience.

The content of my /etc/environment file is now
PATH="~/Documents/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Mint rules! (20.1 MATE) Cinnamon go home! :)
Locked

Return to “Software & Applications”