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:
-bash-4.3#
after I executed source .bashrc, I am able to obtain my expected shell command prompt:
root@ubuntu2011:~#
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
fi
fi
mesg n
and echo $BASH returns /bin/bash
UPDATE: Answers of @terdon's questions:
- How do I login to server?
I use
ssh root@111.222.333.444to login asroot
- Are those command executed as root?
Yes.
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
~/.profile, write. /home/me/.bashrc– 123 May 17 '16 at 09:42./profilesources/etc/profile, which sources/etc/bash.bashrcand$HOME/.bashrcbut evidently something is not working on your server. You can just skip all that though and use you local.bashrcand.profile. – 123 May 17 '16 at 09:52.profile? – 123 May 17 '16 at 09:57~/.profiledoes not source/etc/profileand/etc/profiledoes not source~/.bashrc. Bash itself will read some of these files depending on how it's being run. Seeman bashor 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 '16 at 09:57test -z "$PROFILEREAD" && . /etc/profile || trueis the first line of my default setup of./profile– 123 May 17 '16 at 09:59.profilecontents. – Raptor May 17 '16 at 10:10~/.profile sets LANG variable, sources /etc/profile, iF it has not already been run (checks PROFILEREAD variable), sources ~/.bashrc, runs the fortune program if you uncomment it.from suse documentation. Maybe, dunno, don't think I'm "completely" wrong though. – 123 May 17 '16 at 10:11after 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 '16 at 10:18