4

I'm editing the LS_COLORS environment variable. dircolors lists the default colors for different file types. The file types are denoted as follows:

bd = (BLOCK, BLK)   Block device (buffered) special file
cd = (CHAR, CHR)    Character device (unbuffered) special file
di = (DIR)  Directory
do = (DOOR) [Door][1]
ex = (EXEC) Executable file (ie. has 'x' set in permissions)
fi = (FILE) Normal file
ln = (SYMLINK, LINK, LNK)   Symbolic link. If you set this to ‘target’ instead of a numerical value, the color is as for the file pointed to.
mi = (MISSING)  Non-existent file pointed to by a symbolic link (visible when you type ls -l)
no = (NORMAL, NORM) Normal (non-filename) text. Global default, although everything should be something
or = (ORPHAN)   Symbolic link pointing to an orphaned non-existent file
ow = (OTHER_WRITABLE)   Directory that is other-writable (o+w) and not sticky
pi = (FIFO, PIPE)   Named pipe (fifo file)
sg = (SETGID)   File that is setgid (g+s)
so = (SOCK) Socket file
st = (STICKY)   Directory with the sticky bit set (+t) and not other-writable
su = (SETUID)   File that is setuid (u+s)
tw = (STICKY_OTHER_WRITABLE)    Directory that is sticky and other-writable (+t,o+w)

How do I determine which of these categories a file or directory belongs to?

Links I'm referencing for LS_COLORS:

Using file is not working; querying a directory tells me the directory is... a directory. But clearly it has a filetype flag that file is not displaying, because some directories have an absolutely awful pale-green highlight with white text. Using ls -lah does not work either; the first letter of the permissions string is d and this again is not enough information.

Ubuntu 19.10 | KDE Plasma 5.16.5 | zsh 5.7.1

1
  • Check if the permissions on those folders are different than the rest. That is what I usually find that is coloring my directories oddly. Jun 25, 2020 at 15:11

1 Answer 1

5

I don't know of a program that will list the file type as dircolors knows it. I suspect there isn't, though it would be a nice addition to dircolors But you can dump the database and find there the ones you want to change. For example, for directories:

$ dircolors -p|grep dir

# Configuration file for dircolors, a utility to help you set the
# slackware version of dircolors) are recognized but ignored.
DIR 01;34 # directory
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable

Now you know just how many different types of directories there are (for dicolors, they are just directories for file. Check the permissions of the white on pale-green directory with ls -ld your_directory

You can also list the colors with their meaning, in your system. Check this script.

I know these steps do not do exactly what you want: get the file type dircolors uses for a certain node. But, between the two they should help debug and you adjust your colors for those file types you cannot otherwise find.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .