Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 03-31-2004, 07:01 PM   #1
Registered: Feb 2004
Posts: 40

Rep: Reputation: 15
Login shells vs non-login shells

What is the difference between a 'Login shell' and a 'Non-login shell'?

From what I can gather, login shells source the /etc/profile and the ~/.bash_profile files as well as the /etc/bashrc and ~/.bashrc files. Non-login shells only source the latter two...

So what is the difference, and why is one used over another?

If I am in runlevel 3 each of the virtual terminals is a login terminal... right?

If I start a terminal in X, is it a login shell or a non-login shell? Why?

I have Eterm, and you can choose whether to make it login or not. Why should I have it either way?

Thanks in advance....
Old 03-31-2004, 08:02 PM   #2
Registered: Nov 2003
Distribution: RedHat 9.0
Posts: 45

Rep: Reputation: 15
Some people have things in their ~/.bash_profile that you wouldn't want running in an Xterm. For example, I have made a .bash_profile that automatically started X when the user logged in.

Basically, the .bash_profile is used for things that only have to be done once per login, especially system administrative per-user tasks.

However, I'm not sure what the non-login and login distinction was originally for, and I'd be interested to know.
Old 03-31-2004, 08:29 PM   #3
Registered: Dec 2003
Location: Toronto, Canada
Distribution: Mint, Mandriva
Posts: 221

Rep: Reputation: 31
Hstorically, all logins started with the invocation of a shell, and all further commands would be executed from that shell, and inherit its environment. If you use startx from a login shell, this is still the case.

Over the course of a session, many shells will be started, and there is no need to re-initialize the environment for each one.

Nowadays, many people bypass the shell and log in directly to X via a display manager (xdm, gdm, kdm, or similar). Chances are that your .bash_profile (or .profile) will not have been sourced during the initialization of X, so you may wnat to start bash as a login shell to set up your preferred environment.
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chainging the PATH on login shells cliff76 Debian 5 06-16-2005 04:52 PM
help on the different shells... JoannesX Programming 2 02-06-2005 12:07 PM
Bash and login shells Adrohak Linux - Software 3 11-18-2004 11:21 AM
Why so many shells? linuxzouk Linux - Newbie 5 06-10-2004 08:36 AM
Shells andrewtc Linux - Newbie 3 05-01-2003 04:52 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:46 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration