Fedora Linux Support Community & Resources Center
  #1  
Old 25th March 2009, 10:38 PM
mendicant Offline
Registered User
 
Join Date: Feb 2009
Posts: 5
What is exact purpose of login versus non-login bash shells?

Hi,

I hope I am posting this question in the right place.

During the set up for Linux From Scratch I was directed to use a login shell as opposed to a non-login shell. I have spent a fair amount of time trying to figure out the exact purpose for one as opposed to the other. I have found a great deal of information on how to invoke the two types of shells as well as the scripts that are run by each of them. What is not clear to me is why one would use one of these shells as opposed to the other. Now that I have spent so much time trying to track down an answer I would greatly appreciate any details any of you out there could give me.

Thanks in advance, M.
Reply With Quote
  #2  
Old 25th March 2009, 11:53 PM
LinuxTom Offline
Registered User
 
Join Date: Jul 2005
Location: Kentucky, U.S.A.
Posts: 354
To the best of my understanding the login shell invokes... (Feel free to correct me if I am wrong)

Quote:
/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile
Whereas a non-login shell only invokes...

Quote:
/etc/bashrc
~/.bashrc
The login shell essentially sets up the user configured variables (and system variables) then executes the secondary (non-login) shell where you would execute your programs. As to why one would use one type of login over another I don't really know; I have always used the login shell when using su.
Reply With Quote
  #3  
Old 25th March 2009, 11:58 PM
sonoran Offline
Registered User
 
Join Date: May 2005
Location: Sonoran Desert
Posts: 2,423
From the bash info page:

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

When a login shell exits, Bash reads and executes commands from the
file `~/.bash_logout', if it exists."

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

There's a lot more in man bash and info bash if you really want to dig into it.
Reply With Quote
  #4  
Old 26th March 2009, 12:18 AM
mendicant Offline
Registered User
 
Join Date: Feb 2009
Posts: 5
Thanks for the feedback.

LinuxTom: It would make sense in the context of what I was doing i.e. setting up an unprivileged user to safely begin the building of a Linux From Scratch system. If the login shell is used as you say to "essentially set(s) up the user configured variables (and system variables) then execute(s) the secondary (non-login) shell where you would execute your programs" why would you then always use the login shell as root? I'm not questioning whether it works or not for you - obviously it does. Are you saying that by bringing up a login shell you end up in a non-login shell anyway? My goal with Linux From Scratch is to gain a more complete understanding of the basics of the Linux OS. I find this sort of thing very confusing.

Again I appreciate your feedback, M.
Reply With Quote
  #5  
Old 26th March 2009, 04:17 PM
LinuxTom Offline
Registered User
 
Join Date: Jul 2005
Location: Kentucky, U.S.A.
Posts: 354
From my understanding (at least as it applies to the su command) if you use a login shell (ie: su - username) the environment is set up, then the secondary shell (non-login) is loaded for user interaction. The documentation on all of this stuff is massive, but sometimes hard to follow in typical Linux fashion.
Reply With Quote
Reply

Tags
bash, login, non-login, shells

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
unable login into fedora 9 and getting error as bash:command not found sri22 Using Fedora 3 19th September 2008 12:26 PM
root shell login shows -bash-3.2# 40esp Using Fedora 2 18th December 2007 04:25 PM
after upgrade to F8 only X-login, but failing to login, returns to login screen angro Installation, Upgrades and Live Media 1 26th November 2007 09:12 PM
Bash: Login to root twiistedkaos Using Fedora 2 3rd April 2006 08:04 PM


Current GMT-time: 08:45 (Saturday, 20-12-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
...Creek Side - Stockholm-Arlanda Airport (ARN) Travel Photos on Instagram - Marina of Koper Travel Photos - Te Whiti Park Instagram Photos - Texas State Fair Photos on Instagram