Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

In Ubuntu default .bashrc there's this:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

Does anyone know why that is there? Is there something in the bashrc that is bad to run if the shell is ran non-interactively?

share|improve this question
up vote 3 down vote accepted

The point of the .bashrc file is that it sets the shell up to be more convenient for interactive users. Helpful alias, pretty colors, useful prompts, common environment variables, that sort of thing.

And some of these conveniences could break non-interactive scripts. For example:

`alias rm='rm -i'`

Would not work non-interactively (thanks zwets).

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.