How to change the color of text and background of terminal?

When I'm... well, confused what my car has decided that we need something to do. How easy it is to change the color - there are tutorials.
And how to make one color when a normal console, other color when I'm under root, and have different shades for different ssh sessions, is that possible?
July 9th 19 at 13:56
2 answers
July 9th 19 at 13:58
Like you said, tutorials on how to change the color on the network enough, and they all boil down to what we put in PS1 something (in ~/.bashrc):
PS1="\$(if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227 error:\$?\"; fi) [\@] \[\033[01;37m\] \[\033[01;31m\]\u@\h\[\033[01;34m\] \w $\[\033[00m\] "

So, if you want root access to have another color of this invitation in the same PS1 script to check whether you are root and set the other color (which codes correspond to which difficult to find - for example here). Many of us forget that it is possible to do anything: in my example verified as successfully completed the last command, but in the same way you can check what we are)

And having SSH access to your remote machine you can do the same things on it (just with other colors) - when connected you will be greeted by a colored prompt commands.

If it doesn't work (maybe I have only this bug appeared) or you have a few people go to the remote machine under the same name and don't want to see the colors each other, it is possible to put there a file (let's call it ~/.bashrc_ssh) and supply it with the value of PS1. To connect with this option:
ssh username@host-t "bash --rcfile ~/.bashrc_ssh -i"

It will look something like this:
Thus, when connecting (no matter where) to a remote machine, you will be able to get yourself a bright (red to green) the invitation to enter commands. For convenience for this long option, of course, is to make the alias
>> in the same PS1 script to check whether you are root and set the other colors

for root there is \$, which in case of Ruta turns into bars - turner89 commented on July 9th 19 at 14:01
July 9th 19 at 14:00

Find more questions by tags Linux