Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Are there any security concerns? What is the best way to enable it?

share|improve this question

migrated from serverfault.com Apr 6 '11 at 14:03

This question came from our site for professional system and network administrators.

4 Answers 4

Well, the best (IMHO) way to enable it is editing /root/.bashrc and uncomment the following lines:

export LS_OPTIONS='--color=auto'
eval "`dircolors`"
alias ls='ls $LS_OPTIONS'

If you want to apply the changes, type the following in your home directory:

root@hostname# . .bashrc
share|improve this answer
    
also, in the same file you can force a colored prompt. –  kuhkatz Apr 6 '11 at 18:34
    
I'm still left wondering why, but good info on fixing it. –  Jeff Welling Jun 30 '11 at 6:40

I can't imagine any security concerns. My guess is that, from a Debian point of view, people are not supposed to work as root anyhow, so there is no point in having anything but the most spartan setup.

If you just want colors for ls, this is one of many ways to enable it:

alias ls="ls --color=auto"

You could also enable colors, permanently or temporary, the way Random832 suggests.

share|improve this answer
6  
It may also be used as a visual reminder that you're running as root. –  Joe Internet Jul 1 '11 at 4:51
3  
Joe, that's true. But many other distros, like OpenSUSE, has colors enabled as root with a red prompt. Having visual reminders and colors enabled are not opposites. –  Alexander Jul 1 '11 at 7:46
    
Another possibility might be that if you're logging in as root there is a nontrivial chance that something has gone badly wrong, and whatever terminal you're using to access the system to fix things may or may not be able to handle colors properly... –  Shadur Jul 22 '11 at 15:08
    
Shadur, it's a highly unlikely scenario that only terminals without color should be available for logging into the broken computer that has a colored prompt. When was the last time a terminal that didn't support colors was sold? And what are the chances that a person owning one of those does not own another device that does support color terminals? Even mobile phones can have color terminals. I'll go out on a ledge and say that this is not the reason why Debian leaves the prompt uncolored. –  Alexander Jun 25 '12 at 9:16
    
It at least makes working this way uncomfortable, and by that encourages switching the user (additional to just reminding you, by giving you a red prompt, etc.). So it makes sense in a way, although it is one of the first things I change after a fresh install :-) –  Levit Jul 17 at 7:37

When you edit ~/.bashrc or /root/.bashrc there should be a commented line: # PS1... enter this line directly beneath it:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Now save your file and type:. .bashrc

Et Voila.

share|improve this answer
    
+1 This makes just the prompt colorful, to (additionally) display file/directory listings in color look at either ortegaga's or Alexander's answer. –  Levit Jul 17 at 7:46

In Wheezy (Debian 7) I would rather make all colors appear (not just for single command) uncommenting the line

force_color_prompt=yes

in an user directory and then copying all color-related code from the line starting with

# set a fancy prompt

down to just before the end of the file.

By the way, ~/.bashrc is really well commented. According to it color is

turned off by default to not distract the user: the focus in a terminal window should be on the output of commands, not on the prompt

Personally, I find it hard to read the outputs without color...

share|improve this answer
2  
+1, without being able to clearly see the prompt I find it very hard to locate where my commands begin and where they end. –  Thomas Dec 28 '13 at 10:37
    
+1, if the focus should be on the output, it should color the output. –  Robert Jun 11 at 6:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.