Difference between normal shell and login shell
What is the difference between running a shell (e.g. bash) as a normal shell VS as a login shell (with the option -login, or prefixing hyphen to its sym. link) ??
Thanks. |
I don't understand your question. I thought a shell was a shell, either using bash, sh, csh, tcsh... etc etc... logging in or already logged in..
-trickykid |
You can invoke bash as a login shell or as an interactive shell. From the man page:
Quote:
|
Thanks jeremy. :)
|
I didn't understand the docs either
Login shell is the first one you run when you 'log in': when you sign in on a SSH session, or add a new terminal emulator window or tab. To check:
$ echo $0 -bash $ ps 456 ttys006 0:00.22 -bash 459 ttys007 0:03.81 bash 1633 ttys008 0:00.03 bash 10935 ttys009 0:00.07 -bash -bash = login shell, bash = not login. processes 456 and 10935 are login shells. Interactive shell is when you type in 'bash' from your login or another interactive shell. and stdin and stdout are terminals.To see if yours are terminals (they probably are if you're typing in), run these: $ [ -t 0 ] && echo stdin is a tty $ [ -t 1 ] && echo stdout is a tty The $- env var tells you what options your shell runs in. i=interactive. for example: $ echo $- himBH that one had stdin=terminal, this one has a pipe as stdin: $ echo 'echo $-' | bash hB Login shell runs .profile (or .bash_profile or .bash_login) on startup. Set your env variables in there, cuz sub-shells will inherit the env vars. Then make .profile run your .bashrc: . .bashrc Interactive runs .bashrc . Since it inherits envs, but not aliases, put your aliases in this file. Shell scripts, cron jobs, and the like, run with a bare shell: no bashrc or profiles are run. No kidding you get 4 env vars set, the bare minimum. Therefore your PATH won't work very well so you often have to give an abs pathname like in crontab: right: 0 0 * * 2 /usr/sbin/apachectl restart wrong: 0 0 * * 2 apachectl restart |
> whose first character of argument zero is a -
That will make most sense to C programmers who know the variable argv[] as given to the main() function. |
This option is used to tell Bash how it's supposed to behave. When you log in successfully, getty execs the specified shell-program to give you the command prompt. This shell instance (which replaces "getty") will be the root of all other processes in your session, and as such it needs to look and behave a little differently.
|
Quote:
|
All times are GMT -5. The time now is 05:03 PM. |