I am working on a Redhat server and one of the users' names appears as "bash-3.0" on the "SSH Secure Shell Client."
His name is appearing correct under /etc/passwd
. How could this happen?
How can I fix this?
Is the user's default shell different than the others? (also in /etc/passwd
) This could be the potential cause.
You get a "bash" prompt when launching bash in your terminal without configuring a custom prompt. Since it's just happening to one user, they might have a different login shell than the others or they may be launching bash in a login script or at the terminal.
If the default shell is fine (matching other users) then try determining if the .bashrc
or .bash_profile
is different than what's in the home folder of other users? ( Could also be ~/.profile
, ~/.zprofile
or ~/.login
depending on what you use ... )
it was solved after restoring the files (.bashrc and .bash_profile) from /etc/skel/, it seems that they were deleted by mistake
The reason why you saw bash version instead of the username after the profile files were deleted was that the command prompt (often containing the username) is set in these files. You would see exactly the same after calling bash --norc
.
Interestingly, no command prompt is set in your /etc/profile, which is often the case on modern systems; usually, you have something like
if [ "$PS1" ]; then if [ "$BASH" ]; then PS1='\u@\h:\w\$ ' if [ -f /etc/bash.bashrc ]; then . /etc/bash.bashrc fi else if [ "`id -u`" -eq 0 ]; then PS1='# ' else PS1='$ ' fi fi fi
$PS1
) appears to be'\s-\v\$ '
, where\s
expands to the name of the shell and\v
expands to the version.\u
expands to the username. See the documentation.