I accidentally deleted my /root folder and now my shell string is different. What gives?
Solution 1
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.
Solution 2
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
fi
-bash-4.1# vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
Now mine looks correct [root@bvdirect-db-dev ~]#
Hope this helps!
Related videos on Youtube
WackGet
Updated on September 18, 2022Comments
-
WackGet almost 2 years
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?-
depquid about 11 yearsThis is a reminder of why good, accessible backups are important. But of course, you already knew that. ;-)
-
-
WackGet about 11 yearsAh 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?
-
Iiridayn about 11 yearsI've noticed that it tends to be slightly different from the
/home/<user>/
files, but the default configuration is pretty distribution specific. -
WackGet about 11 yearsWell it certainly worked. Thanks so much. I'll accept the answer as soon as it's possible to do so.