Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 system and network administrators.

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


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.