Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
Difference between Login Shell and Non-Login Shell?

I have been looking at /etc/profile. bash.bashrc to see how they are run, and notice that some are executed by non-login shells, some work with interactive shells etc.

What are the differences in this type of shells, ie interactive & non-interactive, login & non-login etc?

The question may be pretty basic,but it seems I need to ask what a shell is, first and foremost. What is a shell, what is its relevance, how do you use it, and why does it exist to start with?

Update: To make the intent of the question better understood, what I need to understand besides the definitions, are the use cases for one type of shell or the other. It is the use cases that help understanding, not just dictionary definitions.

share|improve this question

migrated from serverfault.com Oct 12 '12 at 7:14

This question came from our site for professional system and network administrators.

marked as duplicate by jasonwryan, manatwork, warl0ck, Mat, jw013 Oct 12 '12 at 13:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
This might be a good place to begin. –  Mitch Brown Oct 11 '12 at 19:07
    
Why vote to close it? I asked this question because lots of times we are so accustomed doing things and thinking in a certain way and we take the tools we use and why we use them for granted. I am asking what seems to be a basic retarded question because of that. –  vfclists Oct 11 '12 at 19:47

2 Answers 2

up vote 9 down vote accepted

A shell is the generic name for any program that gives you a text-interface to interact with the computer.
You type a command and the output is shown on screen.
Many shells have scripting abilities: Put multiple commands in a script and the shell executes them as if they were typed from the keyboard. Most shells offer additional programming constructs that extend the scripting feature into a programming language.
On most Unix/Linux systems multiple shells are available: bash, csh, ksh, sh, tcsh, zsh just to name a few. They differ in the various options they give the user to manipulate the commands and in the complexity and capabilities of the scripting language.

Interactive: As the term implies: Interactive means that the commands are run with user-interaction from keyboard. E.g. the shell can prompt the user to enter input.
Non-interactive: the shell is probably run from an automated process so it can't assume if can request input or that someone will see the output. E.g Maybe it is best to write output to a log-file.

Login: Means that the shell is run as part of the login of the user to the system. Typically used to do any configuration that a user needs/wants to establish his work-environment.
Non-login: Any other shell run by the user after logging on, or which is run by any automated process which is not coupled to a logged in user.

share|improve this answer

It might be strange to realize for some of people who never had a comp disconnected from Internet, that lots of answers regarding UNIX systems are already shipped with them. For e. g., man bash, "Invocation" section:

An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are both connected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state.

share|improve this answer
2  
Don't be too harsh. These days a lot of people come to Linux/Unix from a Windows world. For most of them your quote might just as well be written in Greek. Don't forget: "Once upon a time, we were all newbies." –  Tonny Oct 11 '12 at 19:42
    
@Tonny, I wasn't actually. It often works for me when internet connection goes down and then I realize, that there're lots of manuals/docs. that I can learn from — on the comp already. –  poige Oct 11 '12 at 19:45
    
Aha.. Now I get what you intended to say. Doesn't take away from the fact that the man-pages aren't particularly helpful if you don't already have a reasonable background into Linux/Unix. They are more a reference towards the obscure details of how to use a command than a proper tutorial/explanation of how things work in a Linux/Unix environment. –  Tonny Oct 11 '12 at 19:52
    
@poige The issue with definitions is a lot of time they explain nothing at all, they only provide another set of terminology one needs to look up. I usually login via SSH or directly at the terminal. In those cases what determines whether it is a login shell or not. I don't get to pass any parameters whatsoever as I am not logged to be able to pass any parameters yet. I guess with SSH there could be some parameters to pass that could change the type of login, but when I log in at the console what determines it? Something preconfigured by the distro? –  vfclists Oct 11 '12 at 19:58
1  
@vfclists the login and getty processes handle the user/id password check. When that is successfull they look in /etc/passwd which shell is the default for the user. That shell is started as login shell. If you started a terminal session from a GUI environment the terminal program would do the same. (Except for the userid/password check as you are obviously already logged on.) –  Tonny Oct 11 '12 at 21:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.