Skip to main content
added 72 characters in body
Source Link
goldilocks
  • 90k
  • 33
  • 212
  • 272

From man bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.

"Interactive shells" are ones starting in the foreground on a terminal, but they are not necessarily login shells.

A login shell is one whose first character of argument zero is a -, or one started with the --login option.

GUI terminals don't do that.

This is why generally, .profile sources .bashrc -- then .bashrc can contain the stuff you want for all shells, and .profile any additional stuff just for login shells. Sometimes this is qualified in .profile by checking if $PS1 (the interactive prompt) is defined, so that .bashrc only gets included for interactive ones. One reason for this would be to avoid the use of certain aliases in non-interactive (e.g., script execution) shells.

So: you wantcould put your $PATH definition in ~/.bashrc, and make sure it is sourced from ~/.profile or ~/bash_profile.

From man bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.

"Interactive shells" are ones starting in the foreground on a terminal, but they are not necessarily login shells.

A login shell is one whose first character of argument zero is a -, or one started with the --login option.

GUI terminals don't do that.

This is why generally, .profile sources .bashrc -- then .bashrc can contain the stuff you want for all shells, and .profile any additional stuff just for login shells. Sometimes this is qualified in .profile by checking if $PS1 (the interactive prompt) is defined, so that .bashrc only gets included for interactive ones. One reason for this would be to avoid the use of certain aliases in non-interactive (e.g., script execution) shells.

So: you want your $PATH definition in ~/.bashrc.

From man bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.

"Interactive shells" are ones starting in the foreground on a terminal, but they are not necessarily login shells.

A login shell is one whose first character of argument zero is a -, or one started with the --login option.

GUI terminals don't do that.

This is why generally, .profile sources .bashrc -- then .bashrc can contain the stuff you want for all shells, and .profile any additional stuff just for login shells. Sometimes this is qualified in .profile by checking if $PS1 (the interactive prompt) is defined, so that .bashrc only gets included for interactive ones. One reason for this would be to avoid the use of certain aliases in non-interactive (e.g., script execution) shells.

So: you could put your $PATH definition in ~/.bashrc, and make sure it is sourced from ~/.profile or ~/bash_profile.

added 268 characters in body
Source Link
goldilocks
  • 90k
  • 33
  • 212
  • 272

From man bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.

"Interactive shells" are ones starting in the foreground on a terminal, but they are not necessarily login shells.

A login shell is one whose first character of argument zero is a -, or one started with the --login option.

GUI terminals don't do that.

This is why generally, .profile sources .bashrc -- then .bashrc can contain the stuff you want for all interactive shells, and .profile any additional stuff just for login shells. Sometimes this is qualified in .profile by checking if $PS1 (the interactive prompt) is defined, so that .bashrc only gets included for interactive ones. One reason for this would be to avoid the use of certain aliases in non-interactive (e.g., script execution) shells.

So: you want your $PATH definition in ~/.bashrc.

From man bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.

"Interactive shells" are ones starting in the foreground on a terminal, but they are not necessarily login shells.

A login shell is one whose first character of argument zero is a -, or one started with the --login option.

GUI terminals don't do that.

This is why generally, .profile sources .bashrc -- then .bashrc can contain the stuff you want for all interactive shells, and .profile any additional stuff just for login shells.

So: you want your $PATH definition in ~/.bashrc.

From man bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.

"Interactive shells" are ones starting in the foreground on a terminal, but they are not necessarily login shells.

A login shell is one whose first character of argument zero is a -, or one started with the --login option.

GUI terminals don't do that.

This is why generally, .profile sources .bashrc -- then .bashrc can contain the stuff you want for all shells, and .profile any additional stuff just for login shells. Sometimes this is qualified in .profile by checking if $PS1 (the interactive prompt) is defined, so that .bashrc only gets included for interactive ones. One reason for this would be to avoid the use of certain aliases in non-interactive (e.g., script execution) shells.

So: you want your $PATH definition in ~/.bashrc.

Source Link
goldilocks
  • 90k
  • 33
  • 212
  • 272

From man bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

When a login shell exits, bash reads and executes commands from the files ~/.bash_logout and /etc/bash.bash_logout, if the files exists.

When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.

"Interactive shells" are ones starting in the foreground on a terminal, but they are not necessarily login shells.

A login shell is one whose first character of argument zero is a -, or one started with the --login option.

GUI terminals don't do that.

This is why generally, .profile sources .bashrc -- then .bashrc can contain the stuff you want for all interactive shells, and .profile any additional stuff just for login shells.

So: you want your $PATH definition in ~/.bashrc.