{"id":4697,"date":"2016-02-16T10:09:44","date_gmt":"2016-02-16T10:09:44","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=4697"},"modified":"2016-09-30T13:29:12","modified_gmt":"2016-09-30T13:29:12","slug":"interactive-vs-login-shell","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=4697","title":{"rendered":"Interactive vs. Login Shell"},"content":{"rendered":"<p><a href=\"http:\/\/unix.stackexchange.com\/questions\/50665\/what-is-the-difference-between-interactive-shells-login-shells-non-login-shell\">What is the difference between interactive shells, login shells, non-login shell and their use cases?<\/a><br \/>\n<a href=\"http:\/\/unix.stackexchange.com\/questions\/38175\/difference-between-login-shell-and-non-login-shell\"><\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/18186929\/differences-between-login-shell-and-interactive-shell\">differences between login shell and interactive shell<\/a><br \/>\n<a href=\"http:\/\/superuser.com\/questions\/657848\/why-do-we-have-login-non-login-interactive-and-non-interactive-bash-shells\">Why do we have login, non-login, interactive, and non-interactive bash shells?<\/a><br \/>\n<a href=\"http:\/\/serverfault.com\/questions\/8882\/what-is-the-difference-between-a-login-and-an-interactive-bash-shell\">What is the difference between a &#8216;Login&#8217; and an &#8216;Interactive&#8217; bash shell<\/a><\/p>\n<p><strong>Interactive:<\/strong> 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.<\/p>\n<p><strong>Non-interactive:<\/strong> the shell is probably run from an automated process so it can&#8217;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.<\/p>\n<p><strong>Login:<\/strong> 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.<\/p>\n<p><strong>Non-login:<\/strong> 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.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nUSER       PID TTY    COMMAND\r\nroot       723 ?      \/usr\/sbin\/sshd -D\r\nroot      1023 ?       \\_ sshd: andreas &#x5B;priv]\r\nandreas   1062 ?       |   \\_ sshd: andreas@pts\/0\r\nandreas   1063 pts\/0   |       \\_ -bash\r\nroot      1320 pts\/0   |           \\_ sudo -s\r\nroot      1321 pts\/0   |               \\_ \/bin\/bash\r\nroot      1456 pts\/0   |                   \\_ ps auxf\r\nroot      1271 ?       \\_ sshd: andreas &#x5B;priv]\r\nandreas   1307 ?           \\_ sshd: andreas@pts\/1\r\nandreas   1308 pts\/1           \\_ -bash\r\nroot       760 ttyS0  \/bin\/login --\r\nandreas    849 ttyS0   \\_ -bash\r\nandreas   1464 ttyS0       \\_ bash\r\n<\/pre>\n<p>A login shell is the first process that executes under your user ID when you log in for an interactive session. The login process tells the shell to behave as a login shell with a convention: passing argument 0, which is normally the name of the shell executable, with a &#8211; character prepended (e.g. -bash whereas it would normally be bash.<\/p>\n<h3>sudo<\/h3>\n<p>see also here:<br \/>\n<a href=\"http:\/\/blog.bachi.net\/?p=5265\">blog.bachi.net: bashrc vs. bash_profile<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n   &#x5B;...]\r\n\r\n     -i, --login\r\n                 Run the shell specified by the target user's password data-\r\n                 base entry as a login shell.  This means that login-specific\r\n                 resource files such as .profile or .login will be read by the\r\n                 shell.  If a command is specified, it is passed to the shell\r\n                 for execution via the shell's -c option.  If no command is\r\n                 specified, an interactive shell is executed.  sudo attempts\r\n                 to change to that user's home directory before running the\r\n                 shell.  The command is run with an environment similar to the\r\n                 one a user would receive at log in.  The Command environment\r\n                 section in the sudoers(5) manual documents how the -i option\r\n                 affects the environment in which a command is run when the\r\n                 sudoers policy is in use.\r\n\r\n   &#x5B;...]\r\n\r\n     -s, --shell\r\n                 Run the shell specified by the SHELL environment variable if\r\n                 it is set or the shell specified by the invoking user's pass-\r\n                 word database entry.  If a command is specified, it is passed\r\n                 to the shell for execution via the shell's -c option.  If no\r\n                 command is specified, an interactive shell is executed.\r\n\r\n   &#x5B;...]\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>What is the difference between interactive shells, login shells, non-login shell and their use cases? differences between login shell and interactive shell Why do we have login, non-login, interactive, and non-interactive bash shells? What is the difference between a &#8216;Login&#8217; and an &#8216;Interactive&#8217; bash shell Interactive: As the term implies: Interactive means that the commands [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4697","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4697"}],"version-history":[{"count":6,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4697\/revisions"}],"predecessor-version":[{"id":5267,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4697\/revisions\/5267"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}