For some reason I logged into my CentOS6 server and at the beginning of every line it normally shows
Now it shows
What does this mean? And how to I get it back to normal?
Run this command in your terminal:
export PS1='[\u@\h \W]\$ '
If you want to show this prompt show after you reboot, you can try this (with su):
echo "export PS1='[\u@\h \W]\$ '" > /etc/profile.d/bash_prompt.sh
I had the same issue, here’s how I solved it:
One of two things happened. Either the directory
/root was deleted; or a missing
.bashrc file in
/etc/bashrc, which sets the prompt), you can run the following command to restore the original files (which are copied automatically when the root or any user account is created). Run this command as the user who is having problems OR define the destination path to
cp -v /etc/skel/.bash* ~/ #if logged in as user cp -v /etc/skel/.bash* /home/user/ #run as root
Should replace the
.bashrc - exit terminal and log back in. The
-bash-4.1# should now be gone!
Per your comment, it sounds like you've done a
su, to switch to the root user, rather than
su -. The trailing
- will make the shell a login shell, without it you may notice your root user environment is "off".
To exit the
su session, just type
exit Enter or press ctrl + d. Then re-enter the session using
su -. See the man page,
man su, for more details.
It means that in one place your command prompt was changed by the contents of .profile (or the system profile)....in the second case, your prompt was not changed.
BTW, what is "normal". In my opinion, the default of the application (the second entry) is normal. As in other things "normal" means different things to different people. In UNIXland there are so many ways of doing things, a tag like this really has no meaning.
I'd strong suggest you closely study the man page or look for a good book on bash.
Did you by any chance try and edit your .bashrc file?
There is a backup copy located here:
To restore root run this:
cp /etc/skel/.bashrc /root/.bashrc
seems like all of these people did not know how to actually get the prompt to go BACK to showing [root@domain]~#
I find it hard to believe he did not get a straight answer to his question. Because I am looking for that very same answer.
%userx@voided ~>>$cat /etc/skel/.bashrc # .bashrc # If not running interactively, don't do anything [[ $- != *i* ]] && return alias ls='ls --color=auto' PS1='[\u@\h \W]\$ '
does not change the prompt to indicate root when one uses su - password to switch to root. mine only shows #
when it use to do the same.