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?

  • Google: /etc/skel.
    – quanta
    Dec 24, 2012 at 3:27
  • What does echo $PS1 show? Did you su to get root instead of su -?
    – jscott
    Dec 24, 2012 at 3:40
  • @jscott I'm logged into root, and yes I did su. not su - how would I get out of that?
    – Necro.
    Dec 24, 2012 at 3:42
  • ls -a /root/ | egrep '^\.'?
    – quanta
    Dec 24, 2012 at 3:53
  • @Necro Posted an answer, let me know if that helps.
    – jscott
    Dec 24, 2012 at 16:37

7 Answers 7


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

more information:

man bash

  • It's work well and resolve my problem, thank you so much. Mar 23, 2020 at 5:15

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 / corrupt .bashrc file in /root (.bashrc sources /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 /home/directory/user/

cp -v /etc/skel/.bash* ~/             #if logged in as user
cp -v /etc/skel/.bash* /home/user/    #run as root

Should replace the .bash_logout, .bash_profile and .bashrc - exit terminal and log back in. The -bash-4.1# should now be gone!

  • Thank you! I run cp -v /etc/skel/.bash* ~/ as root and worked perfectly!
    – zinon
    May 12, 2017 at 11:34

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 you're using the bash shell. Version 4.1.

  • 1
    How do I get out of this so it will just show [root@hostname]# and my current folder and stuff?
    – Necro.
    Dec 24, 2012 at 3:29
  • 1
    Check the man page and see how you can set your prompt.
    – mdpc
    Dec 24, 2012 at 3:43

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.

  • Please look at my edit.
    – Necro.
    Dec 24, 2012 at 3:32
  • My answer still stands....please do get a shell book if you going to use the bash shell a lot.
    – mdpc
    Dec 24, 2012 at 3:35
  • Okay, I will get a book, but until I do that, how do I revert back to the [root@hostname]# ?
    – Necro.
    Dec 24, 2012 at 3:39
  • What I would say is reexecute the system profile using the '.' command...assumming your system profile provides such a prompt.
    – mdpc
    Dec 24, 2012 at 3:41

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.