Re: Interactive vs non-interactive shell for users

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dan G wrote:
> 
> I understand that a shel like /bin/bash is interactive since it
> provides login and command execution for the user. What happens if
> you set a user's login shell to a non-interactive shell like /bin/sh.
> Does this allow script execution and login but no command execution?

There's a misconception here: /bin/sh is very well an interactive shell
(actually it was the very first shell, as old as Unix itself). On most
Linux systems it really is a symlink pointing to /bin/bash.

An interactive shell interacts with the user. If it's a login shell, any
commands in ~/.login are executed, if it's not a login shell (you can
spawn interactive subshells) .login is not evaluated.

A non-interactive shell does not interact with the user, but works a
shell script. Whenever you invoke a shell script, the very first line
(the "shebang" #!/bin/bash) spawns a non-interactive subshell. All
non-interactive shells are no login shells, thus they do not evaluate
.login.

For a more detailed discussion about interactive, login and
non-interactive shells see the man pages of the shell you use, like
man sh
man bash
man csh
man tcsh
man ksh
man ash

Conclusion: Any shell a user can log into is per definitionem an
interactive shell. If it wasn't (like /bin/false or /bin/nologon) the
user couldn't log in.

Best regards,
Martin Stricker
-- 
Homepage: http://www.martin-stricker.de/
Linux Migration Project: http://www.linux-migration.org/
Red Hat Linux 7.3 for low memory: http://www.rule-project.org/
Registered Linux user #210635: http://counter.li.org/



-- 
Psyche-list mailing list
Psyche-list@redhat.com
https://listman.redhat.com/mailman/listinfo/psyche-list

[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux