Bash Prompt Basics

Your bash prompt is that beginning bit of your terminal session.  You can change this to be whatever you like.  Some people like to change it to say <prod> if they are on a production machine, or turn the color red if they have made an update to the git repository they are working in.  There are endless ways to configure this to your liking.

Most people will start with their username, the hostname of the machine they are one, and typically the current working directory, to help add context to where they are in the file system, instead of typing ‘pwd’ every 5 seconds.

The PS1 environment variable is what sets up your bash prompt:


\u = username

\h = hostname

\w = current working directory


You can save this PS1 variable in several different places, depending on your usecase.  If you have root access, you can change the PS1 variable for everyone on that server.  It is typical to only change your own PS1

Typically, you are going to want to set this in your own ~/.bashrc file

If you want this PS1 set for everyone on the system, you can set it in /etc/bashrc, of /etc/profile.d/

Here are some cool suggestions to customize your PS1 to work with the git:


For more info see the “PROMPTING” section in the bash man page:

Leave a Reply

Your email address will not be published. Required fields are marked *