Bash – Why when I ssh into one server it shows bash and the other have the username

bashcommand linerhel

So at work I have two web servers that I am able to ssh into.

Both are RHEL 6.5

When I log into one, it shows this:

[username@ldvweb01 /]$ 

When I log into the other one it shows:

-bash-4.1$ 

I find it way more elegant when it shows the first one. How do I switch between the two? Can someone explain this to me?


After running this echo $PS1 these are the results

-bash-4.1$ echo $PS1
\s-\v\$

and

[appadmin@ldvcatweb01 /]$ echo $PS1
[\u@\h \W]\$

After checking for the differences between both home directories. I found that there was no .bashrc or .bash_profile in the home directory.

So I copied the ones from the previous server.

# .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

and

# .bashrc

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

# User specific aliases and functions

I am guess that it just pulls the default bash settings from /etc

Thanks for all your help.

Best Answer

The bash prompt is configured by the PS1 environment variable. You can get the prompt you desire by adding

export PS1="[\u@\h \W]\$ "

to your .bashrc file (located in your user's home directory).

The full list of special characters that you can use for your prompt can be found in the official Bash documentation.

Related Question