How To Change Bash Prmpt Rhel


Today, I’ll show you how to change the bash prompt on RHEL (Red Hat Enterprise Linux). The bash prompt, also known as the command prompt, is the text or graphical indication on the screen that shows where the user should type the next command. It usually includes information such as the username, hostname, current working directory, and more. Customizing the prompt can make your terminal sessions more personalized and efficient. Let’s dive into the process of changing the bash prompt on RHEL.

Understanding the Bash Prompt

Before we start customizing the bash prompt, it’s important to understand the components that make up the default prompt. In RHEL, the default bash prompt typically includes the username, followed by the “@” symbol and the hostname, then the current working directory, and finally the dollar sign ($).

Changing the Bash Prompt

First, open the terminal on your RHEL system. The configuration file that controls the bash prompt is .bashrc, which is located in the user’s home directory. You can use your favorite text editor to modify this file. I personally prefer using nano, so I’ll use it for this example.

Open the .bashrc file in the terminal using the following command:

nano ~/.bashrc

Once the file is open, we can customize the prompt by modifying the PS1 variable. This variable controls the primary prompt and allows for various placeholders and formatting options. Here are some commonly used placeholders:

  • \u – the username
  • \h – the hostname
  • \w – the current working directory
  • \$ – a literal ‘$’ character

For example, if I want to add the current time to my prompt, I can modify the PS1 variable like this:

PS1="\u@\h [\$(date +'%T')] \w $ "

After making the desired changes, save the file and exit the text editor. To apply the new configuration, either open a new terminal session or run the following command:

source ~/.bashrc

Personal Touches

Customizing the bash prompt is a personal affair. It’s an opportunity to make your command line environment reflect your style and preferences. Some users prefer minimal prompts with essential information, while others might opt for colorful and informative prompts. Experiment with different configurations until you find one that suits your workflow and personality.


Changing the bash prompt on RHEL allows you to tailor the command line experience to your liking. With a bit of creativity and understanding of the available options, you can create a personalized and efficient prompt that enhances your productivity. Have fun experimenting with different prompt configurations!