I stupidly managed to delete my /root folder on CentOS. I re-created an empty /root folder and set root privs to it, but now my shell string in PuTTY is different.

Whereas it used to say [root@servername ~]$, now it just says -bash-4.1#.

What has happened? Have I deleted anything important inside /root? How can I restore the previous string?

  • This is a reminder of why good, accessible backups are important. But of course, you already knew that. ;-) – depquid Apr 2 '13 at 21:25

You probably deleted a .bashrc or .bash_profile file - these are hidden by default from ls. You could create a new .bashrc in /root with something like PS1='[\u@\h \W]\$, which would give you something similar to what you lost.

If you would like to get /root set up much the same as the initial install, instead of creating an empty /root you could cp -a /etc/skel /root - this would copy over all of the default user account files, which is likely what your distro does during the initial install. These files would include a .bash_profile, etc, specific to the distro.

  • Ah awesome. Can I copy this from one of my other user accounts (which still do have the correct shell string)? Or is there something "special" about root's? – WackGet Apr 1 '13 at 4:35
  • I've noticed that it tends to be slightly different from the /home/<user>/ files, but the default configuration is pretty distribution specific. – Iiridayn Apr 1 '13 at 4:37
  • Well it certainly worked. Thanks so much. I'll accept the answer as soon as it's possible to do so. – WackGet Apr 1 '13 at 4:39

For CentOS 6 I added back 2 default files of .bashrc and .bash_profile with the following:

-bash-4.1# vim .bashrc

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc

-bash-4.1# vim .bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc

# User specific environment and startup programs


export PATH

Now mine looks correct [root@bvdirect-db-dev ~]#

Hope this helps!

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.