When using ls to list files in a directory, the files are colored according to their access permissions.

Is it possible to color the files only according to their file types (e.g. a regular file, a directory, a special file such as a socket, a symlink, ...)?

  • Hang on, do you want to list files according to their type or color them? Your title asks one thing and the question another.
    – terdon
    Oct 25 '15 at 1:00
  • color. sorry ....
    – Tim
    Oct 25 '15 at 1:11
  • OK, so the dupe should cover it. Let me know if it doesn't.
    – terdon
    Oct 25 '15 at 1:19
  • 1
    The duplicate is Linux-specific (and reading the suggested duplicate, it is not useful). An answer points out that the OP's question depends on the system and can differ from Linux. Oct 25 '15 at 10:48

I recommend reading the manual page for the ls command relevant to your specific operating system and its version.

Shell environment variables might need to be set correctly. For example, on Apple OS X, TERM needs to be set to a color capable console as defined by termcap and the CLICOLOR or CLICOLOR_FORCE variable need be set in order to then appreciate the result of the -G option to the ls command.

In other words, on OS X:

   export CLICOLOR=TRUE ; ls -lAG /

Not the answer you're looking for? Browse other questions tagged or ask your own question.