Skip to content
Unix Server Solutions
  • Server
  • Apple
  • Database
  • Ubuntu
  • Linux

Ubuntu – why aren’t the bash aliases applied when logging in to server

bashbashrclogin

When I log in to my Ubuntu 12.04 LTS server my bash aliases aren't applied, but if I execute bash from the command line they are.

~/.profile executes ~/.bashrc:

if [ "$BASH" ]; then
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc
  fi
fi

, which in turn executes ~/.bash_aliases:

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

and ps -p $$ shows

31662 pts/0 00:00:00 bash

Do I have something misconfigured?

Best Answer

So the problem was that I had both a ~/.profile and ~/.bash_profile, and ~/.bash_profile (which was added to the system when I installed RVM, which explains why it worked and then stopped working) did not execute ~/.bashrc.

Bash's man page explains that ~/.bash_profile is checked before ~/.profile, and if it exists, ~/.profile is not executed.

Related Solutions

Ubuntu – Root’s .bashrc not executing on sudo -i

You should look at the presence and content of the file /root/.profile.

The init file ~/.bashrc is not sourced in login shells: on Ubuntu it is sourced from ~/.profile

Furthermore, the file /root/.profile is not copied from /etc/skel/ as for other users, it is instead copied from /usr/share/base-files/dot.profile during installation of package base-files.

Ubuntu – I Recently Installed Ubuntu Desktop GUI Over My Ubuntu Server Install and I Broke Some Bash Commands

This smells like a problem with your aliases. You probably have something like

alias ls="ls -h .color=auto"

This is what I have:

alias ls='ls --color=auto'

After changing you need to reload the desktop!

Related Question
  • Ubuntu – Root’s .bashrc not executing on sudo -i
  • Ubuntu – I Recently Installed Ubuntu Desktop GUI Over My Ubuntu Server Install and I Broke Some Bash Commands
  • Ubuntu – Changing behavior of bash prompt when functioning as root
  • Ubuntu – Which files are sourced when using su -c