By typing man bash, we can see

              The bash executable
              The systemwide initialization file, executed for login shells
              The systemwide per-interactive-shell startup file
              The systemwide login shell cleanup file, executed when a login shell exits
              The personal initialization file, executed for login shells
              The individual per-interactive-shell startup file
              The individual login shell cleanup file, executed when a login shell exits
              Individual readline initialization file

What does "per-interactive-shell" means? Especially, what does "per" mean here? Does "per" mean "each" here? Each interactive shell? Or does it mean something else?

Does "the individual per-interactive-shell startup file" mean "the individual startup file for each interactive shell"?

  • 1
    it means every interactive shell reads those files once. per-interactive-shell means the same thing as once-per-interactive-shell. – Gregory Nisbet Mar 28 '19 at 7:14
  • Note that info bash (unlike man bash) does not use this wording and, in chapter "Bash Features" > "Bash startup files", gives a reasonably exhaustive explanation of how startup files are used and the relationships among them. (The info documentation for GNU projects is usually more detailed than the man equivalent). – fra-san Mar 28 '19 at 14:41

The bashrc files are used for initialising each individual interactive shell.

I'm a bit uncertain why the "per-" prefix is actually needed here, seeing as the exact same situation is true for login shells as well (albeit with regards to other files). Also, a non-interactive shell would use whatever file $BASH_ENV holds the pathname of, or to put it in other words "$BASH_ENV is the per-noninteractive-shell startup file" if you will.

It may be an attempt at emphasising (for whatever reason) that the files are actually sourced for each interactive shell.

The wording was introduced in release 2.0 of bash (I believe).

  • Maybe, but still seems to be weird. – Victor Mar 28 '19 at 13:57
  • @Victor I'd agree with that. – Kusalananda Mar 28 '19 at 13:58

Two things here. First the easy one:

“individual” is just another word for “personal”, meaning (in this case) file from your user-account’s home directory. Note in fact the ~/ prefix to all individual/personal files.

On desktop systems like your computer at home you usually have only one user account, but on server computers there can be several accounts registered, and each one has its own home directory and therefore its own personal/individual .bash_profile, .bashrc, etc.

Now the hard one, and to try and explain this I need a small preface:

Bash differentiates between “login” interactive-shells and "other" interactive-shells. (I have no experience about other programs like zsh or ksh but I suppose they do too).

For example, on Linux systems a login shell is typically only the very first one that it’s started after you have entered (correctly) your username and password either from textual console or from a network connection such as ssh.

On the contrary, “other” interactive-shells are typically the ones started by a graphic desktop when you click the icon of the terminal emulator application.

Other” (ie non-login) interactive-shells are also when you subsequently invoke nested interactive-shells even from a login one.

A practical example of this latter case. Suppose you are at the prompt of the first shell after having authenticated yourself (ie logged in) to a remote computer via ssh: that’s the login interactive-shell; but if you then type bash and press Return you start a new other interactive-shell. You can nest them as many as you like. Only, you need to type exit (or Control-D) for each of them in order to unwind the stack of nested interactive-shells you started.

Bash’s documentation there tells you which files are automatically executed on startup of login shells and which other files on startup of other shells. There are also a couple of files that are automatically run only when you quit login shells, but not when you quit other shells.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.