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 ?
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.
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.
|All times are GMT -5. The time now is 12:08 PM.|