Re: GNU Bash shell startup files

"Xi Ruoyao" ([email protected] via blfs-dev Mailing List) <[email protected]> Fri, 16 Jan 2026 21:07:03 +0800
Newsgroups gmane.linux.lfs.beyond.devel
Message-ID <[email protected]>
On Fri, 2026-01-16 at 09:51 -0300, Jamenson Espindula wrote:
> Hi all.
> 
> I had an idea of include (in every startup file of the GNU Bash -
> version 5.3.0) an "echo" line as the last command to be executed.
> Below is the output of that "echo" commands:
> 
> Successful login
> 
> read file '/etc/profile'
> read file '/etc/bashrc'
> read file '/root/.bashrc'
> read file '/root/.bash_profile'
> 
> 
> su --login
> 
> read file '/etc/profile'
> read file '/etc/bashrc'
> read file '/root/.bashrc'
> read file '/root/.bash_profile'
> 
> 
> su
> 
> read file '/etc/bashrc'
> read file '/root/.bashrc'
> 
> 
> Some conclusions:
> 
> Conclusion one: regardless it be 'login shell' or a 'non login shell',
> the '/etc/bashrc' and the '$HOME/.bashrc' files _always are read_ and
> in that order.

> Conclusion two: the '/etc/.bash_profile' is the _last file read_ after
> a successful login using the program '/usr/bin/login'.

As you've put the echo line at the end of the file, if one file sources
another, you'll see a reversed order.

For example, in the "su --login" case:

1. bash reads /etc/profile, executes it, and prints "/etc/profile."
2. bash reads .bash_profile, which sources .bashrc, and it only prints
".bash_profile" after finishing .bashrc.

As your deduction is already completely wrong here, I'll not waste more
time to read further.

-- 
Xi Ruoyao <[email protected]>

-- 
http://lists.linuxfromscratch.org/sympa/info/blfs-dev
Unsubscribe: See the above information page