Understand ls Command Colors in Linux: File Type & Permission Explained

If you’ve ever run the ls command in a modern Linux terminal and noticed colorful output, you’re not alone. These colors aren’t just aesthetic—they convey useful information about file types, permissions, and statuses.

Knowing what each color means can help you quickly distinguish between directories, executables, symbolic links, and potentially dangerous files—saving you time and avoiding mistakes.

What Triggers Color Output in ls?

The ls command outputs colored text when it is run with the --color=auto or --color=always option. Most Linux distributions alias ls to include this by default.

ls --color=auto

Or to see all colors:

ls --color=always

You can check your alias using:

alias ls

Explanation:
This command checks whether ls has been aliased to include --color=auto. If so, it means your system already supports and displays colored output by default.

Meaning of Colors in ls Output

Here’s a breakdown of common colors used by ls (with --color enabled):

ColorMeaning
BlueDirectory
GreenExecutable file
Cyan (light blue)Symbolic link
Yellow with black textDevice (block/character special file)
MagentaImage file or archive
RedCompressed file / archive
Red (flashing or with background)Broken symbolic link or missing file
WhiteRegular file
Grey/DarkOther / special types

Below, we will try to create some of the files and know its colors.

 $ mkdir linux-color-coding 

White Color – Indicates regular files. so it can be text file, word document or pdf document etc. Lets create simple text file as,

$ echo "hello text file" > textfile.txt

All the normal files created / present, by default has the permission set to “664

$ ls -alh
-rw-rw-r-- 1 myuser myuser   16 Aug 23 07:43 textfile.txt

Bright Green – Indicates file which are executable. All the executable files in Linux has “x” i.e. executable permissions set, which makes the permissions as “775
Lets create one simple C program and compile it to generate executable as,

 $ vim helloworld.c 
#include <stdio.h>
int main(int argc, char **argv) {
        printf("hello world\n");
        return 0;
}


Compile to generate executable file as,

 $ gcc -o helloworld_exe helloworld.c 

We can check the default permissions set by above compilation for executable “helloworld_exe” is “775” as,

$ ls -alh
-rw-rw-r-- 1 myuser myuser   92 Aug 23 07:52 helloworld.c
-rwxrwxr-x 1 myuser myuser 7.2K Aug 23 07:52 helloworld_exe

Blue – Indicates its a directory. Default permissions of the newly created directory is 775

 $ mkdir directory_name 
$ ls -alh
drwxrwxr-x 2 myuser myuser 4.0K Aug 23 09:36 directory_name

Yellow – Indicates its a device file. Most of the device files created by Linux kernel resides in /dev . Below is an example of device file which will be displayed in yellow color.

$ ls -al /dev/console 
crw------- 1 root root 5, 1 Aug 23 09:25 /dev/console 

Cyan / greenish-blue – Indicates its a softlink to another file. We can create a softlink to our previously created executable as,

 $ ln -sf helloworld_exe helloworld_softlink 
 $ ls -alh 

-rwxrwxr-x 1 myuser myuser 7.2K Aug 23 09:59 helloworld_exe
lrwxrwxrwx 1 myuser myuser 14 Aug 23 10:00 helloworld_softlink -> helloworld_exe

Red with light black background – Indicates its a broken softlink. Means, the file where the link was pointing has been deleted.
We will try to create a broken softlink as,

 $ gcc -o helloworld_exe1 helloworld.c
$ ln -sf helloworld_exe1 helloworld_softlink_broken
$ rm -rf helloworld_exe1
$ ls -alh
lrwxrwxrwx 1 myuser myuser   15 Aug 23 10:05 helloworld_softlink_broken -> helloworld_exe1

Here, helloworld_exe1 we purposefully deleted to create broken softlink.

Magneta ( a light mauvish-crimson color ) Indicates it is a “Image” or “Video” file depending on the extension of file.

$ ls -alh
-rw-rw-r-- 1 myuser myuser  93K Aug 23 10:11 mypicture.jpg 


Red – Indicates its archive / compressed file.

We will create a simple zip with the existing files as,

$ zip -r hello.zip helloworld.c helloworld_exe 
  adding: helloworld.c (deflated 3%)
  adding: helloworld_exe (deflated 68%) 

$ ls -alh
-rw-rw-r-- 1 myuser myuser 2.8K Aug 23 10:18 hello.zip
-rw-rw-r-- 1 myuser myuser  93K Aug 23 10:11 mypicture.jpg

$ file hello.zip 
hello.zip: Zip archive data, at least v2.0 to extract

So finally this will Look Like below,

The color-coded output of the ls command is more than just pretty text—it’s a powerful visual aid. Learning what each color represents allows you to scan your file system faster, spot issues immediately, and be more efficient in managing your Linux environment.

Still confused by ls colors or want help customizing your terminal colors? Drop your setup or questions in the comments and let’s fix it together!

1 thought on “Understand ls Command Colors in Linux: File Type & Permission Explained”

Leave a Comment