Bash and its startup file execution order

Hello.

When a standard user log in, startup file execution order are in this order :


mars 01 22:46:00 ASUS   ETC_PROFILE[2471]: hBc                        - /etc/profile -  ¨€¨€¨ BEGIN ¨€¨€¨   - USER :  user_bidon_2

mars 01 22:46:00 ASUS   ETC_PROFILE_LOCAL[2495]: hBc                - /etc/profile.local -  %% BEGIN %%   - USER :  user_bidon_2

mars 01 22:46:00 ASUS   ETC_BASH_BASHRC[2562]: hBc                    - /etc/bash.bashrc -  ^*^*^ BEGIN ^*^*^   - USER :  user_bidon_2

mars 01 22:46:00 ASUS   ETC_BASH_BASHRC_LOCAL[2568]: hBc            - /etc/bash.bashrc.local -  && BEGIN &&   - USER :  user_bidon_2

mars 01 22:46:00 ASUS   HOME_NORMAL_USER_BASHRC[2589]: hBc        - /home/user_bidon_2/.bashrc -  °¤°¤° BEGIN °¤°¤°   - USER :  user_bidon_2

mars 01 22:46:00 ASUS   HOME_NORMAL_USER_PROFILE[2603]: hBc        - /home/user_bidon_2/.profile -  °µ°µ° BEGIN °µ°µ°   - USER :  user_bidon_2

When user root log in, startup file execution order are in this order :


mars 01 22:55:21 ASUS   HOME_USER_ROOT_PROFILE[2483]: hBs    - /root/.profile -  °µ°µ° BEGIN °µ°µ°   - USER :  root

mars 01 22:55:21 ASUS   ETC_PROFILE[2494]: hBc                    - /etc/profile -  ¨€¨€¨ BEGIN ¨€¨€¨   - USER :  root

mars 01 22:55:22 ASUS   ETC_PROFILE_LOCAL[2518]: hBc            - /etc/profile.local -  %% BEGIN %%   - USER :  root

mars 01 22:55:22 ASUS   ETC_BASH_BASHRC[2585]: hBc                - /etc/bash.bashrc -  ^*^*^ BEGIN ^*^*^   - USER :  root

mars 01 22:55:22 ASUS   ETC_BASH_BASHRC_LOCAL[2591]: hBc        - /etc/bash.bashrc.local -  && BEGIN &&   - USER :  root

mars 01 22:55:22 ASUS   HOME_USER_ROOT_BASHRC[2612]: hBc        - /root/.bashrc -  °¤°¤° BEGIN °¤°¤°   - USER :  root

mars 01 22:55:22 ASUS   HOME_USER_ROOT_PROFILE[2626]: hBc    - /root/.profile -  °µ°µ° BEGIN °µ°µ°   - USER :  root

‘/root/.profile’ is run twice, the first time $- is set to hBs and the second time $- is set to hBc.
‘/home/user’ is run ounce, $- is set to hBc.

Any comment is welcome.

Do you have an installation or boot problem that you want help with?

As far as I know, the bash man page is correct for this. However, what happens also depends on the content of those files. For example, “/etc/profile.local” is only used because it is invoked from one of the other files.

Also, how you login affects things. If you login to a graphic session, then some startup files are run while starting your desktop. And some might be run again later if you open a terminal window.

I think the default for “xterm” is to start a shell that is not a login shell. But you can use “-ls” as an option to start a login shell. For Konsole, I think it does not start a login shell, but you can configure Konsole with “-l” as a shell argument to get a login shell. I’m not sure about Gnome Terminal, which I rarely use.

If you want to launch a login shell,
Although I wrote the following a long time ago and with specific instructions to accommodate some LXDE quirks at the time, the command should work for any DE and any console. At least, it should still work as written AFAIK.

https://en.opensuse.org/User:Tsu2/LXterminal-login_shell

TSU

Not at all.
It is just a question about “Bash and its startup file execution order”

I just discover that when logging in as a normal user, there is no difference between logging in via the graphical environment(KDE PLASMA5 /SDDM ) or via a text environment (via init 3).
This is different for the user ‘root’
When logging in via the graphical environment ‘/root/.profile’ is run first, then other bash initializing step follow the bash documentation.

Is it a kde team decision or opensuse team decision ?

I want nothing.
I just want to initialize the computer environment for all user ( including root user ) during startup.

Interesting.

But then:

  1. I never login to the graphic environment as root;
  2. There is no “/root/.profile” here.

So I guess I can’t easily test that.