≡ Menu

HowTo Turn On or Off Colors For ls Command In Bash On a Linux and Unix-like Systems

How do I turn on or off file name colors (ls command colors) in bash shell on a Linux or Unix like operating systems?

Most modern Linux distributions and Unix systems comes with alias that defines colors for your file. However, ls command is responsible for displaying color on screen for files, directories and other file system objects.

By default, color is not used to distinguish types of files. You need to pass --color option to the ls command on Linux. If you are using OS X or BSD based system pass -G option to the ls command. The syntax is as follows to turn on or off colors.

Task: Turn off colors for ls command

Type the following command
$ ls --color=none
Or just remove alias with unalias command:
$ unalias ls

Task: Turn on colors for ls command

Use any one of the following command:
$ ls --color=auto
$ ls --color=tty

A note about *BSD/OS X ls command

Pass the -G option to ls command to enable colorized output on a {Free,Net,Open}BSD or Apple OS X:
$ ls -G

You can add or remove ls command alias to ~/.bash_profile or ~/.bashrc file.

{ 1 comment… add one }

  • Philippe Petrinko April 2, 2010, 8:24 am

    Well may be the title would be better if it would mention [ ls ].
    something like:
    How to turn on or off colors _for ls command_ in bash

Leave a Comment

   Tagged with: , ,