I wanted to enable color in the shell as the root user on Ubuntu Server 22.04 after having typed sudo -s
. I found this question which led me to the solution of uncommenting the force_color_prompt=yes
in the file /root/.bashrc
. This worked well, but I'm now wondering if there is also a way to change the color of the root prompt to give better indication that I'm operating as root.
Here is what I have:
Here is what I want:
Update:
For completeness here is my original PS1
line:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
And here is the modified PS1
line which gave me the results I desired:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
sudo
group to a minimal amount of trusted users and have no actual users in theroot
group. Sensitive files haveroot:root
ownership usually with X00 permissions. – ubiquibacon Mar 12 '24 at 17:10