1

I've declared an alias in .bashrc file located in my home directory. Export of PS1 environment variable has been added to this file too.

# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell.  There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
        # Shell is non-interactive.  Be done now!
        return
fi


# Put your fun stuff here.
alias ll='ls -l'
export PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \W \$\[\033[00m\] '

However, these changes don't have any effect. I don't have the alias declared in the file after logon. $PS1 isn't affected too. AFAIK user's .bashrc script is sourced by .bash_profile script located in the user's home directory. So I've added the following line to my .bash_profile for testing purposes:

echo hello > ~/test.txt

Here is full content of my .bash_profile file:

# /etc/skel/.bash_profile

# This file is sourced by bash for login shells.  The following line
# runs your .bashrc and is recommended by the bash info pages.
echo hello > ~/test.txt
[[ -f ~/.bashrc ]] && . ~/.bashrc

test.txt doesn't appear in my home directory after logon. It seems that the .bash_profile isn't called during logon.

How to set the system to take user's .bash_profile into account?

chicks
  • 3,793
  • 10
  • 27
  • 36
vect
  • 203
  • 3
  • 6
  • Is your shell a login shell? It means for example logging in from a Linux console (Ctrl+Alt+F1), through ssh: `ssh localhost` or `su -l $USER` etc. – pabouk - Ukraine stay strong Jul 25 '13 at 22:14
  • @pabouk I boot my system in runlevel 3 and then start GUI with `startx` manually if needed. So immediately after boot I definitely have login shell. However, there isn't any sign (alias, environment variable, test.txt file) that my `.bash_profile` script is executed. – vect Jul 26 '13 at 06:25

2 Answers2

3

Could you try to run bash by hand? Simply

bash

for interactive shell which will use .bashrc file and

bash -l

for login shell to test /etc/profile and ~/.bash_profile files.

Additionally, you can try to trace system calls of the bash process with strace utility and to check wether configuration files where opened at least

strace -f -e open bash
strace -f -e open bash -l
chicks
  • 3,793
  • 10
  • 27
  • 36
dsmsk80
  • 5,817
  • 18
  • 22
2

Thank you, dsumsky, for your answer.

Indeed, .bashrc is definitely sourced when I run bash manually. This put in my mind the question "What shell is set as login shell for my user?". It was /bin/sh. The problem has disappeared after I replaced it with /bin/bash despite the fact that /bin/sh symlink is targeted at /bin/bash.

Pierre.Vriens
  • 1,159
  • 34
  • 15
  • 19
vect
  • 203
  • 3
  • 6