Contents
Which file is first executed by a bash shell upon login?
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, ~/.
What is interactive login shell?
An interactive shell is one which reads commands from it’s standard-input, usually a terminal. For example, if you login to bash using an xterm or terminal emulator like putty , then the session is both a login shell and an interactive one.
What is a noninteractive shell?
A non-interactive shell is a shell that can not interact with the user. It’s most often run from a script or similar. It is always a good practice to use the full path for a command but even more so in non-interactive shells.
Where is my Bash file?
In most cases, the bashrc is a hidden file that lives in your home directory, its path is ~/. bashrc or {USER}/.
Is Bash a login shell?
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.
When is Bash invoked as an interactive login shell?
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.
Do you need to specify commands for non-interactive shells to run?
You probably do not want to specify any commands for all non-interactive shells to run; they would run every time a script is run (provided the script is run by the shell you configure to run them). This can cause substantial breakage.
When to run bash profile instead of bash login?
But if .bash_profile exists, bash runs it instead of .profile. If .bash_profile doesn’t exist but .bash_login exists, that is run instead of .profile. (But it is common for .bash_profile or .bash_login, when it exists, to be written so as to *explicitly call .profile .)
Where are the commands in / etc / profile?
Rather, commands in /etc/profile calls them. For example, on my Ubuntu 12.04 system, /etc/profile includes these lines: .profile in the user’s home directory, run by Bourne-compatible shells when started as a login shell (unless overridden, see below).