What is the difference between the various shell profiles?

后端 未结 2 743
萌比男神i
萌比男神i 2021-02-15 17:44

What\'s the difference between ~/.bashrc, ~/.bash_login, ~/.bash_logout, ~/.bash_profile, ~/.profile, /etc/profile, /etc/bash.bashrc, /etc/ssh/ssh_config and sshd_config, when a

2条回答
  •  忘掉有多难
    2021-02-15 18:07

    I happen to be curious about these files and did some experiment myself. It turns out to be a little different than what is in the documents.

    I know the differences between interactive and non-interactive or login and non-login.

    I tried on two computers, my macbook pro with OS 10.9 and a server with ubuntu server 13.10. I add the following command into the /etc/profile:

    echo "Loading /etc/profile"
    

    And similar commands into /etc/bash.bashrc, /etc/bashrc, /etc/bash.bashrc, ~/.profile, ~/.bash_profile, ~/.bashrc, ~/.bash_login and make sure that these files do not source each other inside themselves.

    (OS 10.9, GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)) On the mac, with interactive login bash, I have:

    Loading /etc/profile
    Loading ~/.bash_profile
    

    Which means that the files loaded directly are only /etc/profile and ~/.bash_profile.

    with interactive non-login bash, I have:

    Loading ~/.bashrc
    

    which means that the file loaded directly is ~/.bashrc.

    (ubuntu server 13.10 GNU bash, version 4.2.45(1)-release (x86_64-pc-linux-gnu)) On the ubuntu, with interactive login bash, I have:

    Loading /etc/profile
    Loading ~/.bash_profile
    

    Which means that the files loaded directly are only /etc/profile and ~/.bash_profile.

    with interactive non-login bash, I have:

    Loading /etc/bash.bashrc
    Loading ~/.bashrc
    

    which means that the files loaded directly are /etc/bash.bashrc and ~/.bashrc.

    I do not know why~

提交回复
热议问题