Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Why at the login bash read .profile before .bash_login ?

user-image
Question added by R e n z o V i d o n i , Consultant , Various
Date Posted: 2015/09/17
Adel Abdel Hamid
by Adel Abdel Hamid , TSM technical support specialist , IBM

from

http://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html

 

"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."

 

 

Patrick O''Leary
by Patrick O''Leary , CEO, CTO, Founder , eWitness, LLC

The login will get executed1 time at login, profiles gets executed with every shell/script that you run.

the login is read last to give you the chance to override the profile one knee only one time at login.

YASSER GHAREEB
by YASSER GHAREEB , Graphic Designer , NEW VISION

  1.  BUT BELIEVE IN GUP
  2. MORE MONEY 

Sonny Wenfred Lafuente
by Sonny Wenfred Lafuente , System Engineer , Entropy Solution Pte Ltd.

To check permissions and environment variables.

KHAJA AHSAN KHAN
by KHAJA AHSAN KHAN , Associate Director , Hilton World Wide

the .profile gets executed first and then the .bash_login.

Huzefa Akhter
by Huzefa Akhter , Head of IT Department , Wethaq Takaful Insurance Co

As linux is highly flexible, users are given an opportunity to change the name and location of envioronment setting files (even have a same file for multiple users), but as bash needs a pointer to start with, that pointer is hardcoded to be .profile 

dhakr qayid sufyan saeid الحبشي
by dhakr qayid sufyan saeid الحبشي , موضف شركة صرافه , الإمام للصرافة

Login will be executed once upon login, and

Sourav Bose
by Sourav Bose , Unix Infrastructure Administrator , Wipro Technologies

Because all enviromanetal varible updates along with reboot and stores in .profile file.

Priyanka Chavan
by Priyanka Chavan , System Analyst/Senior System Engineer , Infosys

.profile file process before .bash_login to accomodate both interactive and non-interactive sessions

Thomas Siju
by Thomas Siju , Service Engineer , Southern Naval Command

When the bash script executed in specific  log in shell then it runs required profile commands which exists

Ahmed Sayed
by Ahmed Sayed , Embedded Systems Software Developer , freelancer

because .profile extension is used for files in terminal programs, profile file in Linux comes under the System startup files(defines user environment after reading the initialization files that you have set up when you log in to shell).

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.