How To Turn On/Off Colors For ls Command In Bash On a Linux/Unix

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.

Tutorial details
Difficulty level Easy
Root privileges No
Requirements None
Est. reading time N/A
[/donotprint]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.

How to turn off colors for ls command

Type the following command
$ ls --color=none
Or just remove alias with the unalias command:
$ unalias ls
Please note that the following bash shell aliases are defined to display color with the ls command. Use combination of alias command and grep command as follows:
$ alias | grep ls
Sample outputs

alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'

How to turn on colors for ls command

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

Define bash shell aliases if you want:
alias ls='ls --color=auto'
You can add or remove ls command alias to the ~/.bash_profile or ~/.bashrc file. Edit file using a text editor such as vi command:
$ vi ~/.bashrc
Append the following code:

# my ls command aliases #
alias ls='ls --color=auto'

Save and close the file in Vi/Vim text editor.

A note about *BSD/macOS/Apple OS X ls command

Pass the -G option to ls command to enable colorized output on a {Free,Net,Open}BSD or macOS and Apple OS X Unix family of operating systems:
$ ls -G
Sample outputs:

How to enable colorized output for the ls command in Mac OS X Terminal

How to enable colorized output for the ls command in Mac OS X Terminal

How do I skip colorful ls command output temporarily?

You can always disable bash shell aliases temporarily using any one of the following syntax:
command ls

This entry is 2 of 5 in the Coloring Outputs in the CLI Apps Tutorial series. Keep reading the rest of the series:
  1. How to enable colorized output for ls command in MacOS X Terminal
  2. How To Turn On/Off Colors For ls Command In Bash On a Linux/Unix
  3. Turn off color in Linux terminal/bash session
  4. Turn On or Off Color Syntax Highlighting In vi or vim Editor
  5. BASH Shell: Change The Color of My Shell Prompt Under Linux or UNIX

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Philippe Petrinko Apr 2, 2010 @ 8:24

    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 Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum