LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-13-2010, 12:51 AM   #1
daudiam
Member
 
Registered: Mar 2010
Posts: 68

Rep: Reputation: 15
confusion regarding the login shell and consequent sub-shells


When we are asked for password while booting Linux, is that the login shell ? If yes, we can't seem to be able to do anything in that shell besides typing the password. (Is it in this that the contents of /home/.profile file gets executed ? in a sigle PC)

When we click on the terminal icon for the first time, are we opening a subshell of something or a new shell altogether ? If on repeatedly clicking on the terminal icon, new shells are being launched, not sub-shells, then why does export seem to work with the new shells, though its supposed to work for sub-shells ?
 
Old 06-13-2010, 02:11 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
When you login you are not in your own shell. You are in the login shell which asks who you are and what is your password.
If you supply correct information, the login shell passes you over to your normal shell which is usually /bin/bash. The login shell does not have any more commands available because it does not know who you are unless you log in. It exists only to check permissions.

After that, you do not open any more shells, what you are confusing them with is virtual terminals (VT). These are "windows" to the underlying bash shell. You can have multiple VTs all in the same shell. You can also use screen which gives you multiple VTs within a VT.

But they are all running under your initial bash shell.
Open a terminal, and run the command who

Then open another terminal and run who again. Keep doing this, and you will see that the terminal number for each open terminal increases by one, but they are all using the same sub-screen (or tty), that is :0.0
The very first line is the screen that everything else is running under when you logged in, that is :0

None of these are running in separate shells. It's the same shell, but with different terminals accessing it. Computers are clever like that, they can do more than one thing at once !

tty's are the same locally or remotely. They are a legacy name for a terminal, when terminals used to be real hardware connected to mainframes over a network. So each tty was a physical screen and keyboard somewhere on the network. This is still true BTW, but the same method works for VTs on the same screen and keyboard, and so why change it ?

The who command shows you where each tty is located either on the network or locally, hence the original tty is :0, and all the others are connected to it.

So finally, export works with "sub shells" because they are not sub shells. They are the same shell, just a different VT using it.

Last edited by smoker; 06-13-2010 at 02:22 AM.
 
Old 06-13-2010, 03:14 AM   #3
daudiam
Member
 
Registered: Mar 2010
Posts: 68

Original Poster
Rep: Reputation: 15
system-wide and local .profile file

Thanks a lot, really!

The .bashrc is used for non-login shells, so when I make make any changes in it, like type echo hello, it reflects when I open a new VT. But, the .profile file is for the login shell only. If I make any changes to that file (before the point it calls the .bashrc file), where do the changes reflect? in the login shell(the page is so nice, it hardly seems to be a shell). I am asking this because the .profile file is in our home directory, and login shells should have nothing to do with a particular user's file (its general, for all users). There is also a system-wide .profile file. Does editing this, change the login prompt because its not particular to a user.

Thanks again.
 
  


Reply

Tags
shell


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Login and Interactive shells Josh000 Slackware 7 04-23-2010 09:02 AM
[SOLVED] GNU Screen doesn't start shells as a login shell Himilhil Linux - Software 3 03-22-2010 03:52 AM
Why I can't change my Shell from bash to any other shells I have. johnsanty Linux - General 7 04-20-2006 07:03 PM
Login shells / Non-login shells tofee Linux - Newbie 1 03-24-2006 11:03 PM
Login shells vs non-login shells lsmith Linux - General 2 03-31-2004 07:29 PM


All times are GMT -5. The time now is 01:38 PM.

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