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.
|Omesh Tickoo and Ravi Iyer's Making Sense of Sensors (Apress)||Apr 21, 2017|
|Low Power Wireless: 6LoWPAN, IEEE802.15.4 and the Raspberry Pi||Apr 20, 2017|
|CodeLathe's Tonido Personal Cloud||Apr 19, 2017|
|Wrapping Up the Mars Lander||Apr 18, 2017|
|MultiTaction's MT Canvus-Connect||Apr 17, 2017|
|Android Candy: Facebook Everything?!?!||Apr 14, 2017|
- Teradici's Cloud Access Platform: "Plug & Play" Cloud for the Enterprise
- Low Power Wireless: 6LoWPAN, IEEE802.15.4 and the Raspberry Pi
- The Weather Outside Is Frightful (Or Is It?)
- Simple Server Hardening
- Understanding Firewalld in Multi-Zone Configurations
- Gordon H. Williams' Making Things Smart (Maker Media, Inc.)
- Non-Linux FOSS: Control Web-Based Music!
- Server Technology's HDOT Alt-Phase Switched POPS PDU
- IGEL Universal Desktop Converter