In this tutorial, we'll be exploring how to customize the color of your Bash prompt in Linux. This is a neat trick to personalize your terminal and make certain information stand out. We'll be modifying the ~/.bashrc file, which is a script that runs every time you open a new terminal window.

Step 1: Understanding the Bash Prompt Variable

The Bash prompt is controlled by a special environment variable called PS1. This variable can include a number of special escape sequences, such as:

  • \u - The username
  • \h - The hostname
  • \w - The current working directory

Step 2: Setting the Bash Prompt Color

You can also include color codes in your PS1 variable. Here's an example:

PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

This sets the username and hostname to green (\[\033[01;32m\]) and the current directory to blue (\[\033[01;34m\]).

Step 3: Bash Color Codes

Here are some more color codes you can use:

  • Red: \[\033[0;31m\]
  • Green: \[\033[0;32m\]
  • Yellow: \[\033[0;33m\]
  • Blue: \[\033[0;34m\]
  • Purple: \[\033[0;35m\]
  • Cyan: \[\033[0;36m\]
  • White: \[\033[0;37m\]
  • Black: \[\033[1;30m\]

You can use these color codes to customize your prompt. For example, if you wanted your username and hostname to be in red, your current directory to be in cyan, and your $ prompt to be in yellow, you could set your PS1 variable like this:

PS1='\[\033[0;31m\]\u@\h\[\033[00m\]:\[\033[0;36m\]\w\[\033[00m\]:\[\033[0;33m\]\$\[\033[00m\] '

Remember to use \[\033[00m\] at the end of each color sequence to reset the color back to the default terminal color.

Step 4: Applying the Changes

Once you've modified the ~/.bashrc file, you'll need to apply the changes. You can do this by restarting your terminal session, or you can source the ~/.bashrc file in your current session using the command source ~/.bashrc.


Customizing your Bash prompt color is a simple but effective way to personalize your terminal and make it easier to read. With these instructions, you should be able to set it up in no time. Happy customizing!