How can i change my bash prompt ?

It looks like,

user@hostname:/auto/home3/user$

Desired,

user@hostname$

I added following line in .bashrc, but still its same.

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

Please help me :confused:

Hello!

Per forum rules, and the benefit of all users, please search the forums before posting a question.

You can easily search the forums using our internal Google search engine or our advanced internal search engine. You can also search our huge UNIX and Linux database by user generated tags or search the database for unanswered questions and provide an answer.

Search for prompt

Thank you.

The UNIX and Linux Forums

I searched it in the forum.
and i found the the thread but its not working in my case thats why i have posted it again.

http://www.unix.com/unix-dummies-questions-answers/123982-change-user-user-host-ssh-prompt.html\#post302372298

Sorry

kindly provide the contenant of the ".bashrc" file.

cat .bashrc

# .bashrc
export PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] '

#-------------------
# Personnal Aliases
#-------------------

alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'
alias xzgv='xzgv -arz'
export GREP_OPTIONS='--color=auto'
#The following command is dangerous, it results into all sorts of unexpected and unsuspected behaviour
#export GREP_OPTIONS='--color=always'
#export GREP_COLOR='1;32'
alias grep='grep -E'
export LESS=-R
alias du='du -kh' # Makes a more readable output.
alias df='df -kTh'

#To have manpages in colours
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'

# Options for ls to be colorized
export LS_OPTIONS='--color=auto'
eval `dircolors`
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'

ulimit -s unlimited
#case $TERM in
#xterm*)
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
# ;;
#screen*)
# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD}\007\033k$PWD\033\\"'
# ;;
#*)
# ;;
#esac

#-------------------------------------------------------------
# spelling typos - highly personnal and keyboard-dependent :slight_smile:
#-------------------------------------------------------------

alias xs='cd'
alias vf='cd'
alias moer='more'
alias moew='more'
alias kk='ll'

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

# aliases that use xtitle
alias top='xtitle Processes on $HOST && top'
alias make='xtitle Making $(basename $PWD) ; make'
alias ncftp="xtitle ncFTP ; ncftp"

Ok, check this link (found with Google):

Bash and Bash Prompts

Also check your .bash_profile. This usually calls your .bashrc.

Is PS1 being set in there, after you've called .bashrc?

And .bash_login and .profile are called after that, so check them too.

Is the below files exist in the below condition or not , and is it /etc/bashrc or /etc/.bashrc

if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

and if exist kindly submit cat /etc/bashrc

therefore, edit your .bash_profile to call .bashrc and you will always execute .bashrc from any "style" of login.

I checked .bash_profile it is not set.
this is my .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
unset USERNAME
.............................................................................

still i have the same prompt :confused:

---------- Post updated at 08:25 PM ---------- Previous update was at 08:22 PM ----------

does not exists.

Try putting the PS1=... at the end of your .bashrc script?

Thanks to all of u.

i commented few lines in bashrc now i am getting my desired prompt.

----------------------------------------------------------------------------------------------------
#if [ -f /etc/bashrc ]; then
# . /etc/bashrc
#fi
#if [ -f /etc/bash.bashrc ]; then
# . /etc/bash.bashrc
#fi
----------------------------------------------------------------------------------------------------

But still i have a question

What is the need of bashrc in /etc/ ?
means what is the role ? :confused:

you are using the file /etc/.bashrc not the one in your home as the ~/.bashrc is saying

and I asked you if /etc/.bashrc is exist or not and I didn't get the answer yet
(kindly note the "." before the word bashrc)

your ~/.bashrc is excuting the code /etc/.bashrc when you login.(not good)

when your ~/.bashrc is removed you need to modify your ".bash.profile" in a way that is to use the /etc/.bashrc when you lose your ~/.bashrc (somehow) kindly see below:-

add this condition to your .bashrc.profile and remove it from your ~/.bashrc:-

if [ -f $HOME/.bashrc ]; then
 . $HOME/.bashrc
else
. /etc/.bashrc
fi


I made modifications in my .bash_profile.

:slight_smile: