Setting Linux Prompt in CentOS 6.4

Posted Sep 05, 2013

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:
-bash-4.1$

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.

Discussions

Shannon M Sep 5, 2013 8:31 PM - 1 Comments
Love the article! Spot on!
Cancel Reply

Reply

Comments are currently turned off

Latest Discussions

  • Carlos: Thank you!
    May 16, 2014 | Replies (0)
  • Jessica: Great info, thanks!
    May 15, 2014 | Replies (1)
  • Walter: Thanks, you totally saved me a bunch of searching around just now. I was setting up a percona xtradb...
    Feb 25, 2014 | Replies (0)
  • Avi: I've found the reason of the problem in my case. It's a bug as described here :http://bugs.mysql.com/bug.php?id=68892Shortly:...
    Dec 12, 2013 | Replies (0)
  • Avi: I've also met that behavior twice on 5.6.12 slaves. However, i didn't find the root cause of that....
    Dec 12, 2013 | Replies (0)