Change bash prompt for all users

February 25, 2020 Stanly G Linux, Bash, Shell 0 minutes, 27 seconds

Sometimes you want to customize the shell prompt for all users (on a multiuser system), at least as a default.

For the EL 6 and 7 operating systems, this method works:

echo 'PS1="\u@\H \w \\$ "' > /etc/profile.d/custom.sh

It is very highly recommended to end with the \\$ sequence so that you know where the prompt ends, especially if you're interacting with the shell using expect or a similar screen-scraping utility.

Of course, if you want a fancier prompt, you can use something like Ezprompt and make it super fancy.