Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For some reason I logged into my CentOS6 server and at the beginning of every line it normally shows

[root@hostname]# 

Now it shows

-bash-4.1#

What does this mean? And how to I get it back to normal??? I'm very new to CentOS...

share|improve this question

migrated from serverfault.com Dec 24 '12 at 16:49

This question came from our site for system and network administrators.

    
Google: /etc/skel. – quanta Dec 24 '12 at 3:27
    
What does echo $PS1 show? Did you su to get root instead of su -? – jscott Dec 24 '12 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 '12 at 3:42
    
ls -a /root/ | egrep '^\.'? – quanta Dec 24 '12 at 3:53
    
@Necro Posted an answer, let me know if that helps. – jscott Dec 24 '12 at 16:37

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

share|improve this answer
    
Thanks a lot... friend – K.K Patel Jul 15 '13 at 13:10

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.

share|improve this answer

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!

share|improve this answer
    
Works for me !! Thanks!! – rammayur Jul 12 '15 at 11:47
    
Works for me too. Thanks! – kd0807 Jul 14 '15 at 4:49
    
Thank you very much. it works – Manoj Singh Jul 14 '15 at 10:16

It means you're using the bash shell. Version 4.1.

share|improve this answer
    
How do I get out of this so it will just show [root@hostname]# and my current folder and stuff? – Necro. Dec 24 '12 at 3:29
    
Check the man page and see how you can set your prompt. – mdpc Dec 24 '12 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.

share|improve this answer
    
Please look at my edit. – Necro. Dec 24 '12 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 '12 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 '12 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 '12 at 3:41

Did you by any chance try and edit your .bashrc file?

There is a backup copy located here:

/etc/skel/.bashrc

To restore root run this:

cp /etc/skel/.bashrc /root/.bashrc
share|improve this answer

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.

share|improve this answer

protected by Community Jan 22 at 8:17

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?