I wanted to change my Linux prompt for a new install of CentOS 6.4. The default installation by my hosting provider has a regular users prompt like this:
I performed a search and found this article from a favorite Linux site of mine:
How to: Change / Setup bash custom prompt (PS1)
According to the article, I should edit /etc/bashrc. I don’t know if something changed in CentOS 6.4, but when I edit bashrc, it says this at the top:
# It’s NOT a good idea to change this file unless you know what you # are doing. It’s much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates.
So I took its advice and created custom.sh in /etc/profile.d/:
$ vi /etc/profile.d/custom.sh
And I added the PS1 = to it:
PS1=”[\u@\h:\w ] $ “
My prompt now looks similar to this in my home directory:
[user@hostname:~ ] $
or this in a subdirectory
[user@hostname:/tmp ] $
The article has a nice list of codes I won't republish here.