LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
LinkBack Search this Thread
Old 02-24-2002, 05:10 AM   #1
Manish
Member
 
Registered: Feb 2002
Distribution: Debian / Debian-based
Posts: 58

Rep: Reputation: 15
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.
 
Old 03-09-2002, 02:17 PM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,121

Rep: Reputation: 121Reputation: 121
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
 
Old 03-09-2002, 03:25 PM   #3
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 9,110

Rep: Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401Reputation: 2401
You can invoke bash as a login shell or as an interactive shell. From the man page:

Quote:
A login shell is one whose first character of argument zero is a -, or one started with the -login flag.

An interactive shell is one whose standard input and output 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.

Login shells:
On login (subject to the -noprofile option):
if /etc/profile exists, source it.

if ~/.bash_profile exists, source it,
else if ~/.bash_login exists, source it,
else if ~/.profile exists, source it.

On exit:
if ~/.bash_logout exists, source it.

Non-login interactive shells:
On startup (subject to the -norc and -rcfile options):
if ~/.bashrc exists, source it.

Non-interactive shells:
On startup:
if the environment variable ENV is non-null, expand
it and source the file it names, as if the command
if [ "$ENV" ]; then . $ENV; fi
had been executed, but do not use PATH to search
for the pathname. When not started in Posix mode, bash
looks for BASH_ENV before ENV.

If Bash is invoked as sh, it tries to mimic the behavior of sh as closely as possible. For a login shell, it
attempts to source only /etc/profile and ~/.profile, in that order. The -noprofile option may still be used to
disable this behavior. A shell invoked as sh does not attempt to source any other startup files.
--jeremy
 
Old 03-09-2002, 10:02 PM   #4
Manish
Member
 
Registered: Feb 2002
Distribution: Debian / Debian-based
Posts: 58

Original Poster
Rep: Reputation: 15
Thanks jeremy.
 
  


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between Console, Shell, and Command Prompt Anupam Pathak Linux - Newbie 3 10-23-2005 04:40 AM
difference between shell scripting and c language gadekishore Linux - Software 5 10-17-2005 06:33 AM
Is there any difference between 2 shell scripts? tradewind Linux - Newbie 5 06-07-2004 07:52 PM
shell text fonts are larger than normal??? tsw Mandriva 8 05-12-2004 07:01 PM
difference of shell redragon7964 Linux - Newbie 2 04-06-2004 02:20 AM


All times are GMT -5. The time now is 10:01 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
Open Source Consulting | Domain Registration