Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I change the default prompt in Linux (red-hat 5.4) from "#" to ">"? example

[root@moon11 root]# 


[root@moon11 root]> 
share|improve this question

migrated from Dec 15 '11 at 8:19

This question came from our site for professional and enthusiast programmers.

Note that it is conventional to keep a # in the prompt to remind you that you are playing with fire because you have root privileges and any mistakes can completely wreck the machine. You should always do as little as possible while running as root. – Jonathan Leffler Dec 15 '11 at 8:21

This is defined in your ~/.bashrc file in the variables PS1 and PS2. Find their values and change # to > . Take a look at bash variables and controlling the prompt.


In my ~/.bashrc file if I change

    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '


    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\> '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\> '

it does the job.

share|improve this answer
see edit in my answer. – hovanessyan Dec 15 '11 at 8:52

My answer: Don't do it !

The fact root's prompt is by default # has a very useful side effect. It happens from time to time that people logged as root copy and paste what is on their screen by error. The default prompt makes that operation less risky by preventing the pasted commands to be executed again.

If you change your prompt to >, instead of commenting out the commands, that would run your prompt prefix as a command (likely a not found one) but redirect anyway its output to what used to be the command to execute, essentially blanking the file. Should you gave a file name that happens to be in the current directory (eg: passwd) or the full path of a sensitive binary and you are in serious trouble.

share|improve this answer
Nice info! However, this should probably be a comment! – BloodPhilia Dec 15 '11 at 13:46
Agreed. I hesitated but finally opted for a reply for it to have a better visibility than a mere comment. I once had to investigate a bricked OS, was first surprised to see plenty of commands no more giving any output and finally found the root cause in root's history ... – jlliagre Dec 15 '11 at 16:29
While I do agree with everything you say, it's still not an answer... Please do post it as a comment next time. The OP will receive a notification of your comment. – BloodPhilia Dec 15 '11 at 16:32

Keeping in mind the other answers' recommendation to avoid reducing root's visibility, here's a useful guide to bash prompt editing that a college associate made many years ago: Bash Prompt HowTo

share|improve this answer

You must log in to answer this question.