Solved

Linux prompt

Posted on 2004-04-01
12
16,719 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 $ ?
0
Comment
Question by:perlmn
12 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10731631
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
0
 
LVL 24

Expert Comment

by:fridom
ID: 10732195
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
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10735402
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.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 9

Expert Comment

by:majorwoo
ID: 10736182
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###
0
 
LVL 17

Expert Comment

by:owensleftfoot
ID: 10736342
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 10744014
so much fun with a simple prompt :)



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

*SCNR*
0
 

Expert Comment

by:Pizentios
ID: 10784536
your definatly running as root.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 10785110
Pizentios, how would you proof that (except you have been logged in to perlmn's system)?
0
 

Accepted Solution

by:
Pizentios earned 125 total points
ID: 10785273
well, for one, i doubt that red hat would by default make the normal user prompt look like root, unless red hat has gotten stupid since i last used it. Where i come from, # is reserved for the root prompt and all other users use $. I have never seen any normal user have # for a prompt, even users that belong to the wheel group. It'd be nice if we got a reply with more information from perlmn about his system.

Perlmn:

Did you install it yourself? or did sombody else do it for you. If it was sombody else they might have changed your prompt on your normal user account for some reason to look like a root prompt. Although i don't know why they would.

Do you login as root? if so, you should really create a user account and use it instead of always been root, it's much safer. To create a new user account, it's somthing like adduser or somthing like that, although it might be different since i haven't used red hat in quite a few years.
0
 

Author Comment

by:perlmn
ID: 10822674
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



0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 10824787
perlmn, could you please explain how the graded answer helped you to change the prompt?
0
 

Expert Comment

by:Pizentios
ID: 10825239
he didn't need to change the prompt....he was just loged in as root instead of a normal user.


-Pizentios
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to moveā€¦
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question