i92guboj |
11-05-2008 10:32 PM |
Quote:
Originally Posted by Tim356
(Post 3328919)
What is the difference between an interactive shell and a non-interactive shell? And how can you make sure a user does not have an interactive shell?
|
I think that the other user above already answered that. However, I really advice you to read the INVOCATION section of the bash man page if you haven't yet (if you have already then that's almost everything about it).
A tipical interactive shell presents you a prompt where you can enter commands and read the output. Technically speaking, all of stderr, stdout and stdin are connected to a tty-like interface.
On the contrary, when the shell's non-interactive you can't -well- interact with it. A tipical example is when you run a script. That script is run into a non-interactive shell, which in bash can be checked echoing the contents of $- and checking that "i" is not present on that string.
About the user. Well. It depends on what do you mean. A non interactive shell wouldn't be of much use for a human user unless it's used to launch anything else. Try to explain a bit better what do you mean or what do you try to achieve.
Quote:
Originally Posted by Tim356
(Post 3329021)
Would simply removing the reference to the particular shell for a specific user in the /etc/passwd file achieve the same thing?
|
If you remove the shell, the sh will be used since it's the default. That has nothing to do with the shell being interactive or not.
Quote:
Originally Posted by Tim356
(Post 3332338)
I'm actually doing some study - and in a lab question I have (which unfortunately offers no explanation) the question states "Create users x, y and z. Ensure user x can only login with a non-interactive shell."
Therefore /sbin/nologin and /bin/false will not work in this example as I need to be able to login with the user.
|
I really don't get what they mean, unless they are asking you to use a silly thing like a script that does whatever and then exits or sits there forever. There's no easy way to interact with a non-interactive shell, at most you can interact with your script which might be a menu, or launch another shell (interactive one) or whatever. I really don't get the point of that question.
If that's what they want, you could just use startx as your shell. That will guarantee that a non-interactive shell will be run.
|