We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Linux prompt

perlmn
perlmn asked
on
Medium Priority
16,760 Views
Last Modified: 2013-12-06
Hi all,

i m using  RED HAT LINUX 9.0  and it gives me # as default prompt, how can i change it $ ?
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2006

Commented:
Hi perlmn,

In your ~/.bash_profile add a line
PS1=$'[\\u@\\h \\W]\\$
and after that export PS1 ....

on your command prompt execute

. ~/.bash_profile

Sunnycoder
fridomCEO/Programmer
CERTIFIED EXPERT

Commented:
Well it very much looks as if he's working under the root account. I would not want to have  a root shell having the same prompt as  a "normal" user....

Regards
Friedrich
CERTIFIED EXPERT

Commented:
Friedrich is right, there is a reason why the root prompt looks different than a normal prompt. Try to log in as normal user, and see if the prompt you get is different (it very likely is). You should use Sunnycoder's method only to modify the prompt for a normal user, and never for the root user. You need to be able to see right away that you are logged in as root, because you can do a lot more damage to your system as root user. So everytime you see the '#' prompt, be extra careful.

Commented:
my personal favorite is:


###begin .bashrc file###

# Do not set PS1 for dumb terminals
if [ "$TERM" != 'dumb'  ] && [ -n "$BASH" ]
then
        export PS1='\[\033[01;31m\]\u@\h \[\033[01;34m\]\W \$ \[\033[00m\]'
fi

###end .bashrc file###
so much fun with a simple prompt :)



And as I see, most commentators do not cd to
 /this/dirwithalongnameandprobablyapproxiamtely90characterslongwhichwillmakethepromptveryusefull

*SCNR*
your definatly running as root.
Pizentios, how would you proof that (except you have been logged in to perlmn's system)?
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
Hi All

Many thanx to all of you, after your responses, I verified and I came to know that it was really root using # prompt  :-)

thanx again for u r great help



perlmn, could you please explain how the graded answer helped you to change the prompt?
he didn't need to change the prompt....he was just loged in as root instead of a normal user.


-Pizentios
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.