Main Menu

search

You are here

Linux CLI directory listing colors

[last updated: 2023-04-13]
Linux home page
Linux commands
-----

    Colors of listed files:
    • Foreground and background colors, and formatting (bold, etc.) are specified in the environment variable:
      LS_COLORS
    • To see default color coding:
      $ echo $LS_COLORS
    • Default colors:
        blue is a directory
        green is executable
        blue text with green background is a directory that is writable by others in addition to the owning user and group
        and many others...
    • Each file type can have foreground and background colors specified, as well as font syles like bold, underline, etc.
      ...
      ...
      ...
      ...
    • To change colors:
      • References:
        https://www.howtogeek.com/307899/how-to-change-the-colors-of-directories...
        https://www.2daygeek.com/understanding-the-color-code-of-linux-files/
      • first save default:
        $ ORIGCOLOR=$LS_COLORS
      • to restore it:
        $ LS_COLORS=$ORIGCOLOR
      • To change colors for files of a particular type,
        for example, files that are writable by others (file type code: ow)
        $ LS_COLORS="ow=31"
        This will change other-writable files to red text with no background
      • To change colors for files with a particular extension:
        for example, jpgfiles that are writable by others (file type code: ow)
        $ LS_COLORS="ow=31"

      • Note: such changes are not saved when you close the terminal.
        To make the changes permanent, you must edit the /.bashrc file
        See instructions in first link above...