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.

Normally commands such as ls and grep offer nice syntax highlighting for me. But my system crashed (running an ubuntu VM) and after I restarted, I no longer have this highlighting, it's all a dreary grey.

Nano, however, notably does do it's normal highlighting.

I don't know where to start looking for why I don't have directory highlighting any more, or why grep doesn't highlight matched lines any more.

share|improve this question

migrated from serverfault.com Nov 12 '12 at 3:04

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

2 Answers 2

up vote 3 down vote accepted

The thing that makes ls use colors is the alias set by the default bash config, something like this:

alias ls="ls --color=auto"

This is generally in /etc/bash.bashrc or ~/.bashrc. It is possible that one of those files got corrupted when your system crashed. Do this in your VM:

sudo touch /forcefsck

And reboot it. Then check those files.

share|improve this answer
    
And grep is alias grep="grep --color" :) –  Dennis Kaarsemaker Nov 11 '12 at 23:41
    
Ah, I think I see the problem. I had added a .bash_profile for another purpose, and I think, given this file, it wasn't sourcing .bashrc. Your explanation helped me track down the problem, and I've now added the source .bashrc to my .bash_profile. This answer also helped: stackoverflow.com/questions/820517/bashrc-at-ssh-login –  David Parks Nov 12 '12 at 0:44

"syntax highlighting" in bash for ls command is controled by --color switch

If you want to add to your bash edit ~/.bashrc file. This is how end of my .bashrc looks like:

alias ls='ls --color=always'
alias less='less -r'

to force reading of .bashrc just start new bash shell or logout and login

this 2 aliases will make command:

ls -al | less

have color, also you can add something like this:

alias l='ls -al --color=always | less -r'

to just type l and to have color directory output and page-per-page output.

share|improve this answer

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.