[maemo-users] .bashrc not executed

From: Dave Neary dneary at maemo.org
Date: Wed Jun 23 17:57:12 EEST 2010

Jérôme Bove wrote:
> I'd like to edit my .bashrc file. So i edit it (vi /home/user/.bashrc)
> and save. When I open X-Terminal or connect via ssh to user (not root),
> the bashrc is not executed.
> If I do su user, then bashrc is executed.
> I installed bash and edit my /etc/passwd file for user to use bash.
> What should I do for bashrc to be executed ?

To develop on what Alejandro said, when bash starts, it reads the
following, in this order:

(some approximate definitions: a login shell is when you start bash from
a login prompt, an interactive shell is when you're able to run commands
interactively, as opposed to starting bash for a shell script)

If bash is started as an interactive login shell:
 * Read and execute /etc/profile (if the file exists)
 * Search for ~/.bash_profile, ~/.bash_login, ~/.profile in that order
and read and execute the first one it finds

When a login shell exits:
 * Read and  execute ~/.bash_logout, if it exists.

If started as an interactive, non-login shell (eg. run directly as
 * Read and execute /etc/bash.bashrc and ~/.bashrc, if they exist.

If started  non-interactively in a shell script:
 * Expand BASH_ENV environment variable, and read and execute the file
in it, if it exists

According to the Bash manpage, if started from a network log-in:
 * Read and execute /etc/bash.bashrc and ~/.bashrc, if they exist.

I just tested, for an SSH-launched shell, only .bash_profile got run for
me, not .bashrc

Here on my laptop, the default .bash_profile contains

if [ -f ~/.bashrc ]; then
  . ~/.bashrc;

which basically says that .bashrc will get executed for every login
shell, as well as non-login shells.


maemo.org docsmaster
Email: dneary at maemo.org
Jabber: bolsh at jabber.org

More information about the maemo-users mailing list