| Subcribe via RSS

Customizing Bash Prompt

June 25th, 2007 Posted in RevTI, System Administration


I install several servers 2 days ago, what I found after I login to SSH is that the bash prompt is different with my older server, it only show “bash-3.1#” instead of “[username@servername – directory] $”

I found “bash-3.1#” is difficult as I don’t know my current directory location. With a little bit Google search I get an answer.

You can customize your bash prompt by creating a file named .bash_profile (there is a “dot” in front of the filename)

Insert this code in .bash_profile file:

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

now your bash prompt will look like this:

[user@localhost /home/user]$

Most Commented Posts

2 Responses to “Customizing Bash Prompt”

  1. Willy Sudiarto Raharjo Says:

    The problem is when you are in a deep directory structure, your prompt will be bloated :D


  2. Markus Says:

    yes, you are correct. but I never go deeper than 10 subdirectory (as far as I remember)

    in the case you’ll go to a very deep directory i think you can run this command to make your bash prompt shorter:

    PS1="[u@h]$ "

    your bash prompt should be look like this:

    [user@localhost]$

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word