Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What are interactive and non-interactive shell?

Questions: Create a user john who should not get an interactive shell.

How can we do this?

share|improve this question

Regarding the question you are trying to answer:

Create a user john who should not get an interactive shell.

The question means "Create a user named john who won't be able to log in and run commands from a shell". Interactive describe the way the shell works: the user types something, and the shell does something accordingly (there is a kind of communication between the user and the shell). The word "interactive" doesn't really add any information to the question, because as long as there is a user typing commands, the shell session is interactive.

There is also the non-interactive mode, where the user saves a series of commands they want to run in a file (called a shell script), and executes the file afterwards. Some commands behave differently depending on whether the shell is run interactively or non-interactively. You can read more here (this document is for bash, but the same concept applies for other shells).

On how to create such a user, if you skim through man useradd there is an option to set the login shell, -s or --shell. You can also create a user normally, in anyway you want (which I assume you know already?), then edit /etc/passwd like in msw's answer.

share|improve this answer

The /etc/passwd file has as the last item on a user's line the program to be run upon login. For normal users this is typically set to /bin/sh or other shell (e.g. bash, zsh).

Traditionally, identities that are used to own processes or files or other resources have their "shell" set to /bin/false as in


The pseudo-user syslog owns /var/log/syslog and is the only UID which has write permission for that file, but one cannot log in as user syslog as there is no command interpreter to be run.

share|improve this answer

Yes, change the shell in the password file (/etc/passwd) to some program that will not not allow a shell escape.

if you want to be a bofh /bin/false will do exactly what you want.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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