I read multiple articles refering the login shell and non-login shell,
still, I am very confused.
Difference between Login Shell and Non-Login Shell? - Unix & Linux Stack Exchange
The UNIX School: Login shell or a non-login shell?

Put it simple,
the shell I start from my own computer after I power on it,
Isn't it a login shell or non-login shell?

    $ echo $SHELL
    $ echo $0

Additionally, Could you please help to determine taht the shell called from a program is login shell or not?

    import subprocess
    subprocess.run('ls -l', shell=True)
  • 1
    From one of the answers to the above: "# "-" is the first character. Therefore, this is a login shell.", and as for the program, that depends on on the program, doesn't it? – muru Apr 2 '18 at 3:32

As noted in this answer:

prompt> echo $0
-bash # "-" is the first character. Therefore, this is a login shell.

So your first example shows a login shell.

As also noted in the same answer,

Information can be found in man bash (search for Invocation). Here is an excerpt:

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

And from the Python docs:

... Popen does the equivalent of:

Popen(['/bin/sh', '-c', args[0], args[1], ...])

Since the only option given is -c, it's not a login shell.

| improve this answer | |

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