Highlight Your Shell Prompt When Working as Root
A useful thing that some distros have started doing is setting the color of your shell prompt differently if you're logged in as root. This gives you an additional visual cue that helps avoid doing things as root when you don't want to. If your distro doesn't do this for you, you can accomplish it by changing your .bashrc files. To set the color of your shell prompt you set the shell variable PS1.
To make the prompt red when you're running as root add this to /root/.bashrc:
To make the prompt green when running as a normal user add this to ~/.bashrc:
See the shell man page and search the web for ANSI Escape codes for more info on the meaning of the escape sequences.
In the image below the top shell window is a normal user, the bottom one is a root window.________________________________
Mitch Frazier is an Associate Editor for Linux Journal.
|Where's That Pesky Hidden Word?||Aug 28, 2015|
|A Project to Guarantee Better Security for Open-Source Projects||Aug 27, 2015|
|Concerning Containers' Connections: on Docker Networking||Aug 26, 2015|
|My Network Go-Bag||Aug 24, 2015|
|Doing Astronomy with Python||Aug 19, 2015|
|Build a “Virtual SuperComputer” with Process Virtualization||Aug 18, 2015|
- Concerning Containers' Connections: on Docker Networking
- Where's That Pesky Hidden Word?
- Problems with Ubuntu's Software Center and How Canonical Plans to Fix Them
- A Project to Guarantee Better Security for Open-Source Projects
- Firefox Security Exploit Targets Linux Users and Web Developers
- Doing Astronomy with Python
- Build a “Virtual SuperComputer” with Process Virtualization
- My Network Go-Bag
- Three More Lessons
- Calling All Linux Nerds!