My user's shell prompt is stuck as

and many useful commands like ll don't work on that bash-4.2 shell.

I tried the chsh command and usermod commands, but neither fixed this.

I've checked in the /etc/passwd file, the shell associated with my user is /bin/bash. The other users too have the same lines but those users are presented with the normal bash prompt:

[vin@localhost ~]$

My ~/.bash_profile is

# .bash_profile

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

# User specific environment and startup programs


export PATH

I've noticed that when I log into my user vin through the root or an another account that has the normal bash, it stays on that bash type, doesn't get back to the broken bash.

What could be wrong? Does anyone know how to fix this?

  • 1
    Have you messed with your ~/.bashrc or ~/.bash_profile files? – steeldriver Dec 21 '15 at 13:56
  • What do you want the shell to be? – David King Dec 21 '15 at 13:56
  • @steeldriver no, I haven't, as far as I remember. – vin Dec 21 '15 at 14:00
  • @DavidKing I want it look like the usual [user@localhost ~]$ . Currently it looks like "bash-4.2$" on which many useful commands don't work. – vin Dec 21 '15 at 14:02
  • 1
    ll isn't a command, it's a shell alias to run the ls command with certain options. The appearance of the prompt (whether it's bash-4.2 or vin@localhost) isn't really indicative of anything except the setting of the PS1 variable. Both these things are likely determined by the contents of your ~/.bashrc file: that's where you should start to look for what could be wrong. – steeldriver Dec 21 '15 at 14:17

This: [bash-4.2]$ is called the "shell prompt", not the "shell name".

The shell prompt in Bash is stored in an ordinary shell variable called PS1. The contents of PS1 is a prompt format string which consists of a mixture of ordinary text, plus special codes like \h to insert the host name, \w to insert the working directory or \$ to insert the character # if the user is root or $ otherwise. For instance:

PS1='\h:\w\$ '

Now your prompt looks like:

machinename:/path/to/where/you/are$ _

The underscore represents the cursor. According to the man page for recent versions of Bash, the default value of PS1 is \s-\v\$, which produces the shell name, a literal dash, the shell version and a prompt not followed by a space: exactly what you're seeing.

Read the Bash man page, and skip to the section PROMPTING to read all about this topic.

The other users have a nicer prompt because of some configuration difference between your account and theirs. You might be missing some configuration files like ~/.bash_profile and ~/.bashrc, or PS1 is not configured in these files. Perhaps your account doesn't have a correct home directory at all.

The chsh command changes your login shell entirely, as in using a different program. This is the tool to use if you don't want to use Bash at all, but something else like Zsh or Tcsh. It will not take place in the calling session; it affects a new login session.

|improve this answer|||||
  • When I set the value of PS1, the bash prompt (thanks for telling me about the proper term) changes but it's temporary. When I launch the terminal again, it goes back to bash-4.2 . I added the PS1's value to bashrc file, it seems that some other settings are overriding the bashrc content, because this works well with other users. – vin Dec 23 '15 at 10:18

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.