Get the red root prompt back in Linux Mint 19 & Newer

The Linux terminal is one of those indispensable tools that I spent lots of time in. Linux Mint recently released a new version, 19, to replace 18.3. There were several good upgrades, including a major update to the Cinnamon window manager, so it was worthwhile to get the newer versions installed.

Unfortunately, one of the things that changed was the behavior of the command prompt, and I don’t think the new version is an improvement. The regular user prompt stayed the same:

But the root prompt changed. Actually, it didn’t. In older versions, when you did something like sudo into the root account, you got a prompt like this:

In Linux Mint 19, the root prompt remains the same green color. This isn’t the end of the world and everything works fine. Despite that, I always found the red prompt to be an excellent visual indicator of the elevated privileges that the root user has. It prevents me from just issuing commands that might be problematic, or doing something that I actually want to use my chris account for.

Switching the prompt back

The good news is that it’s really easy to get the older 18-style prompt. Simply edit ~/,bashrc (except that comma should be a period, but WordPress is giving me fits if I leave the actual file name in — same thing below) and change these lines:

if [ "$color_prompt" = yes ]; then
   PS1='${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[
00m]$ '
else
   PS1='${debian_chroot:+($debian_chroot)}u@h:w$ '
fi

to

if [ "$color_prompt" = yes ]; then
   if [[ ${EUID} == 0 ]] ; then
      PS1='${debian_chroot:+($debian_chroot)}[33[01;31m]h[33[01;34m] W $[33[00m] '
   else
      PS1='${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m] [33[01;34m]w $[33[00m] '
   fi
else
   PS1='${debian_chroot:+($debian_chroot)}u@h w $ '
fi

Save the file and run source ~/,bashrc to reset your terminal.

Leave a Comment

You must be logged in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.