I asked this question some time ago about the shell does not displaying the path. Recently I found out that the .bashrc does not get sourced (and this should be a normal practice?). Currently, the shell command prompt is like this:


after I executed source .bashrc, I am able to obtain my expected shell command prompt:


where ubuntu2011 is the machine name. How can I make the prompt looks like the latter one every time I login?

p.s. the .bashrc is from: cp /etc/skel/.bashrc ~/.bashrc

UPDATE: the contents of ~/.profile is as follow:

# ~/.profile: executed by Bourne-compatible login shells.

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

mesg n

and echo $BASH returns /bin/bash

UPDATE: Answers of @terdon's questions:

  1. How do I login to server?

I use ssh root@111.222.333.444 to login as root

  1. Are those command executed as root?


UPDATE: The output of ls -l ~/.{profile,bashrc,bash_profile,bash_login}:

ls: cannot access /root/.bash_login: No such file or directory
-rw-r--r-- 1 root root   63 Dec 24  2012 /root/.bash_profile
-rw-r--r-- 1 root root 3637 May 17 17:00 /root/.bashrc
-rw-r--r-- 1 root root  140 Apr 23  2010 /root/.profile
  • open ~/.profile, write . /home/me/.bashrc
    – 123
    May 17, 2016 at 9:42
  • @123 is it a normal practice to do so? I have several Ubuntu servers, but none requires me to do so .
    – Raptor
    May 17, 2016 at 9:48
  • Normally ./profile sources /etc/profile, which sources /etc/bash.bashrc and $HOME/.bashrc but evidently something is not working on your server. You can just skip all that though and use you local .bashrc and .profile.
    – 123
    May 17, 2016 at 9:52
  • 1
    @123 not quite: ~/.profile does not source /etc/profile and /etc/profile does not source ~/.bashrc. Bash itself will read some of these files depending on how it's being run. See man bash or Difference between Login Shell and Non-Login Shell? or Difference between .bashrc and .bash_profile or Scripts in /etc/profile.d Being Ignored?.
    – terdon
    May 17, 2016 at 9:57
  • 1
    @Raptor after i executed source .bashrc, given that this doesn't have the ~/, just to clarify you are sourcing the same bashrc, not some random one in your PATH ?
    – 123
    May 17, 2016 at 10:18

2 Answers 2


This happens because you are logging in through ssh. It comes down to the differences between login and non-login shells. When you connect via ssh, you run a login interactive shell. As explained in man bash, this sort of shell will:

When bash is invoked as an interactive login shell, or as a non-inter‐ active shell with the --login option, it first reads and executes com‐ mands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.

In other words, ~/.bashrc is ignored by default when running login shells. The simple solution is to explicitly source it from one of the files that are read. As you can see above, login shells will first try to read ~/.bash_profile, and if that doesn't exist ~/.bash_login, and if that also doesn't exist, they read ~/.profile. Since you have a ~/.bash_profile file, you will need to add these lines to it:

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

Put this in your ~/.profile

if [ -f ~/.bashrc ]; then
    . ~/.bashrc
  • it's already in the .profile. I've updated the question to show the contents of the .profile
    – Raptor
    May 17, 2016 at 9:47
  • 1
    @Raptor you really need to tell us how you are logging in to the machine. That's what makes the difference.
    – terdon
    May 17, 2016 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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