[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Profile order



Hi,

On Sun, Dec 01, 2024 at 06:02:42AM +0800, Bitfox wrote:
> If /etc/profile and home dir’s .bash_profile have included the same command
> but with different arguments. Which one will be used then? Thank you.

Your question doesn't make a lot of sense since, as it is posed, in any
situation where both files would be processed, *commands* that are in
both would *both* be executed.

However you probably meant to ask about things like variable settings,
aliases and function definitions, which are things that can override
earlier ones of the same name.

Note that which files are considered depends on what kind of shell
session is being launched, that is whether it is interactive or not, and
whether it is a login shell or not. This is further complicated by
desktop environments, which may choose one or the other way or can be
configured differently, so one really has to check.

Anyway, /etc/profile and ~/.bash_profile are normally only executed for
interactive, login shells. In any case where both would be executed,
/etc/profile is first, and .bash_profile would then override any prior
setting.

If in doubt it is easy enough to test by putting something in them like

export DEBUG_FILE_ORDER="This is /etc/profile"

export DEBUG_FILE_ORDER="This is .bash_profile"

etc.

etc and see what it ends up as.

Thanks,
Andy

-- 
https://bitfolk.com/ -- No-nonsense VPS hosting


Reply to: