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

Posted on in Categories , , last updated March 14, 2014

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.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

1 comment

Leave a Comment